@vibeframe/mcp-server 0.55.2 → 0.57.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/dist/index.js +4328 -29
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -432888,7 +432888,7 @@ var DEFAULT_MODEL, OpenAIImageProvider, openaiImageProvider;
|
|
|
432888
432888
|
var init_OpenAIImageProvider = __esm({
|
|
432889
432889
|
"../ai-providers/dist/openai-image/OpenAIImageProvider.js"() {
|
|
432890
432890
|
"use strict";
|
|
432891
|
-
DEFAULT_MODEL = "gpt-image-
|
|
432891
|
+
DEFAULT_MODEL = "gpt-image-2";
|
|
432892
432892
|
OpenAIImageProvider = class {
|
|
432893
432893
|
constructor() {
|
|
432894
432894
|
this.id = "openai-image";
|
|
@@ -434188,6 +434188,4268 @@ var init_grok = __esm({
|
|
|
434188
434188
|
}
|
|
434189
434189
|
});
|
|
434190
434190
|
|
|
434191
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/middleware.js
|
|
434192
|
+
var require_middleware = __commonJS({
|
|
434193
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/middleware.js"(exports) {
|
|
434194
|
+
"use strict";
|
|
434195
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
434196
|
+
function adopt(value) {
|
|
434197
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
434198
|
+
resolve44(value);
|
|
434199
|
+
});
|
|
434200
|
+
}
|
|
434201
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
434202
|
+
function fulfilled(value) {
|
|
434203
|
+
try {
|
|
434204
|
+
step(generator.next(value));
|
|
434205
|
+
} catch (e) {
|
|
434206
|
+
reject(e);
|
|
434207
|
+
}
|
|
434208
|
+
}
|
|
434209
|
+
function rejected(value) {
|
|
434210
|
+
try {
|
|
434211
|
+
step(generator["throw"](value));
|
|
434212
|
+
} catch (e) {
|
|
434213
|
+
reject(e);
|
|
434214
|
+
}
|
|
434215
|
+
}
|
|
434216
|
+
function step(result) {
|
|
434217
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
434218
|
+
}
|
|
434219
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
434220
|
+
});
|
|
434221
|
+
};
|
|
434222
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434223
|
+
exports.TARGET_URL_HEADER = void 0;
|
|
434224
|
+
exports.withMiddleware = withMiddleware;
|
|
434225
|
+
exports.withProxy = withProxy;
|
|
434226
|
+
function withMiddleware(...middlewares) {
|
|
434227
|
+
const isDefined = (middleware) => typeof middleware === "function";
|
|
434228
|
+
return (config4) => __awaiter4(this, void 0, void 0, function* () {
|
|
434229
|
+
let currentConfig = Object.assign({}, config4);
|
|
434230
|
+
for (const middleware of middlewares.filter(isDefined)) {
|
|
434231
|
+
currentConfig = yield middleware(currentConfig);
|
|
434232
|
+
}
|
|
434233
|
+
return currentConfig;
|
|
434234
|
+
});
|
|
434235
|
+
}
|
|
434236
|
+
exports.TARGET_URL_HEADER = "x-fal-target-url";
|
|
434237
|
+
function shouldProxy(when) {
|
|
434238
|
+
const env4 = {
|
|
434239
|
+
isBrowser: typeof window !== "undefined" && typeof window.document !== "undefined"
|
|
434240
|
+
};
|
|
434241
|
+
if (typeof when === "function") {
|
|
434242
|
+
return when(env4);
|
|
434243
|
+
}
|
|
434244
|
+
if (when === "always") {
|
|
434245
|
+
return true;
|
|
434246
|
+
}
|
|
434247
|
+
return env4.isBrowser;
|
|
434248
|
+
}
|
|
434249
|
+
function withProxy(config4) {
|
|
434250
|
+
return (requestConfig) => {
|
|
434251
|
+
if (requestConfig.headers && exports.TARGET_URL_HEADER in requestConfig.headers) {
|
|
434252
|
+
return Promise.resolve(requestConfig);
|
|
434253
|
+
}
|
|
434254
|
+
if (!shouldProxy(config4.when)) {
|
|
434255
|
+
return Promise.resolve(requestConfig);
|
|
434256
|
+
}
|
|
434257
|
+
return Promise.resolve(Object.assign(Object.assign({}, requestConfig), { url: config4.targetUrl, headers: Object.assign(Object.assign({}, requestConfig.headers || {}), { [exports.TARGET_URL_HEADER]: requestConfig.url }) }));
|
|
434258
|
+
};
|
|
434259
|
+
}
|
|
434260
|
+
}
|
|
434261
|
+
});
|
|
434262
|
+
|
|
434263
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/headers.js
|
|
434264
|
+
var require_headers3 = __commonJS({
|
|
434265
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/headers.js"(exports) {
|
|
434266
|
+
"use strict";
|
|
434267
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434268
|
+
exports.RUNNER_HINT_HEADER = exports.QUEUE_PRIORITY_HEADER = exports.REQUEST_TIMEOUT_TYPE_HEADER = exports.REQUEST_TIMEOUT_HEADER = exports.MIN_REQUEST_TIMEOUT_SECONDS = void 0;
|
|
434269
|
+
exports.validateTimeoutHeader = validateTimeoutHeader;
|
|
434270
|
+
exports.buildTimeoutHeaders = buildTimeoutHeaders;
|
|
434271
|
+
exports.MIN_REQUEST_TIMEOUT_SECONDS = 1;
|
|
434272
|
+
exports.REQUEST_TIMEOUT_HEADER = "x-fal-request-timeout";
|
|
434273
|
+
exports.REQUEST_TIMEOUT_TYPE_HEADER = "x-fal-request-timeout-type";
|
|
434274
|
+
exports.QUEUE_PRIORITY_HEADER = "x-fal-queue-priority";
|
|
434275
|
+
exports.RUNNER_HINT_HEADER = "x-fal-runner-hint";
|
|
434276
|
+
function validateTimeoutHeader(timeout3) {
|
|
434277
|
+
if (typeof timeout3 !== "number" || isNaN(timeout3)) {
|
|
434278
|
+
throw new Error(`Timeout must be a number, got ${timeout3}`);
|
|
434279
|
+
}
|
|
434280
|
+
if (timeout3 <= exports.MIN_REQUEST_TIMEOUT_SECONDS) {
|
|
434281
|
+
throw new Error(`Timeout must be greater than ${exports.MIN_REQUEST_TIMEOUT_SECONDS} seconds`);
|
|
434282
|
+
}
|
|
434283
|
+
return timeout3.toString();
|
|
434284
|
+
}
|
|
434285
|
+
function buildTimeoutHeaders(timeout3) {
|
|
434286
|
+
if (timeout3 === void 0) {
|
|
434287
|
+
return {};
|
|
434288
|
+
}
|
|
434289
|
+
return {
|
|
434290
|
+
[exports.REQUEST_TIMEOUT_HEADER]: validateTimeoutHeader(timeout3)
|
|
434291
|
+
};
|
|
434292
|
+
}
|
|
434293
|
+
}
|
|
434294
|
+
});
|
|
434295
|
+
|
|
434296
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/response.js
|
|
434297
|
+
var require_response = __commonJS({
|
|
434298
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/response.js"(exports) {
|
|
434299
|
+
"use strict";
|
|
434300
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
434301
|
+
function adopt(value) {
|
|
434302
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
434303
|
+
resolve44(value);
|
|
434304
|
+
});
|
|
434305
|
+
}
|
|
434306
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
434307
|
+
function fulfilled(value) {
|
|
434308
|
+
try {
|
|
434309
|
+
step(generator.next(value));
|
|
434310
|
+
} catch (e) {
|
|
434311
|
+
reject(e);
|
|
434312
|
+
}
|
|
434313
|
+
}
|
|
434314
|
+
function rejected(value) {
|
|
434315
|
+
try {
|
|
434316
|
+
step(generator["throw"](value));
|
|
434317
|
+
} catch (e) {
|
|
434318
|
+
reject(e);
|
|
434319
|
+
}
|
|
434320
|
+
}
|
|
434321
|
+
function step(result) {
|
|
434322
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
434323
|
+
}
|
|
434324
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
434325
|
+
});
|
|
434326
|
+
};
|
|
434327
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434328
|
+
exports.ValidationError = exports.ApiError = void 0;
|
|
434329
|
+
exports.defaultResponseHandler = defaultResponseHandler;
|
|
434330
|
+
exports.resultResponseHandler = resultResponseHandler;
|
|
434331
|
+
var headers_1 = require_headers3();
|
|
434332
|
+
var REQUEST_ID_HEADER = "x-fal-request-id";
|
|
434333
|
+
var ApiError = class extends Error {
|
|
434334
|
+
constructor({ message, status, body, requestId, timeoutType }) {
|
|
434335
|
+
super(message);
|
|
434336
|
+
this.name = "ApiError";
|
|
434337
|
+
this.status = status;
|
|
434338
|
+
this.body = body;
|
|
434339
|
+
this.requestId = requestId || "";
|
|
434340
|
+
this.timeoutType = timeoutType;
|
|
434341
|
+
}
|
|
434342
|
+
/**
|
|
434343
|
+
* Returns true if this error was caused by a user-specified timeout
|
|
434344
|
+
* (via startTimeout parameter). These errors should NOT be retried.
|
|
434345
|
+
*/
|
|
434346
|
+
get isUserTimeout() {
|
|
434347
|
+
return this.status === 504 && this.timeoutType === "user";
|
|
434348
|
+
}
|
|
434349
|
+
};
|
|
434350
|
+
exports.ApiError = ApiError;
|
|
434351
|
+
var ValidationError = class extends ApiError {
|
|
434352
|
+
constructor(args) {
|
|
434353
|
+
super(args);
|
|
434354
|
+
this.name = "ValidationError";
|
|
434355
|
+
}
|
|
434356
|
+
get fieldErrors() {
|
|
434357
|
+
if (typeof this.body.detail === "string") {
|
|
434358
|
+
return [
|
|
434359
|
+
{
|
|
434360
|
+
loc: ["body"],
|
|
434361
|
+
msg: this.body.detail,
|
|
434362
|
+
type: "value_error"
|
|
434363
|
+
}
|
|
434364
|
+
];
|
|
434365
|
+
}
|
|
434366
|
+
return this.body.detail || [];
|
|
434367
|
+
}
|
|
434368
|
+
getFieldErrors(field) {
|
|
434369
|
+
return this.fieldErrors.filter((error) => error.loc[error.loc.length - 1] === field);
|
|
434370
|
+
}
|
|
434371
|
+
};
|
|
434372
|
+
exports.ValidationError = ValidationError;
|
|
434373
|
+
function defaultResponseHandler(response) {
|
|
434374
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434375
|
+
var _a7;
|
|
434376
|
+
const { status, statusText } = response;
|
|
434377
|
+
const contentType = (_a7 = response.headers.get("Content-Type")) !== null && _a7 !== void 0 ? _a7 : "";
|
|
434378
|
+
const requestId = response.headers.get(REQUEST_ID_HEADER) || void 0;
|
|
434379
|
+
const timeoutType = response.headers.get(headers_1.REQUEST_TIMEOUT_TYPE_HEADER) || void 0;
|
|
434380
|
+
if (!response.ok) {
|
|
434381
|
+
if (contentType.includes("application/json")) {
|
|
434382
|
+
const body = yield response.json();
|
|
434383
|
+
const ErrorType = status === 422 ? ValidationError : ApiError;
|
|
434384
|
+
throw new ErrorType({
|
|
434385
|
+
message: body.message || statusText,
|
|
434386
|
+
status,
|
|
434387
|
+
body,
|
|
434388
|
+
requestId,
|
|
434389
|
+
timeoutType
|
|
434390
|
+
});
|
|
434391
|
+
}
|
|
434392
|
+
throw new ApiError({
|
|
434393
|
+
message: `HTTP ${status}: ${statusText}`,
|
|
434394
|
+
status,
|
|
434395
|
+
requestId,
|
|
434396
|
+
timeoutType
|
|
434397
|
+
});
|
|
434398
|
+
}
|
|
434399
|
+
if (contentType.includes("application/json")) {
|
|
434400
|
+
return response.json();
|
|
434401
|
+
}
|
|
434402
|
+
if (contentType.includes("text/html")) {
|
|
434403
|
+
return response.text();
|
|
434404
|
+
}
|
|
434405
|
+
if (contentType.includes("application/octet-stream")) {
|
|
434406
|
+
return response.arrayBuffer();
|
|
434407
|
+
}
|
|
434408
|
+
return response.text();
|
|
434409
|
+
});
|
|
434410
|
+
}
|
|
434411
|
+
function resultResponseHandler(response) {
|
|
434412
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434413
|
+
const data = yield defaultResponseHandler(response);
|
|
434414
|
+
return {
|
|
434415
|
+
data,
|
|
434416
|
+
requestId: response.headers.get(REQUEST_ID_HEADER) || ""
|
|
434417
|
+
};
|
|
434418
|
+
});
|
|
434419
|
+
}
|
|
434420
|
+
}
|
|
434421
|
+
});
|
|
434422
|
+
|
|
434423
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/utils.js
|
|
434424
|
+
var require_utils4 = __commonJS({
|
|
434425
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/utils.js"(exports) {
|
|
434426
|
+
"use strict";
|
|
434427
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
434428
|
+
function adopt(value) {
|
|
434429
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
434430
|
+
resolve44(value);
|
|
434431
|
+
});
|
|
434432
|
+
}
|
|
434433
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
434434
|
+
function fulfilled(value) {
|
|
434435
|
+
try {
|
|
434436
|
+
step(generator.next(value));
|
|
434437
|
+
} catch (e) {
|
|
434438
|
+
reject(e);
|
|
434439
|
+
}
|
|
434440
|
+
}
|
|
434441
|
+
function rejected(value) {
|
|
434442
|
+
try {
|
|
434443
|
+
step(generator["throw"](value));
|
|
434444
|
+
} catch (e) {
|
|
434445
|
+
reject(e);
|
|
434446
|
+
}
|
|
434447
|
+
}
|
|
434448
|
+
function step(result) {
|
|
434449
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
434450
|
+
}
|
|
434451
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
434452
|
+
});
|
|
434453
|
+
};
|
|
434454
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434455
|
+
exports.ensureEndpointIdFormat = ensureEndpointIdFormat;
|
|
434456
|
+
exports.parseEndpointId = parseEndpointId;
|
|
434457
|
+
exports.resolveEndpointPath = resolveEndpointPath;
|
|
434458
|
+
exports.isValidUrl = isValidUrl;
|
|
434459
|
+
exports.throttle = throttle;
|
|
434460
|
+
exports.isReact = isReact;
|
|
434461
|
+
exports.isPlainObject = isPlainObject3;
|
|
434462
|
+
exports.sleep = sleep2;
|
|
434463
|
+
function ensureEndpointIdFormat(id) {
|
|
434464
|
+
const parts = id.split("/");
|
|
434465
|
+
if (parts.length > 1) {
|
|
434466
|
+
return id;
|
|
434467
|
+
}
|
|
434468
|
+
const [, appOwner, appId] = /^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(id) || [];
|
|
434469
|
+
if (appOwner && appId) {
|
|
434470
|
+
return `${appOwner}/${appId}`;
|
|
434471
|
+
}
|
|
434472
|
+
throw new Error(`Invalid app id: ${id}. Must be in the format <appOwner>/<appId>`);
|
|
434473
|
+
}
|
|
434474
|
+
var ENDPOINT_NAMESPACES = ["workflows", "comfy"];
|
|
434475
|
+
function parseEndpointId(id) {
|
|
434476
|
+
const normalizedId = ensureEndpointIdFormat(id);
|
|
434477
|
+
const parts = normalizedId.split("/");
|
|
434478
|
+
if (ENDPOINT_NAMESPACES.includes(parts[0])) {
|
|
434479
|
+
return {
|
|
434480
|
+
owner: parts[1],
|
|
434481
|
+
alias: parts[2],
|
|
434482
|
+
path: parts.slice(3).join("/") || void 0,
|
|
434483
|
+
namespace: parts[0]
|
|
434484
|
+
};
|
|
434485
|
+
}
|
|
434486
|
+
return {
|
|
434487
|
+
owner: parts[0],
|
|
434488
|
+
alias: parts[1],
|
|
434489
|
+
path: parts.slice(2).join("/") || void 0
|
|
434490
|
+
};
|
|
434491
|
+
}
|
|
434492
|
+
function resolveEndpointPath(app, path14, defaultPath) {
|
|
434493
|
+
if (path14) {
|
|
434494
|
+
return `/${path14.replace(/^\/+/, "")}`;
|
|
434495
|
+
}
|
|
434496
|
+
if (app.endsWith(defaultPath)) {
|
|
434497
|
+
return void 0;
|
|
434498
|
+
}
|
|
434499
|
+
return defaultPath;
|
|
434500
|
+
}
|
|
434501
|
+
function isValidUrl(url) {
|
|
434502
|
+
try {
|
|
434503
|
+
const { host } = new URL(url);
|
|
434504
|
+
return /(fal\.(ai|run))$/.test(host);
|
|
434505
|
+
} catch (_) {
|
|
434506
|
+
return false;
|
|
434507
|
+
}
|
|
434508
|
+
}
|
|
434509
|
+
function throttle(func, limit, leading = false) {
|
|
434510
|
+
let lastFunc;
|
|
434511
|
+
let lastRan;
|
|
434512
|
+
return (...args) => {
|
|
434513
|
+
if (!lastRan && leading) {
|
|
434514
|
+
func(...args);
|
|
434515
|
+
lastRan = Date.now();
|
|
434516
|
+
} else {
|
|
434517
|
+
if (lastFunc) {
|
|
434518
|
+
clearTimeout(lastFunc);
|
|
434519
|
+
}
|
|
434520
|
+
lastFunc = setTimeout(() => {
|
|
434521
|
+
if (Date.now() - lastRan >= limit) {
|
|
434522
|
+
func(...args);
|
|
434523
|
+
lastRan = Date.now();
|
|
434524
|
+
}
|
|
434525
|
+
}, limit - (Date.now() - lastRan));
|
|
434526
|
+
}
|
|
434527
|
+
};
|
|
434528
|
+
}
|
|
434529
|
+
var isRunningInReact;
|
|
434530
|
+
function isReact() {
|
|
434531
|
+
if (isRunningInReact === void 0) {
|
|
434532
|
+
const stack = new Error().stack;
|
|
434533
|
+
isRunningInReact = !!stack && (stack.includes("node_modules/react-dom/") || stack.includes("node_modules/next/"));
|
|
434534
|
+
}
|
|
434535
|
+
return isRunningInReact;
|
|
434536
|
+
}
|
|
434537
|
+
function isPlainObject3(value) {
|
|
434538
|
+
return !!value && Object.getPrototypeOf(value) === Object.prototype;
|
|
434539
|
+
}
|
|
434540
|
+
function sleep2(ms) {
|
|
434541
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434542
|
+
return new Promise((resolve44) => setTimeout(resolve44, ms));
|
|
434543
|
+
});
|
|
434544
|
+
}
|
|
434545
|
+
}
|
|
434546
|
+
});
|
|
434547
|
+
|
|
434548
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/retry.js
|
|
434549
|
+
var require_retry = __commonJS({
|
|
434550
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/retry.js"(exports) {
|
|
434551
|
+
"use strict";
|
|
434552
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
434553
|
+
function adopt(value) {
|
|
434554
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
434555
|
+
resolve44(value);
|
|
434556
|
+
});
|
|
434557
|
+
}
|
|
434558
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
434559
|
+
function fulfilled(value) {
|
|
434560
|
+
try {
|
|
434561
|
+
step(generator.next(value));
|
|
434562
|
+
} catch (e) {
|
|
434563
|
+
reject(e);
|
|
434564
|
+
}
|
|
434565
|
+
}
|
|
434566
|
+
function rejected(value) {
|
|
434567
|
+
try {
|
|
434568
|
+
step(generator["throw"](value));
|
|
434569
|
+
} catch (e) {
|
|
434570
|
+
reject(e);
|
|
434571
|
+
}
|
|
434572
|
+
}
|
|
434573
|
+
function step(result) {
|
|
434574
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
434575
|
+
}
|
|
434576
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
434577
|
+
});
|
|
434578
|
+
};
|
|
434579
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434580
|
+
exports.DEFAULT_RETRY_OPTIONS = exports.DEFAULT_RETRYABLE_STATUS_CODES = void 0;
|
|
434581
|
+
exports.isRetryableError = isRetryableError;
|
|
434582
|
+
exports.calculateBackoffDelay = calculateBackoffDelay;
|
|
434583
|
+
exports.executeWithRetry = executeWithRetry;
|
|
434584
|
+
var response_1 = require_response();
|
|
434585
|
+
var utils_1 = require_utils4();
|
|
434586
|
+
exports.DEFAULT_RETRYABLE_STATUS_CODES = [429, 502, 503, 504];
|
|
434587
|
+
exports.DEFAULT_RETRY_OPTIONS = {
|
|
434588
|
+
maxRetries: 3,
|
|
434589
|
+
baseDelay: 1e3,
|
|
434590
|
+
maxDelay: 3e4,
|
|
434591
|
+
backoffMultiplier: 2,
|
|
434592
|
+
retryableStatusCodes: exports.DEFAULT_RETRYABLE_STATUS_CODES,
|
|
434593
|
+
enableJitter: true
|
|
434594
|
+
};
|
|
434595
|
+
function isRetryableError(error, retryableStatusCodes) {
|
|
434596
|
+
if (!(error instanceof response_1.ApiError)) {
|
|
434597
|
+
return false;
|
|
434598
|
+
}
|
|
434599
|
+
if (error.isUserTimeout) {
|
|
434600
|
+
return false;
|
|
434601
|
+
}
|
|
434602
|
+
return retryableStatusCodes.includes(error.status);
|
|
434603
|
+
}
|
|
434604
|
+
function calculateBackoffDelay(attempt, baseDelay, maxDelay, backoffMultiplier, enableJitter) {
|
|
434605
|
+
const exponentialDelay = Math.min(baseDelay * Math.pow(backoffMultiplier, attempt), maxDelay);
|
|
434606
|
+
if (enableJitter) {
|
|
434607
|
+
const jitter = 0.25 * exponentialDelay * (Math.random() * 2 - 1);
|
|
434608
|
+
return Math.max(0, exponentialDelay + jitter);
|
|
434609
|
+
}
|
|
434610
|
+
return exponentialDelay;
|
|
434611
|
+
}
|
|
434612
|
+
function executeWithRetry(operation, options, onRetry) {
|
|
434613
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434614
|
+
const metrics = {
|
|
434615
|
+
totalAttempts: 0,
|
|
434616
|
+
totalDelay: 0
|
|
434617
|
+
};
|
|
434618
|
+
let lastError;
|
|
434619
|
+
for (let attempt = 0; attempt <= options.maxRetries; attempt++) {
|
|
434620
|
+
metrics.totalAttempts++;
|
|
434621
|
+
try {
|
|
434622
|
+
const result = yield operation();
|
|
434623
|
+
return { result, metrics };
|
|
434624
|
+
} catch (error) {
|
|
434625
|
+
lastError = error;
|
|
434626
|
+
metrics.lastError = error;
|
|
434627
|
+
if (attempt === options.maxRetries || !isRetryableError(error, options.retryableStatusCodes)) {
|
|
434628
|
+
throw error;
|
|
434629
|
+
}
|
|
434630
|
+
const delay = calculateBackoffDelay(attempt, options.baseDelay, options.maxDelay, options.backoffMultiplier, options.enableJitter);
|
|
434631
|
+
metrics.totalDelay += delay;
|
|
434632
|
+
if (onRetry) {
|
|
434633
|
+
onRetry(attempt + 1, error, delay);
|
|
434634
|
+
}
|
|
434635
|
+
yield (0, utils_1.sleep)(delay);
|
|
434636
|
+
}
|
|
434637
|
+
}
|
|
434638
|
+
throw lastError;
|
|
434639
|
+
});
|
|
434640
|
+
}
|
|
434641
|
+
}
|
|
434642
|
+
});
|
|
434643
|
+
|
|
434644
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/package.json
|
|
434645
|
+
var require_package3 = __commonJS({
|
|
434646
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/package.json"(exports, module) {
|
|
434647
|
+
module.exports = {
|
|
434648
|
+
name: "@fal-ai/client",
|
|
434649
|
+
description: "The fal.ai client for JavaScript and TypeScript",
|
|
434650
|
+
version: "1.10.0",
|
|
434651
|
+
license: "MIT",
|
|
434652
|
+
repository: {
|
|
434653
|
+
type: "git",
|
|
434654
|
+
url: "https://github.com/fal-ai/fal-js.git",
|
|
434655
|
+
directory: "libs/client"
|
|
434656
|
+
},
|
|
434657
|
+
keywords: [
|
|
434658
|
+
"fal",
|
|
434659
|
+
"client",
|
|
434660
|
+
"ai",
|
|
434661
|
+
"ml",
|
|
434662
|
+
"typescript"
|
|
434663
|
+
],
|
|
434664
|
+
exports: {
|
|
434665
|
+
".": "./src/index.js",
|
|
434666
|
+
"./endpoints": "./src/types/endpoints.js"
|
|
434667
|
+
},
|
|
434668
|
+
typesVersions: {
|
|
434669
|
+
"*": {
|
|
434670
|
+
endpoints: [
|
|
434671
|
+
"src/types/endpoints.d.ts"
|
|
434672
|
+
]
|
|
434673
|
+
}
|
|
434674
|
+
},
|
|
434675
|
+
main: "./src/index.js",
|
|
434676
|
+
types: "./src/index.d.ts",
|
|
434677
|
+
dependencies: {
|
|
434678
|
+
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
434679
|
+
"eventsource-parser": "^1.1.2",
|
|
434680
|
+
robot3: "^0.4.1"
|
|
434681
|
+
},
|
|
434682
|
+
engines: {
|
|
434683
|
+
node: ">=18.0.0"
|
|
434684
|
+
},
|
|
434685
|
+
type: "commonjs"
|
|
434686
|
+
};
|
|
434687
|
+
}
|
|
434688
|
+
});
|
|
434689
|
+
|
|
434690
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/runtime.js
|
|
434691
|
+
var require_runtime3 = __commonJS({
|
|
434692
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/runtime.js"(exports) {
|
|
434693
|
+
"use strict";
|
|
434694
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434695
|
+
exports.isBrowser = isBrowser;
|
|
434696
|
+
exports.getUserAgent = getUserAgent;
|
|
434697
|
+
function isBrowser() {
|
|
434698
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
434699
|
+
}
|
|
434700
|
+
var memoizedUserAgent = null;
|
|
434701
|
+
function getUserAgent() {
|
|
434702
|
+
if (memoizedUserAgent !== null) {
|
|
434703
|
+
return memoizedUserAgent;
|
|
434704
|
+
}
|
|
434705
|
+
const packageInfo = require_package3();
|
|
434706
|
+
memoizedUserAgent = `${packageInfo.name}/${packageInfo.version}`;
|
|
434707
|
+
return memoizedUserAgent;
|
|
434708
|
+
}
|
|
434709
|
+
}
|
|
434710
|
+
});
|
|
434711
|
+
|
|
434712
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/config.js
|
|
434713
|
+
var require_config = __commonJS({
|
|
434714
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/config.js"(exports) {
|
|
434715
|
+
"use strict";
|
|
434716
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434717
|
+
exports.credentialsFromEnv = void 0;
|
|
434718
|
+
exports.resolveDefaultFetch = resolveDefaultFetch;
|
|
434719
|
+
exports.createConfig = createConfig;
|
|
434720
|
+
exports.getRestApiUrl = getRestApiUrl;
|
|
434721
|
+
var middleware_1 = require_middleware();
|
|
434722
|
+
var response_1 = require_response();
|
|
434723
|
+
var retry_1 = require_retry();
|
|
434724
|
+
var runtime_1 = require_runtime3();
|
|
434725
|
+
function resolveDefaultFetch() {
|
|
434726
|
+
if (typeof fetch === "undefined") {
|
|
434727
|
+
throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");
|
|
434728
|
+
}
|
|
434729
|
+
return fetch;
|
|
434730
|
+
}
|
|
434731
|
+
function hasEnvVariables() {
|
|
434732
|
+
return typeof process !== "undefined" && process.env && (typeof process.env.FAL_KEY !== "undefined" || typeof process.env.FAL_KEY_ID !== "undefined" && typeof process.env.FAL_KEY_SECRET !== "undefined");
|
|
434733
|
+
}
|
|
434734
|
+
var credentialsFromEnv = () => {
|
|
434735
|
+
if (!hasEnvVariables()) {
|
|
434736
|
+
return void 0;
|
|
434737
|
+
}
|
|
434738
|
+
if (typeof process.env.FAL_KEY !== "undefined") {
|
|
434739
|
+
return process.env.FAL_KEY;
|
|
434740
|
+
}
|
|
434741
|
+
return process.env.FAL_KEY_ID ? `${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}` : void 0;
|
|
434742
|
+
};
|
|
434743
|
+
exports.credentialsFromEnv = credentialsFromEnv;
|
|
434744
|
+
var DEFAULT_CONFIG2 = {
|
|
434745
|
+
credentials: exports.credentialsFromEnv,
|
|
434746
|
+
suppressLocalCredentialsWarning: false,
|
|
434747
|
+
requestMiddleware: (request5) => Promise.resolve(request5),
|
|
434748
|
+
responseHandler: response_1.defaultResponseHandler,
|
|
434749
|
+
retry: retry_1.DEFAULT_RETRY_OPTIONS
|
|
434750
|
+
};
|
|
434751
|
+
function createConfig(config4) {
|
|
434752
|
+
var _a7;
|
|
434753
|
+
let configuration2 = Object.assign(Object.assign(Object.assign({}, DEFAULT_CONFIG2), config4), {
|
|
434754
|
+
fetch: (_a7 = config4.fetch) !== null && _a7 !== void 0 ? _a7 : resolveDefaultFetch(),
|
|
434755
|
+
// Merge retry configuration with defaults
|
|
434756
|
+
retry: Object.assign(Object.assign({}, retry_1.DEFAULT_RETRY_OPTIONS), config4.retry || {})
|
|
434757
|
+
});
|
|
434758
|
+
if (config4.proxyUrl) {
|
|
434759
|
+
const proxy = typeof config4.proxyUrl === "string" ? { url: config4.proxyUrl } : config4.proxyUrl;
|
|
434760
|
+
configuration2 = Object.assign(Object.assign({}, configuration2), { requestMiddleware: (0, middleware_1.withMiddleware)(configuration2.requestMiddleware, (0, middleware_1.withProxy)({ targetUrl: proxy.url, when: proxy.when })) });
|
|
434761
|
+
}
|
|
434762
|
+
const { credentials: resolveCredentials, suppressLocalCredentialsWarning } = configuration2;
|
|
434763
|
+
const credentials = typeof resolveCredentials === "function" ? resolveCredentials() : resolveCredentials;
|
|
434764
|
+
if ((0, runtime_1.isBrowser)() && credentials && !suppressLocalCredentialsWarning) {
|
|
434765
|
+
console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases.");
|
|
434766
|
+
}
|
|
434767
|
+
return configuration2;
|
|
434768
|
+
}
|
|
434769
|
+
function getRestApiUrl() {
|
|
434770
|
+
return "https://rest.fal.ai";
|
|
434771
|
+
}
|
|
434772
|
+
}
|
|
434773
|
+
});
|
|
434774
|
+
|
|
434775
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/request.js
|
|
434776
|
+
var require_request = __commonJS({
|
|
434777
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/request.js"(exports) {
|
|
434778
|
+
"use strict";
|
|
434779
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
434780
|
+
function adopt(value) {
|
|
434781
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
434782
|
+
resolve44(value);
|
|
434783
|
+
});
|
|
434784
|
+
}
|
|
434785
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
434786
|
+
function fulfilled(value) {
|
|
434787
|
+
try {
|
|
434788
|
+
step(generator.next(value));
|
|
434789
|
+
} catch (e) {
|
|
434790
|
+
reject(e);
|
|
434791
|
+
}
|
|
434792
|
+
}
|
|
434793
|
+
function rejected(value) {
|
|
434794
|
+
try {
|
|
434795
|
+
step(generator["throw"](value));
|
|
434796
|
+
} catch (e) {
|
|
434797
|
+
reject(e);
|
|
434798
|
+
}
|
|
434799
|
+
}
|
|
434800
|
+
function step(result) {
|
|
434801
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
434802
|
+
}
|
|
434803
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
434804
|
+
});
|
|
434805
|
+
};
|
|
434806
|
+
var __rest3 = exports && exports.__rest || function(s, e) {
|
|
434807
|
+
var t = {};
|
|
434808
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
434809
|
+
t[p] = s[p];
|
|
434810
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
434811
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
434812
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
434813
|
+
t[p[i]] = s[p[i]];
|
|
434814
|
+
}
|
|
434815
|
+
return t;
|
|
434816
|
+
};
|
|
434817
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434818
|
+
exports.dispatchRequest = dispatchRequest;
|
|
434819
|
+
exports.buildUrl = buildUrl;
|
|
434820
|
+
var retry_1 = require_retry();
|
|
434821
|
+
var runtime_1 = require_runtime3();
|
|
434822
|
+
var utils_1 = require_utils4();
|
|
434823
|
+
var isCloudflareWorkers = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === "Cloudflare-Workers";
|
|
434824
|
+
function dispatchRequest(params) {
|
|
434825
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434826
|
+
var _a7;
|
|
434827
|
+
const { targetUrl, input: input3, config: config4, options = {} } = params;
|
|
434828
|
+
const { credentials: credentialsValue, requestMiddleware, responseHandler, fetch: fetch3 } = config4;
|
|
434829
|
+
const retryOptions = Object.assign(Object.assign({}, config4.retry), options.retry || {});
|
|
434830
|
+
const executeRequest = () => __awaiter4(this, void 0, void 0, function* () {
|
|
434831
|
+
var _a8, _b3, _c3;
|
|
434832
|
+
const userAgent = (0, runtime_1.isBrowser)() ? {} : { "User-Agent": (0, runtime_1.getUserAgent)() };
|
|
434833
|
+
const credentials = typeof credentialsValue === "function" ? credentialsValue() : credentialsValue;
|
|
434834
|
+
const { method, url, headers } = yield requestMiddleware({
|
|
434835
|
+
method: ((_b3 = (_a8 = params.method) !== null && _a8 !== void 0 ? _a8 : options.method) !== null && _b3 !== void 0 ? _b3 : "post").toUpperCase(),
|
|
434836
|
+
url: targetUrl,
|
|
434837
|
+
headers: params.headers
|
|
434838
|
+
});
|
|
434839
|
+
const authHeader = credentials ? { Authorization: `Key ${credentials}` } : {};
|
|
434840
|
+
const requestHeaders = Object.assign(Object.assign(Object.assign(Object.assign({}, authHeader), { Accept: "application/json", "Content-Type": "application/json" }), userAgent), headers !== null && headers !== void 0 ? headers : {});
|
|
434841
|
+
const { responseHandler: customResponseHandler, retry: _ } = options, requestInit = __rest3(options, ["responseHandler", "retry"]);
|
|
434842
|
+
const response = yield fetch3(url, Object.assign(Object.assign(Object.assign(Object.assign({}, requestInit), { method, headers: Object.assign(Object.assign({}, requestHeaders), (_c3 = requestInit.headers) !== null && _c3 !== void 0 ? _c3 : {}) }), !isCloudflareWorkers && { mode: "cors" }), { signal: options.signal, body: method.toLowerCase() !== "get" && input3 ? JSON.stringify(input3) : void 0 }));
|
|
434843
|
+
const handleResponse = customResponseHandler !== null && customResponseHandler !== void 0 ? customResponseHandler : responseHandler;
|
|
434844
|
+
return yield handleResponse(response);
|
|
434845
|
+
});
|
|
434846
|
+
let lastError;
|
|
434847
|
+
for (let attempt = 0; attempt <= retryOptions.maxRetries; attempt++) {
|
|
434848
|
+
try {
|
|
434849
|
+
return yield executeRequest();
|
|
434850
|
+
} catch (error) {
|
|
434851
|
+
lastError = error;
|
|
434852
|
+
const shouldNotRetry = attempt === retryOptions.maxRetries || !(0, retry_1.isRetryableError)(error, retryOptions.retryableStatusCodes) || ((_a7 = options.signal) === null || _a7 === void 0 ? void 0 : _a7.aborted);
|
|
434853
|
+
if (shouldNotRetry) {
|
|
434854
|
+
throw error;
|
|
434855
|
+
}
|
|
434856
|
+
const delay = (0, retry_1.calculateBackoffDelay)(attempt, retryOptions.baseDelay, retryOptions.maxDelay, retryOptions.backoffMultiplier, retryOptions.enableJitter);
|
|
434857
|
+
yield (0, utils_1.sleep)(delay);
|
|
434858
|
+
}
|
|
434859
|
+
}
|
|
434860
|
+
throw lastError;
|
|
434861
|
+
});
|
|
434862
|
+
}
|
|
434863
|
+
function buildUrl(id, options = {}) {
|
|
434864
|
+
var _a7, _b3;
|
|
434865
|
+
const method = ((_a7 = options.method) !== null && _a7 !== void 0 ? _a7 : "post").toLowerCase();
|
|
434866
|
+
const path14 = ((_b3 = options.path) !== null && _b3 !== void 0 ? _b3 : "").replace(/^\//, "").replace(/\/{2,}/, "/");
|
|
434867
|
+
const input3 = options.input;
|
|
434868
|
+
const params = Object.assign(Object.assign({}, options.query || {}), method === "get" ? input3 : {});
|
|
434869
|
+
const queryParams = Object.keys(params).length > 0 ? `?${new URLSearchParams(params).toString()}` : "";
|
|
434870
|
+
if ((0, utils_1.isValidUrl)(id)) {
|
|
434871
|
+
const url2 = id.endsWith("/") ? id : `${id}/`;
|
|
434872
|
+
return `${url2}${path14}${queryParams}`;
|
|
434873
|
+
}
|
|
434874
|
+
const appId = (0, utils_1.ensureEndpointIdFormat)(id);
|
|
434875
|
+
const subdomain = options.subdomain ? `${options.subdomain}.` : "";
|
|
434876
|
+
const url = `https://${subdomain}fal.run/${appId}/${path14}`;
|
|
434877
|
+
return `${url.replace(/\/$/, "")}${queryParams}`;
|
|
434878
|
+
}
|
|
434879
|
+
}
|
|
434880
|
+
});
|
|
434881
|
+
|
|
434882
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/storage.js
|
|
434883
|
+
var require_storage = __commonJS({
|
|
434884
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/storage.js"(exports) {
|
|
434885
|
+
"use strict";
|
|
434886
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
434887
|
+
function adopt(value) {
|
|
434888
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
434889
|
+
resolve44(value);
|
|
434890
|
+
});
|
|
434891
|
+
}
|
|
434892
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
434893
|
+
function fulfilled(value) {
|
|
434894
|
+
try {
|
|
434895
|
+
step(generator.next(value));
|
|
434896
|
+
} catch (e) {
|
|
434897
|
+
reject(e);
|
|
434898
|
+
}
|
|
434899
|
+
}
|
|
434900
|
+
function rejected(value) {
|
|
434901
|
+
try {
|
|
434902
|
+
step(generator["throw"](value));
|
|
434903
|
+
} catch (e) {
|
|
434904
|
+
reject(e);
|
|
434905
|
+
}
|
|
434906
|
+
}
|
|
434907
|
+
function step(result) {
|
|
434908
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
434909
|
+
}
|
|
434910
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
434911
|
+
});
|
|
434912
|
+
};
|
|
434913
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
434914
|
+
exports.OBJECT_LIFECYCYLE_PREFERENCE_HEADER = void 0;
|
|
434915
|
+
exports.getExpirationDurationSeconds = getExpirationDurationSeconds;
|
|
434916
|
+
exports.buildObjectLifecycleHeaders = buildObjectLifecycleHeaders;
|
|
434917
|
+
exports.createStorageClient = createStorageClient;
|
|
434918
|
+
var config_1 = require_config();
|
|
434919
|
+
var request_1 = require_request();
|
|
434920
|
+
var utils_1 = require_utils4();
|
|
434921
|
+
exports.OBJECT_LIFECYCYLE_PREFERENCE_HEADER = "x-fal-object-lifecycle-preference";
|
|
434922
|
+
var EXPIRATION_VALUES = {
|
|
434923
|
+
never: void 0,
|
|
434924
|
+
immediate: 60,
|
|
434925
|
+
"1h": 3600,
|
|
434926
|
+
"1d": 86400,
|
|
434927
|
+
"7d": 604800,
|
|
434928
|
+
"30d": 2592e3,
|
|
434929
|
+
"1y": 31536e3
|
|
434930
|
+
};
|
|
434931
|
+
function getExpirationDurationSeconds(lifecycle) {
|
|
434932
|
+
const { expiresIn } = lifecycle;
|
|
434933
|
+
if (expiresIn === void 0) {
|
|
434934
|
+
return void 0;
|
|
434935
|
+
}
|
|
434936
|
+
return typeof expiresIn === "number" ? expiresIn : EXPIRATION_VALUES[expiresIn];
|
|
434937
|
+
}
|
|
434938
|
+
function buildUploadLifecycleConfig(lifecycle) {
|
|
434939
|
+
if (!lifecycle) {
|
|
434940
|
+
return void 0;
|
|
434941
|
+
}
|
|
434942
|
+
const expirationDurationSeconds = getExpirationDurationSeconds(lifecycle);
|
|
434943
|
+
const lifecycleConfig = {};
|
|
434944
|
+
if (expirationDurationSeconds !== void 0) {
|
|
434945
|
+
lifecycleConfig.expiration_duration_seconds = expirationDurationSeconds;
|
|
434946
|
+
}
|
|
434947
|
+
if (lifecycle.initialAcl !== void 0) {
|
|
434948
|
+
lifecycleConfig.initial_acl = lifecycle.initialAcl;
|
|
434949
|
+
}
|
|
434950
|
+
return Object.keys(lifecycleConfig).length > 0 ? lifecycleConfig : void 0;
|
|
434951
|
+
}
|
|
434952
|
+
function buildObjectLifecycleHeaders(lifecycle) {
|
|
434953
|
+
const lifecycleConfig = buildUploadLifecycleConfig(lifecycle);
|
|
434954
|
+
if (!lifecycleConfig) {
|
|
434955
|
+
return {};
|
|
434956
|
+
}
|
|
434957
|
+
return {
|
|
434958
|
+
[exports.OBJECT_LIFECYCYLE_PREFERENCE_HEADER]: JSON.stringify(lifecycleConfig)
|
|
434959
|
+
};
|
|
434960
|
+
}
|
|
434961
|
+
function getExtensionFromContentType(contentType) {
|
|
434962
|
+
var _a7;
|
|
434963
|
+
const [, fileType] = contentType.split("/");
|
|
434964
|
+
return (_a7 = fileType.split(/[-;]/)[0]) !== null && _a7 !== void 0 ? _a7 : "bin";
|
|
434965
|
+
}
|
|
434966
|
+
function initiateUpload(file, config4, contentType, lifecycle) {
|
|
434967
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434968
|
+
const filename = file.name || `${Date.now()}.${getExtensionFromContentType(contentType)}`;
|
|
434969
|
+
const headers = {};
|
|
434970
|
+
const lifecycleConfig = buildUploadLifecycleConfig(lifecycle);
|
|
434971
|
+
if (lifecycleConfig) {
|
|
434972
|
+
headers["X-Fal-Object-Lifecycle"] = JSON.stringify(lifecycleConfig);
|
|
434973
|
+
}
|
|
434974
|
+
return yield (0, request_1.dispatchRequest)({
|
|
434975
|
+
method: "POST",
|
|
434976
|
+
// NOTE: We want to test V3 without making it the default at the API level
|
|
434977
|
+
targetUrl: `${(0, config_1.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,
|
|
434978
|
+
input: {
|
|
434979
|
+
content_type: contentType,
|
|
434980
|
+
file_name: filename
|
|
434981
|
+
},
|
|
434982
|
+
config: config4,
|
|
434983
|
+
headers
|
|
434984
|
+
});
|
|
434985
|
+
});
|
|
434986
|
+
}
|
|
434987
|
+
function initiateMultipartUpload(file, config4, contentType, lifecycle) {
|
|
434988
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
434989
|
+
const filename = file.name || `${Date.now()}.${getExtensionFromContentType(contentType)}`;
|
|
434990
|
+
const headers = {};
|
|
434991
|
+
const lifecycleConfig = buildUploadLifecycleConfig(lifecycle);
|
|
434992
|
+
if (lifecycleConfig) {
|
|
434993
|
+
headers["X-Fal-Object-Lifecycle"] = JSON.stringify(lifecycleConfig);
|
|
434994
|
+
}
|
|
434995
|
+
return yield (0, request_1.dispatchRequest)({
|
|
434996
|
+
method: "POST",
|
|
434997
|
+
targetUrl: `${(0, config_1.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,
|
|
434998
|
+
input: {
|
|
434999
|
+
content_type: contentType,
|
|
435000
|
+
file_name: filename
|
|
435001
|
+
},
|
|
435002
|
+
config: config4,
|
|
435003
|
+
headers
|
|
435004
|
+
});
|
|
435005
|
+
});
|
|
435006
|
+
}
|
|
435007
|
+
function partUploadRetries(uploadUrl_1, chunk_1, config_2) {
|
|
435008
|
+
return __awaiter4(this, arguments, void 0, function* (uploadUrl, chunk, config4, tries = 3) {
|
|
435009
|
+
if (tries === 0) {
|
|
435010
|
+
throw new Error("Part upload failed, retries exhausted");
|
|
435011
|
+
}
|
|
435012
|
+
const { fetch: fetch3, responseHandler } = config4;
|
|
435013
|
+
try {
|
|
435014
|
+
const response = yield fetch3(uploadUrl, {
|
|
435015
|
+
method: "PUT",
|
|
435016
|
+
body: chunk
|
|
435017
|
+
});
|
|
435018
|
+
return yield responseHandler(response);
|
|
435019
|
+
} catch (error) {
|
|
435020
|
+
return yield partUploadRetries(uploadUrl, chunk, config4, tries - 1);
|
|
435021
|
+
}
|
|
435022
|
+
});
|
|
435023
|
+
}
|
|
435024
|
+
function multipartUpload(file, config4, lifecycle) {
|
|
435025
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
435026
|
+
const { fetch: fetch3, responseHandler } = config4;
|
|
435027
|
+
const contentType = file.type || "application/octet-stream";
|
|
435028
|
+
const { upload_url: uploadUrl, file_url: url } = yield initiateMultipartUpload(file, config4, contentType, lifecycle);
|
|
435029
|
+
const chunkSize = 10 * 1024 * 1024;
|
|
435030
|
+
const chunks = Math.ceil(file.size / chunkSize);
|
|
435031
|
+
const parsedUrl = new URL(uploadUrl);
|
|
435032
|
+
const responses = [];
|
|
435033
|
+
for (let i = 0; i < chunks; i++) {
|
|
435034
|
+
const start = i * chunkSize;
|
|
435035
|
+
const end = Math.min(start + chunkSize, file.size);
|
|
435036
|
+
const chunk = file.slice(start, end);
|
|
435037
|
+
const partNumber = i + 1;
|
|
435038
|
+
const partUploadUrl = `${parsedUrl.origin}${parsedUrl.pathname}/${partNumber}${parsedUrl.search}`;
|
|
435039
|
+
responses.push(yield partUploadRetries(partUploadUrl, chunk, config4));
|
|
435040
|
+
}
|
|
435041
|
+
const completeUrl = `${parsedUrl.origin}${parsedUrl.pathname}/complete${parsedUrl.search}`;
|
|
435042
|
+
const response = yield fetch3(completeUrl, {
|
|
435043
|
+
method: "POST",
|
|
435044
|
+
headers: {
|
|
435045
|
+
"Content-Type": "application/json"
|
|
435046
|
+
},
|
|
435047
|
+
body: JSON.stringify({
|
|
435048
|
+
parts: responses.map((mpart) => ({
|
|
435049
|
+
partNumber: mpart.partNumber,
|
|
435050
|
+
etag: mpart.etag
|
|
435051
|
+
}))
|
|
435052
|
+
})
|
|
435053
|
+
});
|
|
435054
|
+
yield responseHandler(response);
|
|
435055
|
+
return url;
|
|
435056
|
+
});
|
|
435057
|
+
}
|
|
435058
|
+
function createStorageClient({ config: config4 }) {
|
|
435059
|
+
const ref = {
|
|
435060
|
+
upload: (file, options) => __awaiter4(this, void 0, void 0, function* () {
|
|
435061
|
+
const lifecycle = options === null || options === void 0 ? void 0 : options.lifecycle;
|
|
435062
|
+
if (file.size > 90 * 1024 * 1024) {
|
|
435063
|
+
return yield multipartUpload(file, config4, lifecycle);
|
|
435064
|
+
}
|
|
435065
|
+
const contentType = file.type || "application/octet-stream";
|
|
435066
|
+
const { fetch: fetch3, responseHandler } = config4;
|
|
435067
|
+
const { upload_url: uploadUrl, file_url: url } = yield initiateUpload(file, config4, contentType, lifecycle);
|
|
435068
|
+
const response = yield fetch3(uploadUrl, {
|
|
435069
|
+
method: "PUT",
|
|
435070
|
+
body: file,
|
|
435071
|
+
headers: {
|
|
435072
|
+
"Content-Type": file.type || "application/octet-stream"
|
|
435073
|
+
}
|
|
435074
|
+
});
|
|
435075
|
+
yield responseHandler(response);
|
|
435076
|
+
return url;
|
|
435077
|
+
}),
|
|
435078
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
435079
|
+
transformInput: (input3) => __awaiter4(this, void 0, void 0, function* () {
|
|
435080
|
+
if (Array.isArray(input3)) {
|
|
435081
|
+
return Promise.all(input3.map((item) => ref.transformInput(item)));
|
|
435082
|
+
} else if (input3 instanceof Blob) {
|
|
435083
|
+
return yield ref.upload(input3);
|
|
435084
|
+
} else if ((0, utils_1.isPlainObject)(input3)) {
|
|
435085
|
+
const inputObject = input3;
|
|
435086
|
+
const promises = Object.entries(inputObject).map((_a7) => __awaiter4(this, [_a7], void 0, function* ([key2, value]) {
|
|
435087
|
+
return [key2, yield ref.transformInput(value)];
|
|
435088
|
+
}));
|
|
435089
|
+
const results = yield Promise.all(promises);
|
|
435090
|
+
return Object.fromEntries(results);
|
|
435091
|
+
}
|
|
435092
|
+
return input3;
|
|
435093
|
+
})
|
|
435094
|
+
};
|
|
435095
|
+
return ref;
|
|
435096
|
+
}
|
|
435097
|
+
}
|
|
435098
|
+
});
|
|
435099
|
+
|
|
435100
|
+
// ../../node_modules/.pnpm/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/index.cjs
|
|
435101
|
+
var require_dist14 = __commonJS({
|
|
435102
|
+
"../../node_modules/.pnpm/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/index.cjs"(exports) {
|
|
435103
|
+
"use strict";
|
|
435104
|
+
Object.defineProperty(exports, "__esModule", {
|
|
435105
|
+
value: true
|
|
435106
|
+
});
|
|
435107
|
+
function createParser(onParse) {
|
|
435108
|
+
let isFirstChunk;
|
|
435109
|
+
let buffer;
|
|
435110
|
+
let startingPosition;
|
|
435111
|
+
let startingFieldLength;
|
|
435112
|
+
let eventId;
|
|
435113
|
+
let eventName;
|
|
435114
|
+
let data;
|
|
435115
|
+
reset();
|
|
435116
|
+
return {
|
|
435117
|
+
feed,
|
|
435118
|
+
reset
|
|
435119
|
+
};
|
|
435120
|
+
function reset() {
|
|
435121
|
+
isFirstChunk = true;
|
|
435122
|
+
buffer = "";
|
|
435123
|
+
startingPosition = 0;
|
|
435124
|
+
startingFieldLength = -1;
|
|
435125
|
+
eventId = void 0;
|
|
435126
|
+
eventName = void 0;
|
|
435127
|
+
data = "";
|
|
435128
|
+
}
|
|
435129
|
+
function feed(chunk) {
|
|
435130
|
+
buffer = buffer ? buffer + chunk : chunk;
|
|
435131
|
+
if (isFirstChunk && hasBom(buffer)) {
|
|
435132
|
+
buffer = buffer.slice(BOM.length);
|
|
435133
|
+
}
|
|
435134
|
+
isFirstChunk = false;
|
|
435135
|
+
const length = buffer.length;
|
|
435136
|
+
let position = 0;
|
|
435137
|
+
let discardTrailingNewline = false;
|
|
435138
|
+
while (position < length) {
|
|
435139
|
+
if (discardTrailingNewline) {
|
|
435140
|
+
if (buffer[position] === "\n") {
|
|
435141
|
+
++position;
|
|
435142
|
+
}
|
|
435143
|
+
discardTrailingNewline = false;
|
|
435144
|
+
}
|
|
435145
|
+
let lineLength = -1;
|
|
435146
|
+
let fieldLength = startingFieldLength;
|
|
435147
|
+
let character;
|
|
435148
|
+
for (let index = startingPosition; lineLength < 0 && index < length; ++index) {
|
|
435149
|
+
character = buffer[index];
|
|
435150
|
+
if (character === ":" && fieldLength < 0) {
|
|
435151
|
+
fieldLength = index - position;
|
|
435152
|
+
} else if (character === "\r") {
|
|
435153
|
+
discardTrailingNewline = true;
|
|
435154
|
+
lineLength = index - position;
|
|
435155
|
+
} else if (character === "\n") {
|
|
435156
|
+
lineLength = index - position;
|
|
435157
|
+
}
|
|
435158
|
+
}
|
|
435159
|
+
if (lineLength < 0) {
|
|
435160
|
+
startingPosition = length - position;
|
|
435161
|
+
startingFieldLength = fieldLength;
|
|
435162
|
+
break;
|
|
435163
|
+
} else {
|
|
435164
|
+
startingPosition = 0;
|
|
435165
|
+
startingFieldLength = -1;
|
|
435166
|
+
}
|
|
435167
|
+
parseEventStreamLine(buffer, position, fieldLength, lineLength);
|
|
435168
|
+
position += lineLength + 1;
|
|
435169
|
+
}
|
|
435170
|
+
if (position === length) {
|
|
435171
|
+
buffer = "";
|
|
435172
|
+
} else if (position > 0) {
|
|
435173
|
+
buffer = buffer.slice(position);
|
|
435174
|
+
}
|
|
435175
|
+
}
|
|
435176
|
+
function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
|
|
435177
|
+
if (lineLength === 0) {
|
|
435178
|
+
if (data.length > 0) {
|
|
435179
|
+
onParse({
|
|
435180
|
+
type: "event",
|
|
435181
|
+
id: eventId,
|
|
435182
|
+
event: eventName || void 0,
|
|
435183
|
+
data: data.slice(0, -1)
|
|
435184
|
+
// remove trailing newline
|
|
435185
|
+
});
|
|
435186
|
+
data = "";
|
|
435187
|
+
eventId = void 0;
|
|
435188
|
+
}
|
|
435189
|
+
eventName = void 0;
|
|
435190
|
+
return;
|
|
435191
|
+
}
|
|
435192
|
+
const noValue = fieldLength < 0;
|
|
435193
|
+
const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
|
|
435194
|
+
let step = 0;
|
|
435195
|
+
if (noValue) {
|
|
435196
|
+
step = lineLength;
|
|
435197
|
+
} else if (lineBuffer[index + fieldLength + 1] === " ") {
|
|
435198
|
+
step = fieldLength + 2;
|
|
435199
|
+
} else {
|
|
435200
|
+
step = fieldLength + 1;
|
|
435201
|
+
}
|
|
435202
|
+
const position = index + step;
|
|
435203
|
+
const valueLength = lineLength - step;
|
|
435204
|
+
const value = lineBuffer.slice(position, position + valueLength).toString();
|
|
435205
|
+
if (field === "data") {
|
|
435206
|
+
data += value ? "".concat(value, "\n") : "\n";
|
|
435207
|
+
} else if (field === "event") {
|
|
435208
|
+
eventName = value;
|
|
435209
|
+
} else if (field === "id" && !value.includes("\0")) {
|
|
435210
|
+
eventId = value;
|
|
435211
|
+
} else if (field === "retry") {
|
|
435212
|
+
const retry3 = parseInt(value, 10);
|
|
435213
|
+
if (!Number.isNaN(retry3)) {
|
|
435214
|
+
onParse({
|
|
435215
|
+
type: "reconnect-interval",
|
|
435216
|
+
value: retry3
|
|
435217
|
+
});
|
|
435218
|
+
}
|
|
435219
|
+
}
|
|
435220
|
+
}
|
|
435221
|
+
}
|
|
435222
|
+
var BOM = [239, 187, 191];
|
|
435223
|
+
function hasBom(buffer) {
|
|
435224
|
+
return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
|
|
435225
|
+
}
|
|
435226
|
+
exports.createParser = createParser;
|
|
435227
|
+
}
|
|
435228
|
+
});
|
|
435229
|
+
|
|
435230
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/auth.js
|
|
435231
|
+
var require_auth = __commonJS({
|
|
435232
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/auth.js"(exports) {
|
|
435233
|
+
"use strict";
|
|
435234
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
435235
|
+
function adopt(value) {
|
|
435236
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
435237
|
+
resolve44(value);
|
|
435238
|
+
});
|
|
435239
|
+
}
|
|
435240
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
435241
|
+
function fulfilled(value) {
|
|
435242
|
+
try {
|
|
435243
|
+
step(generator.next(value));
|
|
435244
|
+
} catch (e) {
|
|
435245
|
+
reject(e);
|
|
435246
|
+
}
|
|
435247
|
+
}
|
|
435248
|
+
function rejected(value) {
|
|
435249
|
+
try {
|
|
435250
|
+
step(generator["throw"](value));
|
|
435251
|
+
} catch (e) {
|
|
435252
|
+
reject(e);
|
|
435253
|
+
}
|
|
435254
|
+
}
|
|
435255
|
+
function step(result) {
|
|
435256
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
435257
|
+
}
|
|
435258
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
435259
|
+
});
|
|
435260
|
+
};
|
|
435261
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
435262
|
+
exports.TOKEN_EXPIRATION_SECONDS = void 0;
|
|
435263
|
+
exports.getTemporaryAuthToken = getTemporaryAuthToken;
|
|
435264
|
+
var config_1 = require_config();
|
|
435265
|
+
var request_1 = require_request();
|
|
435266
|
+
var utils_1 = require_utils4();
|
|
435267
|
+
exports.TOKEN_EXPIRATION_SECONDS = 120;
|
|
435268
|
+
function getTemporaryAuthToken(app, config4) {
|
|
435269
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
435270
|
+
const appId = (0, utils_1.parseEndpointId)(app);
|
|
435271
|
+
const token = yield (0, request_1.dispatchRequest)({
|
|
435272
|
+
method: "POST",
|
|
435273
|
+
targetUrl: `${(0, config_1.getRestApiUrl)()}/tokens/`,
|
|
435274
|
+
config: config4,
|
|
435275
|
+
input: {
|
|
435276
|
+
allowed_apps: [appId.alias],
|
|
435277
|
+
token_expiration: exports.TOKEN_EXPIRATION_SECONDS
|
|
435278
|
+
}
|
|
435279
|
+
});
|
|
435280
|
+
if (typeof token !== "string" && token["detail"]) {
|
|
435281
|
+
return token["detail"];
|
|
435282
|
+
}
|
|
435283
|
+
return token;
|
|
435284
|
+
});
|
|
435285
|
+
}
|
|
435286
|
+
}
|
|
435287
|
+
});
|
|
435288
|
+
|
|
435289
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/streaming.js
|
|
435290
|
+
var require_streaming = __commonJS({
|
|
435291
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/streaming.js"(exports) {
|
|
435292
|
+
"use strict";
|
|
435293
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
435294
|
+
function adopt(value) {
|
|
435295
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
435296
|
+
resolve44(value);
|
|
435297
|
+
});
|
|
435298
|
+
}
|
|
435299
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
435300
|
+
function fulfilled(value) {
|
|
435301
|
+
try {
|
|
435302
|
+
step(generator.next(value));
|
|
435303
|
+
} catch (e) {
|
|
435304
|
+
reject(e);
|
|
435305
|
+
}
|
|
435306
|
+
}
|
|
435307
|
+
function rejected(value) {
|
|
435308
|
+
try {
|
|
435309
|
+
step(generator["throw"](value));
|
|
435310
|
+
} catch (e) {
|
|
435311
|
+
reject(e);
|
|
435312
|
+
}
|
|
435313
|
+
}
|
|
435314
|
+
function step(result) {
|
|
435315
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
435316
|
+
}
|
|
435317
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
435318
|
+
});
|
|
435319
|
+
};
|
|
435320
|
+
var __await4 = exports && exports.__await || function(v) {
|
|
435321
|
+
return this instanceof __await4 ? (this.v = v, this) : new __await4(v);
|
|
435322
|
+
};
|
|
435323
|
+
var __asyncGenerator4 = exports && exports.__asyncGenerator || function(thisArg, _arguments, generator) {
|
|
435324
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
435325
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
435326
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
|
|
435327
|
+
return this;
|
|
435328
|
+
}, i;
|
|
435329
|
+
function awaitReturn(f) {
|
|
435330
|
+
return function(v) {
|
|
435331
|
+
return Promise.resolve(v).then(f, reject);
|
|
435332
|
+
};
|
|
435333
|
+
}
|
|
435334
|
+
function verb(n, f) {
|
|
435335
|
+
if (g[n]) {
|
|
435336
|
+
i[n] = function(v) {
|
|
435337
|
+
return new Promise(function(a, b) {
|
|
435338
|
+
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
435339
|
+
});
|
|
435340
|
+
};
|
|
435341
|
+
if (f) i[n] = f(i[n]);
|
|
435342
|
+
}
|
|
435343
|
+
}
|
|
435344
|
+
function resume(n, v) {
|
|
435345
|
+
try {
|
|
435346
|
+
step(g[n](v));
|
|
435347
|
+
} catch (e) {
|
|
435348
|
+
settle(q[0][3], e);
|
|
435349
|
+
}
|
|
435350
|
+
}
|
|
435351
|
+
function step(r) {
|
|
435352
|
+
r.value instanceof __await4 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
435353
|
+
}
|
|
435354
|
+
function fulfill(value) {
|
|
435355
|
+
resume("next", value);
|
|
435356
|
+
}
|
|
435357
|
+
function reject(value) {
|
|
435358
|
+
resume("throw", value);
|
|
435359
|
+
}
|
|
435360
|
+
function settle(f, v) {
|
|
435361
|
+
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
|
|
435362
|
+
}
|
|
435363
|
+
};
|
|
435364
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
435365
|
+
exports.FalStream = void 0;
|
|
435366
|
+
exports.createStreamingClient = createStreamingClient;
|
|
435367
|
+
var eventsource_parser_1 = require_dist14();
|
|
435368
|
+
var auth_1 = require_auth();
|
|
435369
|
+
var request_1 = require_request();
|
|
435370
|
+
var response_1 = require_response();
|
|
435371
|
+
var utils_1 = require_utils4();
|
|
435372
|
+
var CONTENT_TYPE_EVENT_STREAM = "text/event-stream";
|
|
435373
|
+
var EVENT_STREAM_TIMEOUT = 15 * 1e3;
|
|
435374
|
+
var FalStream = class {
|
|
435375
|
+
constructor(endpointId, config4, options) {
|
|
435376
|
+
var _a7;
|
|
435377
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
435378
|
+
this.buffer = [];
|
|
435379
|
+
this.currentData = void 0;
|
|
435380
|
+
this.lastEventTimestamp = 0;
|
|
435381
|
+
this.streamClosed = false;
|
|
435382
|
+
this._requestId = null;
|
|
435383
|
+
this.abortController = new AbortController();
|
|
435384
|
+
this.start = () => __awaiter4(this, void 0, void 0, function* () {
|
|
435385
|
+
var _a8, _b3, _c3;
|
|
435386
|
+
const { endpointId: endpointId2, options: options2 } = this;
|
|
435387
|
+
const { input: input3, method = "post", connectionMode = "server", tokenProvider } = options2;
|
|
435388
|
+
try {
|
|
435389
|
+
if (connectionMode === "client") {
|
|
435390
|
+
const appId = (0, utils_1.ensureEndpointIdFormat)(endpointId2);
|
|
435391
|
+
const resolvedPath = (_a8 = (0, utils_1.resolveEndpointPath)(endpointId2, void 0, "/stream")) !== null && _a8 !== void 0 ? _a8 : "";
|
|
435392
|
+
const fetchToken = tokenProvider ? () => tokenProvider(`${appId}${resolvedPath}`) : () => {
|
|
435393
|
+
console.warn('[fal.stream] Using the default token provider is deprecated. Please provide a `tokenProvider` function when using `connectionMode: "client"`. See https://docs.fal.ai/fal-client/authentication for more information.');
|
|
435394
|
+
return (0, auth_1.getTemporaryAuthToken)(endpointId2, this.config);
|
|
435395
|
+
};
|
|
435396
|
+
const token = yield fetchToken();
|
|
435397
|
+
const { fetch: fetch3 } = this.config;
|
|
435398
|
+
const parsedUrl = new URL(this.url);
|
|
435399
|
+
parsedUrl.searchParams.set("fal_jwt_token", token);
|
|
435400
|
+
const response = yield fetch3(parsedUrl.toString(), {
|
|
435401
|
+
method: method.toUpperCase(),
|
|
435402
|
+
headers: {
|
|
435403
|
+
accept: (_b3 = options2.accept) !== null && _b3 !== void 0 ? _b3 : CONTENT_TYPE_EVENT_STREAM,
|
|
435404
|
+
"content-type": "application/json"
|
|
435405
|
+
},
|
|
435406
|
+
body: input3 && method !== "get" ? JSON.stringify(input3) : void 0,
|
|
435407
|
+
signal: this.abortController.signal
|
|
435408
|
+
});
|
|
435409
|
+
this._requestId = response.headers.get("x-fal-request-id");
|
|
435410
|
+
return yield this.handleResponse(response);
|
|
435411
|
+
}
|
|
435412
|
+
return yield (0, request_1.dispatchRequest)({
|
|
435413
|
+
method: method.toUpperCase(),
|
|
435414
|
+
targetUrl: this.url,
|
|
435415
|
+
input: input3,
|
|
435416
|
+
config: this.config,
|
|
435417
|
+
options: {
|
|
435418
|
+
headers: {
|
|
435419
|
+
accept: (_c3 = options2.accept) !== null && _c3 !== void 0 ? _c3 : CONTENT_TYPE_EVENT_STREAM
|
|
435420
|
+
},
|
|
435421
|
+
responseHandler: (response) => __awaiter4(this, void 0, void 0, function* () {
|
|
435422
|
+
this._requestId = response.headers.get("x-fal-request-id");
|
|
435423
|
+
return yield this.handleResponse(response);
|
|
435424
|
+
}),
|
|
435425
|
+
signal: this.abortController.signal
|
|
435426
|
+
}
|
|
435427
|
+
});
|
|
435428
|
+
} catch (error) {
|
|
435429
|
+
this.handleError(error);
|
|
435430
|
+
}
|
|
435431
|
+
});
|
|
435432
|
+
this.handleResponse = (response) => __awaiter4(this, void 0, void 0, function* () {
|
|
435433
|
+
var _a8, _b3;
|
|
435434
|
+
if (!response.ok) {
|
|
435435
|
+
try {
|
|
435436
|
+
yield (0, response_1.defaultResponseHandler)(response);
|
|
435437
|
+
} catch (error) {
|
|
435438
|
+
this.emit("error", error);
|
|
435439
|
+
}
|
|
435440
|
+
return;
|
|
435441
|
+
}
|
|
435442
|
+
const body = response.body;
|
|
435443
|
+
if (!body) {
|
|
435444
|
+
this.emit("error", new response_1.ApiError({
|
|
435445
|
+
message: "Response body is empty.",
|
|
435446
|
+
status: 400,
|
|
435447
|
+
body: void 0,
|
|
435448
|
+
requestId: this._requestId || void 0
|
|
435449
|
+
}));
|
|
435450
|
+
return;
|
|
435451
|
+
}
|
|
435452
|
+
const isEventStream = ((_a8 = response.headers.get("content-type")) !== null && _a8 !== void 0 ? _a8 : "").startsWith(CONTENT_TYPE_EVENT_STREAM);
|
|
435453
|
+
if (!isEventStream) {
|
|
435454
|
+
const reader2 = body.getReader();
|
|
435455
|
+
const emitRawChunk = () => {
|
|
435456
|
+
reader2.read().then(({ done, value }) => {
|
|
435457
|
+
if (done) {
|
|
435458
|
+
this.emit("done", this.currentData);
|
|
435459
|
+
return;
|
|
435460
|
+
}
|
|
435461
|
+
this.buffer.push(value);
|
|
435462
|
+
this.currentData = value;
|
|
435463
|
+
this.emit("data", value);
|
|
435464
|
+
emitRawChunk();
|
|
435465
|
+
});
|
|
435466
|
+
};
|
|
435467
|
+
emitRawChunk();
|
|
435468
|
+
return;
|
|
435469
|
+
}
|
|
435470
|
+
const decoder2 = new TextDecoder("utf-8");
|
|
435471
|
+
const reader = response.body.getReader();
|
|
435472
|
+
const parser3 = (0, eventsource_parser_1.createParser)((event) => {
|
|
435473
|
+
if (event.type === "event") {
|
|
435474
|
+
const data = event.data;
|
|
435475
|
+
try {
|
|
435476
|
+
const parsedData = JSON.parse(data);
|
|
435477
|
+
this.buffer.push(parsedData);
|
|
435478
|
+
this.currentData = parsedData;
|
|
435479
|
+
this.emit("data", parsedData);
|
|
435480
|
+
this.emit("message", parsedData);
|
|
435481
|
+
} catch (e) {
|
|
435482
|
+
this.emit("error", e);
|
|
435483
|
+
}
|
|
435484
|
+
}
|
|
435485
|
+
});
|
|
435486
|
+
const timeout3 = (_b3 = this.options.timeout) !== null && _b3 !== void 0 ? _b3 : EVENT_STREAM_TIMEOUT;
|
|
435487
|
+
const readPartialResponse = () => __awaiter4(this, void 0, void 0, function* () {
|
|
435488
|
+
const { value, done } = yield reader.read();
|
|
435489
|
+
this.lastEventTimestamp = Date.now();
|
|
435490
|
+
parser3.feed(decoder2.decode(value));
|
|
435491
|
+
if (Date.now() - this.lastEventTimestamp > timeout3) {
|
|
435492
|
+
this.emit("error", new response_1.ApiError({
|
|
435493
|
+
message: `Event stream timed out after ${(timeout3 / 1e3).toFixed(0)} seconds with no messages.`,
|
|
435494
|
+
status: 408,
|
|
435495
|
+
requestId: this._requestId || void 0
|
|
435496
|
+
}));
|
|
435497
|
+
}
|
|
435498
|
+
if (!done) {
|
|
435499
|
+
readPartialResponse().catch(this.handleError);
|
|
435500
|
+
} else {
|
|
435501
|
+
this.emit("done", this.currentData);
|
|
435502
|
+
}
|
|
435503
|
+
});
|
|
435504
|
+
readPartialResponse().catch(this.handleError);
|
|
435505
|
+
return;
|
|
435506
|
+
});
|
|
435507
|
+
this.handleError = (error) => {
|
|
435508
|
+
var _a8;
|
|
435509
|
+
if (error.name === "AbortError" || this.signal.aborted) {
|
|
435510
|
+
return;
|
|
435511
|
+
}
|
|
435512
|
+
const apiError2 = error instanceof response_1.ApiError ? error : new response_1.ApiError({
|
|
435513
|
+
message: (_a8 = error.message) !== null && _a8 !== void 0 ? _a8 : "An unknown error occurred",
|
|
435514
|
+
status: 500,
|
|
435515
|
+
requestId: this._requestId || void 0
|
|
435516
|
+
});
|
|
435517
|
+
this.emit("error", apiError2);
|
|
435518
|
+
return;
|
|
435519
|
+
};
|
|
435520
|
+
this.on = (type, listener) => {
|
|
435521
|
+
var _a8;
|
|
435522
|
+
if (!this.listeners.has(type)) {
|
|
435523
|
+
this.listeners.set(type, []);
|
|
435524
|
+
}
|
|
435525
|
+
(_a8 = this.listeners.get(type)) === null || _a8 === void 0 ? void 0 : _a8.push(listener);
|
|
435526
|
+
};
|
|
435527
|
+
this.emit = (type, event) => {
|
|
435528
|
+
const listeners = this.listeners.get(type) || [];
|
|
435529
|
+
for (const listener of listeners) {
|
|
435530
|
+
listener(event);
|
|
435531
|
+
}
|
|
435532
|
+
};
|
|
435533
|
+
this.done = () => __awaiter4(this, void 0, void 0, function* () {
|
|
435534
|
+
return this.donePromise;
|
|
435535
|
+
});
|
|
435536
|
+
this.abort = (reason) => {
|
|
435537
|
+
if (!this.streamClosed) {
|
|
435538
|
+
this.abortController.abort(reason);
|
|
435539
|
+
}
|
|
435540
|
+
};
|
|
435541
|
+
this.endpointId = endpointId;
|
|
435542
|
+
this.config = config4;
|
|
435543
|
+
this.url = (_a7 = options.url) !== null && _a7 !== void 0 ? _a7 : (0, request_1.buildUrl)(endpointId, {
|
|
435544
|
+
path: (0, utils_1.resolveEndpointPath)(endpointId, void 0, "/stream"),
|
|
435545
|
+
query: options.queryParams
|
|
435546
|
+
});
|
|
435547
|
+
this.options = options;
|
|
435548
|
+
this.donePromise = new Promise((resolve44, reject) => {
|
|
435549
|
+
if (this.streamClosed) {
|
|
435550
|
+
reject(new response_1.ApiError({
|
|
435551
|
+
message: "Streaming connection is already closed.",
|
|
435552
|
+
status: 400,
|
|
435553
|
+
body: void 0,
|
|
435554
|
+
requestId: this._requestId || void 0
|
|
435555
|
+
}));
|
|
435556
|
+
}
|
|
435557
|
+
this.signal.addEventListener("abort", () => {
|
|
435558
|
+
var _a8;
|
|
435559
|
+
resolve44((_a8 = this.currentData) !== null && _a8 !== void 0 ? _a8 : {});
|
|
435560
|
+
});
|
|
435561
|
+
this.on("done", (data) => {
|
|
435562
|
+
this.streamClosed = true;
|
|
435563
|
+
resolve44(data);
|
|
435564
|
+
});
|
|
435565
|
+
this.on("error", (error) => {
|
|
435566
|
+
this.streamClosed = true;
|
|
435567
|
+
reject(error);
|
|
435568
|
+
});
|
|
435569
|
+
});
|
|
435570
|
+
if (options.signal) {
|
|
435571
|
+
options.signal.addEventListener("abort", () => {
|
|
435572
|
+
this.abortController.abort();
|
|
435573
|
+
});
|
|
435574
|
+
}
|
|
435575
|
+
this.start().catch(this.handleError);
|
|
435576
|
+
}
|
|
435577
|
+
[Symbol.asyncIterator]() {
|
|
435578
|
+
return __asyncGenerator4(this, arguments, function* _a7() {
|
|
435579
|
+
let running = true;
|
|
435580
|
+
const stopAsyncIterator = () => running = false;
|
|
435581
|
+
this.on("error", stopAsyncIterator);
|
|
435582
|
+
this.on("done", stopAsyncIterator);
|
|
435583
|
+
while (running || this.buffer.length > 0) {
|
|
435584
|
+
const data = this.buffer.shift();
|
|
435585
|
+
if (data) {
|
|
435586
|
+
yield yield __await4(data);
|
|
435587
|
+
}
|
|
435588
|
+
yield __await4(new Promise((resolve44) => setTimeout(resolve44, 16)));
|
|
435589
|
+
}
|
|
435590
|
+
});
|
|
435591
|
+
}
|
|
435592
|
+
/**
|
|
435593
|
+
* Gets the `AbortSignal` instance that can be used to listen for abort events.
|
|
435594
|
+
*
|
|
435595
|
+
* **Note:** this signal is internal to the `FalStream` instance. If you pass your
|
|
435596
|
+
* own abort signal, the `FalStream` will listen to it and abort it appropriately.
|
|
435597
|
+
*
|
|
435598
|
+
* @returns the `AbortSignal` instance.
|
|
435599
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
435600
|
+
*/
|
|
435601
|
+
get signal() {
|
|
435602
|
+
return this.abortController.signal;
|
|
435603
|
+
}
|
|
435604
|
+
/**
|
|
435605
|
+
* Gets the request id of the streaming request.
|
|
435606
|
+
*
|
|
435607
|
+
* @returns the request id.
|
|
435608
|
+
*/
|
|
435609
|
+
get requestId() {
|
|
435610
|
+
return this._requestId;
|
|
435611
|
+
}
|
|
435612
|
+
};
|
|
435613
|
+
exports.FalStream = FalStream;
|
|
435614
|
+
function createStreamingClient({ config: config4, storage }) {
|
|
435615
|
+
return {
|
|
435616
|
+
stream(endpointId, options) {
|
|
435617
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
435618
|
+
const input3 = options.input ? yield storage.transformInput(options.input) : void 0;
|
|
435619
|
+
return new FalStream(endpointId, config4, Object.assign(Object.assign({}, options), { input: input3 }));
|
|
435620
|
+
});
|
|
435621
|
+
}
|
|
435622
|
+
};
|
|
435623
|
+
}
|
|
435624
|
+
}
|
|
435625
|
+
});
|
|
435626
|
+
|
|
435627
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/queue.js
|
|
435628
|
+
var require_queue = __commonJS({
|
|
435629
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/queue.js"(exports) {
|
|
435630
|
+
"use strict";
|
|
435631
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
435632
|
+
function adopt(value) {
|
|
435633
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
435634
|
+
resolve44(value);
|
|
435635
|
+
});
|
|
435636
|
+
}
|
|
435637
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
435638
|
+
function fulfilled(value) {
|
|
435639
|
+
try {
|
|
435640
|
+
step(generator.next(value));
|
|
435641
|
+
} catch (e) {
|
|
435642
|
+
reject(e);
|
|
435643
|
+
}
|
|
435644
|
+
}
|
|
435645
|
+
function rejected(value) {
|
|
435646
|
+
try {
|
|
435647
|
+
step(generator["throw"](value));
|
|
435648
|
+
} catch (e) {
|
|
435649
|
+
reject(e);
|
|
435650
|
+
}
|
|
435651
|
+
}
|
|
435652
|
+
function step(result) {
|
|
435653
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
435654
|
+
}
|
|
435655
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
435656
|
+
});
|
|
435657
|
+
};
|
|
435658
|
+
var __rest3 = exports && exports.__rest || function(s, e) {
|
|
435659
|
+
var t = {};
|
|
435660
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
435661
|
+
t[p] = s[p];
|
|
435662
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
435663
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
435664
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
435665
|
+
t[p[i]] = s[p[i]];
|
|
435666
|
+
}
|
|
435667
|
+
return t;
|
|
435668
|
+
};
|
|
435669
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
435670
|
+
exports.createQueueClient = void 0;
|
|
435671
|
+
var headers_1 = require_headers3();
|
|
435672
|
+
var request_1 = require_request();
|
|
435673
|
+
var response_1 = require_response();
|
|
435674
|
+
var retry_1 = require_retry();
|
|
435675
|
+
var storage_1 = require_storage();
|
|
435676
|
+
var streaming_1 = require_streaming();
|
|
435677
|
+
var utils_1 = require_utils4();
|
|
435678
|
+
var DEFAULT_POLL_INTERVAL = 500;
|
|
435679
|
+
var QUEUE_RETRY_CONFIG = {
|
|
435680
|
+
maxRetries: 3,
|
|
435681
|
+
baseDelay: 1e3,
|
|
435682
|
+
maxDelay: 6e4,
|
|
435683
|
+
retryableStatusCodes: retry_1.DEFAULT_RETRYABLE_STATUS_CODES
|
|
435684
|
+
};
|
|
435685
|
+
var QUEUE_STATUS_RETRY_CONFIG = {
|
|
435686
|
+
maxRetries: 5,
|
|
435687
|
+
baseDelay: 1e3,
|
|
435688
|
+
maxDelay: 3e4,
|
|
435689
|
+
retryableStatusCodes: [...retry_1.DEFAULT_RETRYABLE_STATUS_CODES, 500]
|
|
435690
|
+
};
|
|
435691
|
+
var createQueueClient = ({ config: config4, storage }) => {
|
|
435692
|
+
const ref = {
|
|
435693
|
+
submit(endpointId, options) {
|
|
435694
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
435695
|
+
const { webhookUrl, priority, hint, startTimeout, headers, storageSettings } = options, runOptions = __rest3(options, ["webhookUrl", "priority", "hint", "startTimeout", "headers", "storageSettings"]);
|
|
435696
|
+
const input3 = options.input ? yield storage.transformInput(options.input) : void 0;
|
|
435697
|
+
const extraHeaders = Object.fromEntries(Object.entries(headers !== null && headers !== void 0 ? headers : {}).map(([key2, value]) => [
|
|
435698
|
+
key2.toLowerCase(),
|
|
435699
|
+
value
|
|
435700
|
+
]));
|
|
435701
|
+
return (0, request_1.dispatchRequest)({
|
|
435702
|
+
method: options.method,
|
|
435703
|
+
targetUrl: (0, request_1.buildUrl)(endpointId, Object.assign(Object.assign({}, runOptions), { subdomain: "queue", query: webhookUrl ? { fal_webhook: webhookUrl } : void 0 })),
|
|
435704
|
+
headers: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, extraHeaders), (0, storage_1.buildObjectLifecycleHeaders)(storageSettings)), { [headers_1.QUEUE_PRIORITY_HEADER]: priority !== null && priority !== void 0 ? priority : "normal" }), hint && { [headers_1.RUNNER_HINT_HEADER]: hint }), (0, headers_1.buildTimeoutHeaders)(startTimeout)),
|
|
435705
|
+
input: input3,
|
|
435706
|
+
config: config4,
|
|
435707
|
+
options: {
|
|
435708
|
+
signal: options.abortSignal,
|
|
435709
|
+
retry: QUEUE_RETRY_CONFIG
|
|
435710
|
+
}
|
|
435711
|
+
});
|
|
435712
|
+
});
|
|
435713
|
+
},
|
|
435714
|
+
status(endpointId_1, _a7) {
|
|
435715
|
+
return __awaiter4(this, arguments, void 0, function* (endpointId, { requestId, logs = false, abortSignal }) {
|
|
435716
|
+
const appId = (0, utils_1.parseEndpointId)(endpointId);
|
|
435717
|
+
const prefix = appId.namespace ? `${appId.namespace}/` : "";
|
|
435718
|
+
return (0, request_1.dispatchRequest)({
|
|
435719
|
+
method: "get",
|
|
435720
|
+
targetUrl: (0, request_1.buildUrl)(`${prefix}${appId.owner}/${appId.alias}`, {
|
|
435721
|
+
subdomain: "queue",
|
|
435722
|
+
query: { logs: logs ? "1" : "0" },
|
|
435723
|
+
path: `/requests/${requestId}/status`
|
|
435724
|
+
}),
|
|
435725
|
+
config: config4,
|
|
435726
|
+
options: {
|
|
435727
|
+
signal: abortSignal,
|
|
435728
|
+
retry: QUEUE_STATUS_RETRY_CONFIG
|
|
435729
|
+
}
|
|
435730
|
+
});
|
|
435731
|
+
});
|
|
435732
|
+
},
|
|
435733
|
+
streamStatus(endpointId_1, _a7) {
|
|
435734
|
+
return __awaiter4(this, arguments, void 0, function* (endpointId, { requestId, logs = false, connectionMode }) {
|
|
435735
|
+
const appId = (0, utils_1.parseEndpointId)(endpointId);
|
|
435736
|
+
const prefix = appId.namespace ? `${appId.namespace}/` : "";
|
|
435737
|
+
const queryParams = {
|
|
435738
|
+
logs: logs ? "1" : "0"
|
|
435739
|
+
};
|
|
435740
|
+
const url = (0, request_1.buildUrl)(`${prefix}${appId.owner}/${appId.alias}`, {
|
|
435741
|
+
subdomain: "queue",
|
|
435742
|
+
path: `/requests/${requestId}/status/stream`,
|
|
435743
|
+
query: queryParams
|
|
435744
|
+
});
|
|
435745
|
+
return new streaming_1.FalStream(endpointId, config4, {
|
|
435746
|
+
url,
|
|
435747
|
+
method: "get",
|
|
435748
|
+
connectionMode,
|
|
435749
|
+
queryParams
|
|
435750
|
+
});
|
|
435751
|
+
});
|
|
435752
|
+
},
|
|
435753
|
+
subscribeToStatus(endpointId, options) {
|
|
435754
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
435755
|
+
const requestId = options.requestId;
|
|
435756
|
+
const timeout3 = options.timeout;
|
|
435757
|
+
let timeoutId = void 0;
|
|
435758
|
+
const handleCancelError = () => {
|
|
435759
|
+
};
|
|
435760
|
+
if (options.mode === "streaming") {
|
|
435761
|
+
const status = yield ref.streamStatus(endpointId, {
|
|
435762
|
+
requestId,
|
|
435763
|
+
logs: options.logs,
|
|
435764
|
+
connectionMode: "connectionMode" in options ? options.connectionMode : void 0
|
|
435765
|
+
});
|
|
435766
|
+
const logs = [];
|
|
435767
|
+
if (timeout3) {
|
|
435768
|
+
timeoutId = setTimeout(() => {
|
|
435769
|
+
status.abort();
|
|
435770
|
+
ref.cancel(endpointId, { requestId }).catch(handleCancelError);
|
|
435771
|
+
throw new Error(`Client timed out waiting for the request to complete after ${timeout3}ms`);
|
|
435772
|
+
}, timeout3);
|
|
435773
|
+
}
|
|
435774
|
+
status.on("data", (data) => {
|
|
435775
|
+
if (options.onQueueUpdate) {
|
|
435776
|
+
if ("logs" in data && Array.isArray(data.logs) && data.logs.length > 0) {
|
|
435777
|
+
logs.push(...data.logs);
|
|
435778
|
+
}
|
|
435779
|
+
options.onQueueUpdate("logs" in data ? Object.assign(Object.assign({}, data), { logs }) : data);
|
|
435780
|
+
}
|
|
435781
|
+
});
|
|
435782
|
+
const doneStatus = yield status.done();
|
|
435783
|
+
if (timeoutId) {
|
|
435784
|
+
clearTimeout(timeoutId);
|
|
435785
|
+
}
|
|
435786
|
+
return doneStatus;
|
|
435787
|
+
}
|
|
435788
|
+
return new Promise((resolve44, reject) => {
|
|
435789
|
+
var _a7;
|
|
435790
|
+
let pollingTimeoutId;
|
|
435791
|
+
const pollInterval = "pollInterval" in options && typeof options.pollInterval === "number" ? (_a7 = options.pollInterval) !== null && _a7 !== void 0 ? _a7 : DEFAULT_POLL_INTERVAL : DEFAULT_POLL_INTERVAL;
|
|
435792
|
+
const clearScheduledTasks = () => {
|
|
435793
|
+
if (timeoutId) {
|
|
435794
|
+
clearTimeout(timeoutId);
|
|
435795
|
+
}
|
|
435796
|
+
if (pollingTimeoutId) {
|
|
435797
|
+
clearTimeout(pollingTimeoutId);
|
|
435798
|
+
}
|
|
435799
|
+
};
|
|
435800
|
+
if (timeout3) {
|
|
435801
|
+
timeoutId = setTimeout(() => {
|
|
435802
|
+
clearScheduledTasks();
|
|
435803
|
+
ref.cancel(endpointId, { requestId }).catch(handleCancelError);
|
|
435804
|
+
reject(new Error(`Client timed out waiting for the request to complete after ${timeout3}ms`));
|
|
435805
|
+
}, timeout3);
|
|
435806
|
+
}
|
|
435807
|
+
const poll = () => __awaiter4(this, void 0, void 0, function* () {
|
|
435808
|
+
var _a8;
|
|
435809
|
+
try {
|
|
435810
|
+
const requestStatus = yield ref.status(endpointId, {
|
|
435811
|
+
requestId,
|
|
435812
|
+
logs: (_a8 = options.logs) !== null && _a8 !== void 0 ? _a8 : false,
|
|
435813
|
+
abortSignal: options.abortSignal
|
|
435814
|
+
});
|
|
435815
|
+
if (options.onQueueUpdate) {
|
|
435816
|
+
options.onQueueUpdate(requestStatus);
|
|
435817
|
+
}
|
|
435818
|
+
if (requestStatus.status === "COMPLETED") {
|
|
435819
|
+
clearScheduledTasks();
|
|
435820
|
+
resolve44(requestStatus);
|
|
435821
|
+
return;
|
|
435822
|
+
}
|
|
435823
|
+
pollingTimeoutId = setTimeout(poll, pollInterval);
|
|
435824
|
+
} catch (error) {
|
|
435825
|
+
clearScheduledTasks();
|
|
435826
|
+
reject(error);
|
|
435827
|
+
}
|
|
435828
|
+
});
|
|
435829
|
+
poll().catch(reject);
|
|
435830
|
+
});
|
|
435831
|
+
});
|
|
435832
|
+
},
|
|
435833
|
+
result(endpointId_1, _a7) {
|
|
435834
|
+
return __awaiter4(this, arguments, void 0, function* (endpointId, { requestId, abortSignal }) {
|
|
435835
|
+
const appId = (0, utils_1.parseEndpointId)(endpointId);
|
|
435836
|
+
const prefix = appId.namespace ? `${appId.namespace}/` : "";
|
|
435837
|
+
return (0, request_1.dispatchRequest)({
|
|
435838
|
+
method: "get",
|
|
435839
|
+
targetUrl: (0, request_1.buildUrl)(`${prefix}${appId.owner}/${appId.alias}`, {
|
|
435840
|
+
subdomain: "queue",
|
|
435841
|
+
path: `/requests/${requestId}`
|
|
435842
|
+
}),
|
|
435843
|
+
config: Object.assign(Object.assign({}, config4), { responseHandler: response_1.resultResponseHandler }),
|
|
435844
|
+
options: {
|
|
435845
|
+
signal: abortSignal,
|
|
435846
|
+
retry: QUEUE_RETRY_CONFIG
|
|
435847
|
+
}
|
|
435848
|
+
});
|
|
435849
|
+
});
|
|
435850
|
+
},
|
|
435851
|
+
cancel(endpointId_1, _a7) {
|
|
435852
|
+
return __awaiter4(this, arguments, void 0, function* (endpointId, { requestId, abortSignal }) {
|
|
435853
|
+
const appId = (0, utils_1.parseEndpointId)(endpointId);
|
|
435854
|
+
const prefix = appId.namespace ? `${appId.namespace}/` : "";
|
|
435855
|
+
yield (0, request_1.dispatchRequest)({
|
|
435856
|
+
method: "put",
|
|
435857
|
+
targetUrl: (0, request_1.buildUrl)(`${prefix}${appId.owner}/${appId.alias}`, {
|
|
435858
|
+
subdomain: "queue",
|
|
435859
|
+
path: `/requests/${requestId}/cancel`
|
|
435860
|
+
}),
|
|
435861
|
+
config: config4,
|
|
435862
|
+
options: {
|
|
435863
|
+
signal: abortSignal
|
|
435864
|
+
}
|
|
435865
|
+
});
|
|
435866
|
+
});
|
|
435867
|
+
}
|
|
435868
|
+
};
|
|
435869
|
+
return ref;
|
|
435870
|
+
};
|
|
435871
|
+
exports.createQueueClient = createQueueClient;
|
|
435872
|
+
}
|
|
435873
|
+
});
|
|
435874
|
+
|
|
435875
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs
|
|
435876
|
+
var require_utf8 = __commonJS({
|
|
435877
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs"(exports) {
|
|
435878
|
+
"use strict";
|
|
435879
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
435880
|
+
exports.utf8Count = utf8Count;
|
|
435881
|
+
exports.utf8EncodeJs = utf8EncodeJs;
|
|
435882
|
+
exports.utf8EncodeTE = utf8EncodeTE;
|
|
435883
|
+
exports.utf8Encode = utf8Encode;
|
|
435884
|
+
exports.utf8DecodeJs = utf8DecodeJs;
|
|
435885
|
+
exports.utf8DecodeTD = utf8DecodeTD;
|
|
435886
|
+
exports.utf8Decode = utf8Decode;
|
|
435887
|
+
function utf8Count(str) {
|
|
435888
|
+
const strLength = str.length;
|
|
435889
|
+
let byteLength = 0;
|
|
435890
|
+
let pos = 0;
|
|
435891
|
+
while (pos < strLength) {
|
|
435892
|
+
let value = str.charCodeAt(pos++);
|
|
435893
|
+
if ((value & 4294967168) === 0) {
|
|
435894
|
+
byteLength++;
|
|
435895
|
+
continue;
|
|
435896
|
+
} else if ((value & 4294965248) === 0) {
|
|
435897
|
+
byteLength += 2;
|
|
435898
|
+
} else {
|
|
435899
|
+
if (value >= 55296 && value <= 56319) {
|
|
435900
|
+
if (pos < strLength) {
|
|
435901
|
+
const extra = str.charCodeAt(pos);
|
|
435902
|
+
if ((extra & 64512) === 56320) {
|
|
435903
|
+
++pos;
|
|
435904
|
+
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
435905
|
+
}
|
|
435906
|
+
}
|
|
435907
|
+
}
|
|
435908
|
+
if ((value & 4294901760) === 0) {
|
|
435909
|
+
byteLength += 3;
|
|
435910
|
+
} else {
|
|
435911
|
+
byteLength += 4;
|
|
435912
|
+
}
|
|
435913
|
+
}
|
|
435914
|
+
}
|
|
435915
|
+
return byteLength;
|
|
435916
|
+
}
|
|
435917
|
+
function utf8EncodeJs(str, output3, outputOffset) {
|
|
435918
|
+
const strLength = str.length;
|
|
435919
|
+
let offset = outputOffset;
|
|
435920
|
+
let pos = 0;
|
|
435921
|
+
while (pos < strLength) {
|
|
435922
|
+
let value = str.charCodeAt(pos++);
|
|
435923
|
+
if ((value & 4294967168) === 0) {
|
|
435924
|
+
output3[offset++] = value;
|
|
435925
|
+
continue;
|
|
435926
|
+
} else if ((value & 4294965248) === 0) {
|
|
435927
|
+
output3[offset++] = value >> 6 & 31 | 192;
|
|
435928
|
+
} else {
|
|
435929
|
+
if (value >= 55296 && value <= 56319) {
|
|
435930
|
+
if (pos < strLength) {
|
|
435931
|
+
const extra = str.charCodeAt(pos);
|
|
435932
|
+
if ((extra & 64512) === 56320) {
|
|
435933
|
+
++pos;
|
|
435934
|
+
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
435935
|
+
}
|
|
435936
|
+
}
|
|
435937
|
+
}
|
|
435938
|
+
if ((value & 4294901760) === 0) {
|
|
435939
|
+
output3[offset++] = value >> 12 & 15 | 224;
|
|
435940
|
+
output3[offset++] = value >> 6 & 63 | 128;
|
|
435941
|
+
} else {
|
|
435942
|
+
output3[offset++] = value >> 18 & 7 | 240;
|
|
435943
|
+
output3[offset++] = value >> 12 & 63 | 128;
|
|
435944
|
+
output3[offset++] = value >> 6 & 63 | 128;
|
|
435945
|
+
}
|
|
435946
|
+
}
|
|
435947
|
+
output3[offset++] = value & 63 | 128;
|
|
435948
|
+
}
|
|
435949
|
+
}
|
|
435950
|
+
var sharedTextEncoder = new TextEncoder();
|
|
435951
|
+
var TEXT_ENCODER_THRESHOLD = 50;
|
|
435952
|
+
function utf8EncodeTE(str, output3, outputOffset) {
|
|
435953
|
+
sharedTextEncoder.encodeInto(str, output3.subarray(outputOffset));
|
|
435954
|
+
}
|
|
435955
|
+
function utf8Encode(str, output3, outputOffset) {
|
|
435956
|
+
if (str.length > TEXT_ENCODER_THRESHOLD) {
|
|
435957
|
+
utf8EncodeTE(str, output3, outputOffset);
|
|
435958
|
+
} else {
|
|
435959
|
+
utf8EncodeJs(str, output3, outputOffset);
|
|
435960
|
+
}
|
|
435961
|
+
}
|
|
435962
|
+
var CHUNK_SIZE = 4096;
|
|
435963
|
+
function utf8DecodeJs(bytes, inputOffset, byteLength) {
|
|
435964
|
+
let offset = inputOffset;
|
|
435965
|
+
const end = offset + byteLength;
|
|
435966
|
+
const units2 = [];
|
|
435967
|
+
let result = "";
|
|
435968
|
+
while (offset < end) {
|
|
435969
|
+
const byte1 = bytes[offset++];
|
|
435970
|
+
if ((byte1 & 128) === 0) {
|
|
435971
|
+
units2.push(byte1);
|
|
435972
|
+
} else if ((byte1 & 224) === 192) {
|
|
435973
|
+
const byte2 = bytes[offset++] & 63;
|
|
435974
|
+
units2.push((byte1 & 31) << 6 | byte2);
|
|
435975
|
+
} else if ((byte1 & 240) === 224) {
|
|
435976
|
+
const byte2 = bytes[offset++] & 63;
|
|
435977
|
+
const byte3 = bytes[offset++] & 63;
|
|
435978
|
+
units2.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
|
|
435979
|
+
} else if ((byte1 & 248) === 240) {
|
|
435980
|
+
const byte2 = bytes[offset++] & 63;
|
|
435981
|
+
const byte3 = bytes[offset++] & 63;
|
|
435982
|
+
const byte4 = bytes[offset++] & 63;
|
|
435983
|
+
let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
|
|
435984
|
+
if (unit > 65535) {
|
|
435985
|
+
unit -= 65536;
|
|
435986
|
+
units2.push(unit >>> 10 & 1023 | 55296);
|
|
435987
|
+
unit = 56320 | unit & 1023;
|
|
435988
|
+
}
|
|
435989
|
+
units2.push(unit);
|
|
435990
|
+
} else {
|
|
435991
|
+
units2.push(byte1);
|
|
435992
|
+
}
|
|
435993
|
+
if (units2.length >= CHUNK_SIZE) {
|
|
435994
|
+
result += String.fromCharCode(...units2);
|
|
435995
|
+
units2.length = 0;
|
|
435996
|
+
}
|
|
435997
|
+
}
|
|
435998
|
+
if (units2.length > 0) {
|
|
435999
|
+
result += String.fromCharCode(...units2);
|
|
436000
|
+
}
|
|
436001
|
+
return result;
|
|
436002
|
+
}
|
|
436003
|
+
var sharedTextDecoder = new TextDecoder();
|
|
436004
|
+
var TEXT_DECODER_THRESHOLD = 200;
|
|
436005
|
+
function utf8DecodeTD(bytes, inputOffset, byteLength) {
|
|
436006
|
+
const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
|
|
436007
|
+
return sharedTextDecoder.decode(stringBytes);
|
|
436008
|
+
}
|
|
436009
|
+
function utf8Decode(bytes, inputOffset, byteLength) {
|
|
436010
|
+
if (byteLength > TEXT_DECODER_THRESHOLD) {
|
|
436011
|
+
return utf8DecodeTD(bytes, inputOffset, byteLength);
|
|
436012
|
+
} else {
|
|
436013
|
+
return utf8DecodeJs(bytes, inputOffset, byteLength);
|
|
436014
|
+
}
|
|
436015
|
+
}
|
|
436016
|
+
}
|
|
436017
|
+
});
|
|
436018
|
+
|
|
436019
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/ExtData.cjs
|
|
436020
|
+
var require_ExtData = __commonJS({
|
|
436021
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/ExtData.cjs"(exports) {
|
|
436022
|
+
"use strict";
|
|
436023
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436024
|
+
exports.ExtData = void 0;
|
|
436025
|
+
var ExtData = class {
|
|
436026
|
+
type;
|
|
436027
|
+
data;
|
|
436028
|
+
constructor(type, data) {
|
|
436029
|
+
this.type = type;
|
|
436030
|
+
this.data = data;
|
|
436031
|
+
}
|
|
436032
|
+
};
|
|
436033
|
+
exports.ExtData = ExtData;
|
|
436034
|
+
}
|
|
436035
|
+
});
|
|
436036
|
+
|
|
436037
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/DecodeError.cjs
|
|
436038
|
+
var require_DecodeError = __commonJS({
|
|
436039
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/DecodeError.cjs"(exports) {
|
|
436040
|
+
"use strict";
|
|
436041
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436042
|
+
exports.DecodeError = void 0;
|
|
436043
|
+
var DecodeError = class _DecodeError extends Error {
|
|
436044
|
+
constructor(message) {
|
|
436045
|
+
super(message);
|
|
436046
|
+
const proto2 = Object.create(_DecodeError.prototype);
|
|
436047
|
+
Object.setPrototypeOf(this, proto2);
|
|
436048
|
+
Object.defineProperty(this, "name", {
|
|
436049
|
+
configurable: true,
|
|
436050
|
+
enumerable: false,
|
|
436051
|
+
value: _DecodeError.name
|
|
436052
|
+
});
|
|
436053
|
+
}
|
|
436054
|
+
};
|
|
436055
|
+
exports.DecodeError = DecodeError;
|
|
436056
|
+
}
|
|
436057
|
+
});
|
|
436058
|
+
|
|
436059
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/int.cjs
|
|
436060
|
+
var require_int2 = __commonJS({
|
|
436061
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/int.cjs"(exports) {
|
|
436062
|
+
"use strict";
|
|
436063
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436064
|
+
exports.UINT32_MAX = void 0;
|
|
436065
|
+
exports.setUint64 = setUint64;
|
|
436066
|
+
exports.setInt64 = setInt64;
|
|
436067
|
+
exports.getInt64 = getInt64;
|
|
436068
|
+
exports.getUint64 = getUint64;
|
|
436069
|
+
exports.UINT32_MAX = 4294967295;
|
|
436070
|
+
function setUint64(view, offset, value) {
|
|
436071
|
+
const high = value / 4294967296;
|
|
436072
|
+
const low = value;
|
|
436073
|
+
view.setUint32(offset, high);
|
|
436074
|
+
view.setUint32(offset + 4, low);
|
|
436075
|
+
}
|
|
436076
|
+
function setInt64(view, offset, value) {
|
|
436077
|
+
const high = Math.floor(value / 4294967296);
|
|
436078
|
+
const low = value;
|
|
436079
|
+
view.setUint32(offset, high);
|
|
436080
|
+
view.setUint32(offset + 4, low);
|
|
436081
|
+
}
|
|
436082
|
+
function getInt64(view, offset) {
|
|
436083
|
+
const high = view.getInt32(offset);
|
|
436084
|
+
const low = view.getUint32(offset + 4);
|
|
436085
|
+
return high * 4294967296 + low;
|
|
436086
|
+
}
|
|
436087
|
+
function getUint64(view, offset) {
|
|
436088
|
+
const high = view.getUint32(offset);
|
|
436089
|
+
const low = view.getUint32(offset + 4);
|
|
436090
|
+
return high * 4294967296 + low;
|
|
436091
|
+
}
|
|
436092
|
+
}
|
|
436093
|
+
});
|
|
436094
|
+
|
|
436095
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/timestamp.cjs
|
|
436096
|
+
var require_timestamp2 = __commonJS({
|
|
436097
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/timestamp.cjs"(exports) {
|
|
436098
|
+
"use strict";
|
|
436099
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436100
|
+
exports.timestampExtension = exports.EXT_TIMESTAMP = void 0;
|
|
436101
|
+
exports.encodeTimeSpecToTimestamp = encodeTimeSpecToTimestamp;
|
|
436102
|
+
exports.encodeDateToTimeSpec = encodeDateToTimeSpec;
|
|
436103
|
+
exports.encodeTimestampExtension = encodeTimestampExtension;
|
|
436104
|
+
exports.decodeTimestampToTimeSpec = decodeTimestampToTimeSpec;
|
|
436105
|
+
exports.decodeTimestampExtension = decodeTimestampExtension;
|
|
436106
|
+
var DecodeError_ts_1 = require_DecodeError();
|
|
436107
|
+
var int_ts_1 = require_int2();
|
|
436108
|
+
exports.EXT_TIMESTAMP = -1;
|
|
436109
|
+
var TIMESTAMP32_MAX_SEC = 4294967296 - 1;
|
|
436110
|
+
var TIMESTAMP64_MAX_SEC = 17179869184 - 1;
|
|
436111
|
+
function encodeTimeSpecToTimestamp({ sec, nsec }) {
|
|
436112
|
+
if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
|
|
436113
|
+
if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
|
|
436114
|
+
const rv = new Uint8Array(4);
|
|
436115
|
+
const view = new DataView(rv.buffer);
|
|
436116
|
+
view.setUint32(0, sec);
|
|
436117
|
+
return rv;
|
|
436118
|
+
} else {
|
|
436119
|
+
const secHigh = sec / 4294967296;
|
|
436120
|
+
const secLow = sec & 4294967295;
|
|
436121
|
+
const rv = new Uint8Array(8);
|
|
436122
|
+
const view = new DataView(rv.buffer);
|
|
436123
|
+
view.setUint32(0, nsec << 2 | secHigh & 3);
|
|
436124
|
+
view.setUint32(4, secLow);
|
|
436125
|
+
return rv;
|
|
436126
|
+
}
|
|
436127
|
+
} else {
|
|
436128
|
+
const rv = new Uint8Array(12);
|
|
436129
|
+
const view = new DataView(rv.buffer);
|
|
436130
|
+
view.setUint32(0, nsec);
|
|
436131
|
+
(0, int_ts_1.setInt64)(view, 4, sec);
|
|
436132
|
+
return rv;
|
|
436133
|
+
}
|
|
436134
|
+
}
|
|
436135
|
+
function encodeDateToTimeSpec(date) {
|
|
436136
|
+
const msec = date.getTime();
|
|
436137
|
+
const sec = Math.floor(msec / 1e3);
|
|
436138
|
+
const nsec = (msec - sec * 1e3) * 1e6;
|
|
436139
|
+
const nsecInSec = Math.floor(nsec / 1e9);
|
|
436140
|
+
return {
|
|
436141
|
+
sec: sec + nsecInSec,
|
|
436142
|
+
nsec: nsec - nsecInSec * 1e9
|
|
436143
|
+
};
|
|
436144
|
+
}
|
|
436145
|
+
function encodeTimestampExtension(object) {
|
|
436146
|
+
if (object instanceof Date) {
|
|
436147
|
+
const timeSpec = encodeDateToTimeSpec(object);
|
|
436148
|
+
return encodeTimeSpecToTimestamp(timeSpec);
|
|
436149
|
+
} else {
|
|
436150
|
+
return null;
|
|
436151
|
+
}
|
|
436152
|
+
}
|
|
436153
|
+
function decodeTimestampToTimeSpec(data) {
|
|
436154
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
436155
|
+
switch (data.byteLength) {
|
|
436156
|
+
case 4: {
|
|
436157
|
+
const sec = view.getUint32(0);
|
|
436158
|
+
const nsec = 0;
|
|
436159
|
+
return { sec, nsec };
|
|
436160
|
+
}
|
|
436161
|
+
case 8: {
|
|
436162
|
+
const nsec30AndSecHigh2 = view.getUint32(0);
|
|
436163
|
+
const secLow32 = view.getUint32(4);
|
|
436164
|
+
const sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
|
|
436165
|
+
const nsec = nsec30AndSecHigh2 >>> 2;
|
|
436166
|
+
return { sec, nsec };
|
|
436167
|
+
}
|
|
436168
|
+
case 12: {
|
|
436169
|
+
const sec = (0, int_ts_1.getInt64)(view, 4);
|
|
436170
|
+
const nsec = view.getUint32(0);
|
|
436171
|
+
return { sec, nsec };
|
|
436172
|
+
}
|
|
436173
|
+
default:
|
|
436174
|
+
throw new DecodeError_ts_1.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
|
|
436175
|
+
}
|
|
436176
|
+
}
|
|
436177
|
+
function decodeTimestampExtension(data) {
|
|
436178
|
+
const timeSpec = decodeTimestampToTimeSpec(data);
|
|
436179
|
+
return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
|
|
436180
|
+
}
|
|
436181
|
+
exports.timestampExtension = {
|
|
436182
|
+
type: exports.EXT_TIMESTAMP,
|
|
436183
|
+
encode: encodeTimestampExtension,
|
|
436184
|
+
decode: decodeTimestampExtension
|
|
436185
|
+
};
|
|
436186
|
+
}
|
|
436187
|
+
});
|
|
436188
|
+
|
|
436189
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/ExtensionCodec.cjs
|
|
436190
|
+
var require_ExtensionCodec = __commonJS({
|
|
436191
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/ExtensionCodec.cjs"(exports) {
|
|
436192
|
+
"use strict";
|
|
436193
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436194
|
+
exports.ExtensionCodec = void 0;
|
|
436195
|
+
var ExtData_ts_1 = require_ExtData();
|
|
436196
|
+
var timestamp_ts_1 = require_timestamp2();
|
|
436197
|
+
var ExtensionCodec = class _ExtensionCodec {
|
|
436198
|
+
static defaultCodec = new _ExtensionCodec();
|
|
436199
|
+
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
|
436200
|
+
// this will make type errors a lot more clear
|
|
436201
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
436202
|
+
__brand;
|
|
436203
|
+
// built-in extensions
|
|
436204
|
+
builtInEncoders = [];
|
|
436205
|
+
builtInDecoders = [];
|
|
436206
|
+
// custom extensions
|
|
436207
|
+
encoders = [];
|
|
436208
|
+
decoders = [];
|
|
436209
|
+
constructor() {
|
|
436210
|
+
this.register(timestamp_ts_1.timestampExtension);
|
|
436211
|
+
}
|
|
436212
|
+
register({ type, encode, decode }) {
|
|
436213
|
+
if (type >= 0) {
|
|
436214
|
+
this.encoders[type] = encode;
|
|
436215
|
+
this.decoders[type] = decode;
|
|
436216
|
+
} else {
|
|
436217
|
+
const index = -1 - type;
|
|
436218
|
+
this.builtInEncoders[index] = encode;
|
|
436219
|
+
this.builtInDecoders[index] = decode;
|
|
436220
|
+
}
|
|
436221
|
+
}
|
|
436222
|
+
tryToEncode(object, context3) {
|
|
436223
|
+
for (let i = 0; i < this.builtInEncoders.length; i++) {
|
|
436224
|
+
const encodeExt = this.builtInEncoders[i];
|
|
436225
|
+
if (encodeExt != null) {
|
|
436226
|
+
const data = encodeExt(object, context3);
|
|
436227
|
+
if (data != null) {
|
|
436228
|
+
const type = -1 - i;
|
|
436229
|
+
return new ExtData_ts_1.ExtData(type, data);
|
|
436230
|
+
}
|
|
436231
|
+
}
|
|
436232
|
+
}
|
|
436233
|
+
for (let i = 0; i < this.encoders.length; i++) {
|
|
436234
|
+
const encodeExt = this.encoders[i];
|
|
436235
|
+
if (encodeExt != null) {
|
|
436236
|
+
const data = encodeExt(object, context3);
|
|
436237
|
+
if (data != null) {
|
|
436238
|
+
const type = i;
|
|
436239
|
+
return new ExtData_ts_1.ExtData(type, data);
|
|
436240
|
+
}
|
|
436241
|
+
}
|
|
436242
|
+
}
|
|
436243
|
+
if (object instanceof ExtData_ts_1.ExtData) {
|
|
436244
|
+
return object;
|
|
436245
|
+
}
|
|
436246
|
+
return null;
|
|
436247
|
+
}
|
|
436248
|
+
decode(data, type, context3) {
|
|
436249
|
+
const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
|
436250
|
+
if (decodeExt) {
|
|
436251
|
+
return decodeExt(data, type, context3);
|
|
436252
|
+
} else {
|
|
436253
|
+
return new ExtData_ts_1.ExtData(type, data);
|
|
436254
|
+
}
|
|
436255
|
+
}
|
|
436256
|
+
};
|
|
436257
|
+
exports.ExtensionCodec = ExtensionCodec;
|
|
436258
|
+
}
|
|
436259
|
+
});
|
|
436260
|
+
|
|
436261
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/typedArrays.cjs
|
|
436262
|
+
var require_typedArrays = __commonJS({
|
|
436263
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/typedArrays.cjs"(exports) {
|
|
436264
|
+
"use strict";
|
|
436265
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436266
|
+
exports.ensureUint8Array = ensureUint8Array;
|
|
436267
|
+
function isArrayBufferLike(buffer) {
|
|
436268
|
+
return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
|
|
436269
|
+
}
|
|
436270
|
+
function ensureUint8Array(buffer) {
|
|
436271
|
+
if (buffer instanceof Uint8Array) {
|
|
436272
|
+
return buffer;
|
|
436273
|
+
} else if (ArrayBuffer.isView(buffer)) {
|
|
436274
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
436275
|
+
} else if (isArrayBufferLike(buffer)) {
|
|
436276
|
+
return new Uint8Array(buffer);
|
|
436277
|
+
} else {
|
|
436278
|
+
return Uint8Array.from(buffer);
|
|
436279
|
+
}
|
|
436280
|
+
}
|
|
436281
|
+
}
|
|
436282
|
+
});
|
|
436283
|
+
|
|
436284
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/Encoder.cjs
|
|
436285
|
+
var require_Encoder = __commonJS({
|
|
436286
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/Encoder.cjs"(exports) {
|
|
436287
|
+
"use strict";
|
|
436288
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436289
|
+
exports.Encoder = exports.DEFAULT_INITIAL_BUFFER_SIZE = exports.DEFAULT_MAX_DEPTH = void 0;
|
|
436290
|
+
var utf8_ts_1 = require_utf8();
|
|
436291
|
+
var ExtensionCodec_ts_1 = require_ExtensionCodec();
|
|
436292
|
+
var int_ts_1 = require_int2();
|
|
436293
|
+
var typedArrays_ts_1 = require_typedArrays();
|
|
436294
|
+
exports.DEFAULT_MAX_DEPTH = 100;
|
|
436295
|
+
exports.DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
|
436296
|
+
var Encoder = class _Encoder {
|
|
436297
|
+
extensionCodec;
|
|
436298
|
+
context;
|
|
436299
|
+
useBigInt64;
|
|
436300
|
+
maxDepth;
|
|
436301
|
+
initialBufferSize;
|
|
436302
|
+
sortKeys;
|
|
436303
|
+
forceFloat32;
|
|
436304
|
+
ignoreUndefined;
|
|
436305
|
+
forceIntegerToFloat;
|
|
436306
|
+
pos;
|
|
436307
|
+
view;
|
|
436308
|
+
bytes;
|
|
436309
|
+
entered = false;
|
|
436310
|
+
constructor(options) {
|
|
436311
|
+
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec_ts_1.ExtensionCodec.defaultCodec;
|
|
436312
|
+
this.context = options?.context;
|
|
436313
|
+
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
436314
|
+
this.maxDepth = options?.maxDepth ?? exports.DEFAULT_MAX_DEPTH;
|
|
436315
|
+
this.initialBufferSize = options?.initialBufferSize ?? exports.DEFAULT_INITIAL_BUFFER_SIZE;
|
|
436316
|
+
this.sortKeys = options?.sortKeys ?? false;
|
|
436317
|
+
this.forceFloat32 = options?.forceFloat32 ?? false;
|
|
436318
|
+
this.ignoreUndefined = options?.ignoreUndefined ?? false;
|
|
436319
|
+
this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
|
|
436320
|
+
this.pos = 0;
|
|
436321
|
+
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
|
436322
|
+
this.bytes = new Uint8Array(this.view.buffer);
|
|
436323
|
+
}
|
|
436324
|
+
clone() {
|
|
436325
|
+
return new _Encoder({
|
|
436326
|
+
extensionCodec: this.extensionCodec,
|
|
436327
|
+
context: this.context,
|
|
436328
|
+
useBigInt64: this.useBigInt64,
|
|
436329
|
+
maxDepth: this.maxDepth,
|
|
436330
|
+
initialBufferSize: this.initialBufferSize,
|
|
436331
|
+
sortKeys: this.sortKeys,
|
|
436332
|
+
forceFloat32: this.forceFloat32,
|
|
436333
|
+
ignoreUndefined: this.ignoreUndefined,
|
|
436334
|
+
forceIntegerToFloat: this.forceIntegerToFloat
|
|
436335
|
+
});
|
|
436336
|
+
}
|
|
436337
|
+
reinitializeState() {
|
|
436338
|
+
this.pos = 0;
|
|
436339
|
+
}
|
|
436340
|
+
/**
|
|
436341
|
+
* This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
|
|
436342
|
+
*
|
|
436343
|
+
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
|
436344
|
+
*/
|
|
436345
|
+
encodeSharedRef(object) {
|
|
436346
|
+
if (this.entered) {
|
|
436347
|
+
const instance = this.clone();
|
|
436348
|
+
return instance.encodeSharedRef(object);
|
|
436349
|
+
}
|
|
436350
|
+
try {
|
|
436351
|
+
this.entered = true;
|
|
436352
|
+
this.reinitializeState();
|
|
436353
|
+
this.doEncode(object, 1);
|
|
436354
|
+
return this.bytes.subarray(0, this.pos);
|
|
436355
|
+
} finally {
|
|
436356
|
+
this.entered = false;
|
|
436357
|
+
}
|
|
436358
|
+
}
|
|
436359
|
+
/**
|
|
436360
|
+
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
|
436361
|
+
*/
|
|
436362
|
+
encode(object) {
|
|
436363
|
+
if (this.entered) {
|
|
436364
|
+
const instance = this.clone();
|
|
436365
|
+
return instance.encode(object);
|
|
436366
|
+
}
|
|
436367
|
+
try {
|
|
436368
|
+
this.entered = true;
|
|
436369
|
+
this.reinitializeState();
|
|
436370
|
+
this.doEncode(object, 1);
|
|
436371
|
+
return this.bytes.slice(0, this.pos);
|
|
436372
|
+
} finally {
|
|
436373
|
+
this.entered = false;
|
|
436374
|
+
}
|
|
436375
|
+
}
|
|
436376
|
+
doEncode(object, depth) {
|
|
436377
|
+
if (depth > this.maxDepth) {
|
|
436378
|
+
throw new Error(`Too deep objects in depth ${depth}`);
|
|
436379
|
+
}
|
|
436380
|
+
if (object == null) {
|
|
436381
|
+
this.encodeNil();
|
|
436382
|
+
} else if (typeof object === "boolean") {
|
|
436383
|
+
this.encodeBoolean(object);
|
|
436384
|
+
} else if (typeof object === "number") {
|
|
436385
|
+
if (!this.forceIntegerToFloat) {
|
|
436386
|
+
this.encodeNumber(object);
|
|
436387
|
+
} else {
|
|
436388
|
+
this.encodeNumberAsFloat(object);
|
|
436389
|
+
}
|
|
436390
|
+
} else if (typeof object === "string") {
|
|
436391
|
+
this.encodeString(object);
|
|
436392
|
+
} else if (this.useBigInt64 && typeof object === "bigint") {
|
|
436393
|
+
this.encodeBigInt64(object);
|
|
436394
|
+
} else {
|
|
436395
|
+
this.encodeObject(object, depth);
|
|
436396
|
+
}
|
|
436397
|
+
}
|
|
436398
|
+
ensureBufferSizeToWrite(sizeToWrite) {
|
|
436399
|
+
const requiredSize = this.pos + sizeToWrite;
|
|
436400
|
+
if (this.view.byteLength < requiredSize) {
|
|
436401
|
+
this.resizeBuffer(requiredSize * 2);
|
|
436402
|
+
}
|
|
436403
|
+
}
|
|
436404
|
+
resizeBuffer(newSize) {
|
|
436405
|
+
const newBuffer = new ArrayBuffer(newSize);
|
|
436406
|
+
const newBytes = new Uint8Array(newBuffer);
|
|
436407
|
+
const newView = new DataView(newBuffer);
|
|
436408
|
+
newBytes.set(this.bytes);
|
|
436409
|
+
this.view = newView;
|
|
436410
|
+
this.bytes = newBytes;
|
|
436411
|
+
}
|
|
436412
|
+
encodeNil() {
|
|
436413
|
+
this.writeU8(192);
|
|
436414
|
+
}
|
|
436415
|
+
encodeBoolean(object) {
|
|
436416
|
+
if (object === false) {
|
|
436417
|
+
this.writeU8(194);
|
|
436418
|
+
} else {
|
|
436419
|
+
this.writeU8(195);
|
|
436420
|
+
}
|
|
436421
|
+
}
|
|
436422
|
+
encodeNumber(object) {
|
|
436423
|
+
if (!this.forceIntegerToFloat && Number.isSafeInteger(object)) {
|
|
436424
|
+
if (object >= 0) {
|
|
436425
|
+
if (object < 128) {
|
|
436426
|
+
this.writeU8(object);
|
|
436427
|
+
} else if (object < 256) {
|
|
436428
|
+
this.writeU8(204);
|
|
436429
|
+
this.writeU8(object);
|
|
436430
|
+
} else if (object < 65536) {
|
|
436431
|
+
this.writeU8(205);
|
|
436432
|
+
this.writeU16(object);
|
|
436433
|
+
} else if (object < 4294967296) {
|
|
436434
|
+
this.writeU8(206);
|
|
436435
|
+
this.writeU32(object);
|
|
436436
|
+
} else if (!this.useBigInt64) {
|
|
436437
|
+
this.writeU8(207);
|
|
436438
|
+
this.writeU64(object);
|
|
436439
|
+
} else {
|
|
436440
|
+
this.encodeNumberAsFloat(object);
|
|
436441
|
+
}
|
|
436442
|
+
} else {
|
|
436443
|
+
if (object >= -32) {
|
|
436444
|
+
this.writeU8(224 | object + 32);
|
|
436445
|
+
} else if (object >= -128) {
|
|
436446
|
+
this.writeU8(208);
|
|
436447
|
+
this.writeI8(object);
|
|
436448
|
+
} else if (object >= -32768) {
|
|
436449
|
+
this.writeU8(209);
|
|
436450
|
+
this.writeI16(object);
|
|
436451
|
+
} else if (object >= -2147483648) {
|
|
436452
|
+
this.writeU8(210);
|
|
436453
|
+
this.writeI32(object);
|
|
436454
|
+
} else if (!this.useBigInt64) {
|
|
436455
|
+
this.writeU8(211);
|
|
436456
|
+
this.writeI64(object);
|
|
436457
|
+
} else {
|
|
436458
|
+
this.encodeNumberAsFloat(object);
|
|
436459
|
+
}
|
|
436460
|
+
}
|
|
436461
|
+
} else {
|
|
436462
|
+
this.encodeNumberAsFloat(object);
|
|
436463
|
+
}
|
|
436464
|
+
}
|
|
436465
|
+
encodeNumberAsFloat(object) {
|
|
436466
|
+
if (this.forceFloat32) {
|
|
436467
|
+
this.writeU8(202);
|
|
436468
|
+
this.writeF32(object);
|
|
436469
|
+
} else {
|
|
436470
|
+
this.writeU8(203);
|
|
436471
|
+
this.writeF64(object);
|
|
436472
|
+
}
|
|
436473
|
+
}
|
|
436474
|
+
encodeBigInt64(object) {
|
|
436475
|
+
if (object >= BigInt(0)) {
|
|
436476
|
+
this.writeU8(207);
|
|
436477
|
+
this.writeBigUint64(object);
|
|
436478
|
+
} else {
|
|
436479
|
+
this.writeU8(211);
|
|
436480
|
+
this.writeBigInt64(object);
|
|
436481
|
+
}
|
|
436482
|
+
}
|
|
436483
|
+
writeStringHeader(byteLength) {
|
|
436484
|
+
if (byteLength < 32) {
|
|
436485
|
+
this.writeU8(160 + byteLength);
|
|
436486
|
+
} else if (byteLength < 256) {
|
|
436487
|
+
this.writeU8(217);
|
|
436488
|
+
this.writeU8(byteLength);
|
|
436489
|
+
} else if (byteLength < 65536) {
|
|
436490
|
+
this.writeU8(218);
|
|
436491
|
+
this.writeU16(byteLength);
|
|
436492
|
+
} else if (byteLength < 4294967296) {
|
|
436493
|
+
this.writeU8(219);
|
|
436494
|
+
this.writeU32(byteLength);
|
|
436495
|
+
} else {
|
|
436496
|
+
throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
|
|
436497
|
+
}
|
|
436498
|
+
}
|
|
436499
|
+
encodeString(object) {
|
|
436500
|
+
const maxHeaderSize = 1 + 4;
|
|
436501
|
+
const byteLength = (0, utf8_ts_1.utf8Count)(object);
|
|
436502
|
+
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
|
436503
|
+
this.writeStringHeader(byteLength);
|
|
436504
|
+
(0, utf8_ts_1.utf8Encode)(object, this.bytes, this.pos);
|
|
436505
|
+
this.pos += byteLength;
|
|
436506
|
+
}
|
|
436507
|
+
encodeObject(object, depth) {
|
|
436508
|
+
const ext = this.extensionCodec.tryToEncode(object, this.context);
|
|
436509
|
+
if (ext != null) {
|
|
436510
|
+
this.encodeExtension(ext);
|
|
436511
|
+
} else if (Array.isArray(object)) {
|
|
436512
|
+
this.encodeArray(object, depth);
|
|
436513
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
436514
|
+
this.encodeBinary(object);
|
|
436515
|
+
} else if (typeof object === "object") {
|
|
436516
|
+
this.encodeMap(object, depth);
|
|
436517
|
+
} else {
|
|
436518
|
+
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object)}`);
|
|
436519
|
+
}
|
|
436520
|
+
}
|
|
436521
|
+
encodeBinary(object) {
|
|
436522
|
+
const size = object.byteLength;
|
|
436523
|
+
if (size < 256) {
|
|
436524
|
+
this.writeU8(196);
|
|
436525
|
+
this.writeU8(size);
|
|
436526
|
+
} else if (size < 65536) {
|
|
436527
|
+
this.writeU8(197);
|
|
436528
|
+
this.writeU16(size);
|
|
436529
|
+
} else if (size < 4294967296) {
|
|
436530
|
+
this.writeU8(198);
|
|
436531
|
+
this.writeU32(size);
|
|
436532
|
+
} else {
|
|
436533
|
+
throw new Error(`Too large binary: ${size}`);
|
|
436534
|
+
}
|
|
436535
|
+
const bytes = (0, typedArrays_ts_1.ensureUint8Array)(object);
|
|
436536
|
+
this.writeU8a(bytes);
|
|
436537
|
+
}
|
|
436538
|
+
encodeArray(object, depth) {
|
|
436539
|
+
const size = object.length;
|
|
436540
|
+
if (size < 16) {
|
|
436541
|
+
this.writeU8(144 + size);
|
|
436542
|
+
} else if (size < 65536) {
|
|
436543
|
+
this.writeU8(220);
|
|
436544
|
+
this.writeU16(size);
|
|
436545
|
+
} else if (size < 4294967296) {
|
|
436546
|
+
this.writeU8(221);
|
|
436547
|
+
this.writeU32(size);
|
|
436548
|
+
} else {
|
|
436549
|
+
throw new Error(`Too large array: ${size}`);
|
|
436550
|
+
}
|
|
436551
|
+
for (const item of object) {
|
|
436552
|
+
this.doEncode(item, depth + 1);
|
|
436553
|
+
}
|
|
436554
|
+
}
|
|
436555
|
+
countWithoutUndefined(object, keys2) {
|
|
436556
|
+
let count = 0;
|
|
436557
|
+
for (const key2 of keys2) {
|
|
436558
|
+
if (object[key2] !== void 0) {
|
|
436559
|
+
count++;
|
|
436560
|
+
}
|
|
436561
|
+
}
|
|
436562
|
+
return count;
|
|
436563
|
+
}
|
|
436564
|
+
encodeMap(object, depth) {
|
|
436565
|
+
const keys2 = Object.keys(object);
|
|
436566
|
+
if (this.sortKeys) {
|
|
436567
|
+
keys2.sort();
|
|
436568
|
+
}
|
|
436569
|
+
const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys2) : keys2.length;
|
|
436570
|
+
if (size < 16) {
|
|
436571
|
+
this.writeU8(128 + size);
|
|
436572
|
+
} else if (size < 65536) {
|
|
436573
|
+
this.writeU8(222);
|
|
436574
|
+
this.writeU16(size);
|
|
436575
|
+
} else if (size < 4294967296) {
|
|
436576
|
+
this.writeU8(223);
|
|
436577
|
+
this.writeU32(size);
|
|
436578
|
+
} else {
|
|
436579
|
+
throw new Error(`Too large map object: ${size}`);
|
|
436580
|
+
}
|
|
436581
|
+
for (const key2 of keys2) {
|
|
436582
|
+
const value = object[key2];
|
|
436583
|
+
if (!(this.ignoreUndefined && value === void 0)) {
|
|
436584
|
+
this.encodeString(key2);
|
|
436585
|
+
this.doEncode(value, depth + 1);
|
|
436586
|
+
}
|
|
436587
|
+
}
|
|
436588
|
+
}
|
|
436589
|
+
encodeExtension(ext) {
|
|
436590
|
+
if (typeof ext.data === "function") {
|
|
436591
|
+
const data = ext.data(this.pos + 6);
|
|
436592
|
+
const size2 = data.length;
|
|
436593
|
+
if (size2 >= 4294967296) {
|
|
436594
|
+
throw new Error(`Too large extension object: ${size2}`);
|
|
436595
|
+
}
|
|
436596
|
+
this.writeU8(201);
|
|
436597
|
+
this.writeU32(size2);
|
|
436598
|
+
this.writeI8(ext.type);
|
|
436599
|
+
this.writeU8a(data);
|
|
436600
|
+
return;
|
|
436601
|
+
}
|
|
436602
|
+
const size = ext.data.length;
|
|
436603
|
+
if (size === 1) {
|
|
436604
|
+
this.writeU8(212);
|
|
436605
|
+
} else if (size === 2) {
|
|
436606
|
+
this.writeU8(213);
|
|
436607
|
+
} else if (size === 4) {
|
|
436608
|
+
this.writeU8(214);
|
|
436609
|
+
} else if (size === 8) {
|
|
436610
|
+
this.writeU8(215);
|
|
436611
|
+
} else if (size === 16) {
|
|
436612
|
+
this.writeU8(216);
|
|
436613
|
+
} else if (size < 256) {
|
|
436614
|
+
this.writeU8(199);
|
|
436615
|
+
this.writeU8(size);
|
|
436616
|
+
} else if (size < 65536) {
|
|
436617
|
+
this.writeU8(200);
|
|
436618
|
+
this.writeU16(size);
|
|
436619
|
+
} else if (size < 4294967296) {
|
|
436620
|
+
this.writeU8(201);
|
|
436621
|
+
this.writeU32(size);
|
|
436622
|
+
} else {
|
|
436623
|
+
throw new Error(`Too large extension object: ${size}`);
|
|
436624
|
+
}
|
|
436625
|
+
this.writeI8(ext.type);
|
|
436626
|
+
this.writeU8a(ext.data);
|
|
436627
|
+
}
|
|
436628
|
+
writeU8(value) {
|
|
436629
|
+
this.ensureBufferSizeToWrite(1);
|
|
436630
|
+
this.view.setUint8(this.pos, value);
|
|
436631
|
+
this.pos++;
|
|
436632
|
+
}
|
|
436633
|
+
writeU8a(values) {
|
|
436634
|
+
const size = values.length;
|
|
436635
|
+
this.ensureBufferSizeToWrite(size);
|
|
436636
|
+
this.bytes.set(values, this.pos);
|
|
436637
|
+
this.pos += size;
|
|
436638
|
+
}
|
|
436639
|
+
writeI8(value) {
|
|
436640
|
+
this.ensureBufferSizeToWrite(1);
|
|
436641
|
+
this.view.setInt8(this.pos, value);
|
|
436642
|
+
this.pos++;
|
|
436643
|
+
}
|
|
436644
|
+
writeU16(value) {
|
|
436645
|
+
this.ensureBufferSizeToWrite(2);
|
|
436646
|
+
this.view.setUint16(this.pos, value);
|
|
436647
|
+
this.pos += 2;
|
|
436648
|
+
}
|
|
436649
|
+
writeI16(value) {
|
|
436650
|
+
this.ensureBufferSizeToWrite(2);
|
|
436651
|
+
this.view.setInt16(this.pos, value);
|
|
436652
|
+
this.pos += 2;
|
|
436653
|
+
}
|
|
436654
|
+
writeU32(value) {
|
|
436655
|
+
this.ensureBufferSizeToWrite(4);
|
|
436656
|
+
this.view.setUint32(this.pos, value);
|
|
436657
|
+
this.pos += 4;
|
|
436658
|
+
}
|
|
436659
|
+
writeI32(value) {
|
|
436660
|
+
this.ensureBufferSizeToWrite(4);
|
|
436661
|
+
this.view.setInt32(this.pos, value);
|
|
436662
|
+
this.pos += 4;
|
|
436663
|
+
}
|
|
436664
|
+
writeF32(value) {
|
|
436665
|
+
this.ensureBufferSizeToWrite(4);
|
|
436666
|
+
this.view.setFloat32(this.pos, value);
|
|
436667
|
+
this.pos += 4;
|
|
436668
|
+
}
|
|
436669
|
+
writeF64(value) {
|
|
436670
|
+
this.ensureBufferSizeToWrite(8);
|
|
436671
|
+
this.view.setFloat64(this.pos, value);
|
|
436672
|
+
this.pos += 8;
|
|
436673
|
+
}
|
|
436674
|
+
writeU64(value) {
|
|
436675
|
+
this.ensureBufferSizeToWrite(8);
|
|
436676
|
+
(0, int_ts_1.setUint64)(this.view, this.pos, value);
|
|
436677
|
+
this.pos += 8;
|
|
436678
|
+
}
|
|
436679
|
+
writeI64(value) {
|
|
436680
|
+
this.ensureBufferSizeToWrite(8);
|
|
436681
|
+
(0, int_ts_1.setInt64)(this.view, this.pos, value);
|
|
436682
|
+
this.pos += 8;
|
|
436683
|
+
}
|
|
436684
|
+
writeBigUint64(value) {
|
|
436685
|
+
this.ensureBufferSizeToWrite(8);
|
|
436686
|
+
this.view.setBigUint64(this.pos, value);
|
|
436687
|
+
this.pos += 8;
|
|
436688
|
+
}
|
|
436689
|
+
writeBigInt64(value) {
|
|
436690
|
+
this.ensureBufferSizeToWrite(8);
|
|
436691
|
+
this.view.setBigInt64(this.pos, value);
|
|
436692
|
+
this.pos += 8;
|
|
436693
|
+
}
|
|
436694
|
+
};
|
|
436695
|
+
exports.Encoder = Encoder;
|
|
436696
|
+
}
|
|
436697
|
+
});
|
|
436698
|
+
|
|
436699
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/encode.cjs
|
|
436700
|
+
var require_encode = __commonJS({
|
|
436701
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/encode.cjs"(exports) {
|
|
436702
|
+
"use strict";
|
|
436703
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436704
|
+
exports.encode = encode;
|
|
436705
|
+
var Encoder_ts_1 = require_Encoder();
|
|
436706
|
+
function encode(value, options) {
|
|
436707
|
+
const encoder = new Encoder_ts_1.Encoder(options);
|
|
436708
|
+
return encoder.encodeSharedRef(value);
|
|
436709
|
+
}
|
|
436710
|
+
}
|
|
436711
|
+
});
|
|
436712
|
+
|
|
436713
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/prettyByte.cjs
|
|
436714
|
+
var require_prettyByte = __commonJS({
|
|
436715
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/prettyByte.cjs"(exports) {
|
|
436716
|
+
"use strict";
|
|
436717
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436718
|
+
exports.prettyByte = prettyByte;
|
|
436719
|
+
function prettyByte(byte) {
|
|
436720
|
+
return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
|
|
436721
|
+
}
|
|
436722
|
+
}
|
|
436723
|
+
});
|
|
436724
|
+
|
|
436725
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/CachedKeyDecoder.cjs
|
|
436726
|
+
var require_CachedKeyDecoder = __commonJS({
|
|
436727
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/CachedKeyDecoder.cjs"(exports) {
|
|
436728
|
+
"use strict";
|
|
436729
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436730
|
+
exports.CachedKeyDecoder = void 0;
|
|
436731
|
+
var utf8_ts_1 = require_utf8();
|
|
436732
|
+
var DEFAULT_MAX_KEY_LENGTH = 16;
|
|
436733
|
+
var DEFAULT_MAX_LENGTH_PER_KEY = 16;
|
|
436734
|
+
var CachedKeyDecoder = class {
|
|
436735
|
+
hit = 0;
|
|
436736
|
+
miss = 0;
|
|
436737
|
+
caches;
|
|
436738
|
+
maxKeyLength;
|
|
436739
|
+
maxLengthPerKey;
|
|
436740
|
+
constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
|
|
436741
|
+
this.maxKeyLength = maxKeyLength;
|
|
436742
|
+
this.maxLengthPerKey = maxLengthPerKey;
|
|
436743
|
+
this.caches = [];
|
|
436744
|
+
for (let i = 0; i < this.maxKeyLength; i++) {
|
|
436745
|
+
this.caches.push([]);
|
|
436746
|
+
}
|
|
436747
|
+
}
|
|
436748
|
+
canBeCached(byteLength) {
|
|
436749
|
+
return byteLength > 0 && byteLength <= this.maxKeyLength;
|
|
436750
|
+
}
|
|
436751
|
+
find(bytes, inputOffset, byteLength) {
|
|
436752
|
+
const records = this.caches[byteLength - 1];
|
|
436753
|
+
FIND_CHUNK: for (const record of records) {
|
|
436754
|
+
const recordBytes = record.bytes;
|
|
436755
|
+
for (let j = 0; j < byteLength; j++) {
|
|
436756
|
+
if (recordBytes[j] !== bytes[inputOffset + j]) {
|
|
436757
|
+
continue FIND_CHUNK;
|
|
436758
|
+
}
|
|
436759
|
+
}
|
|
436760
|
+
return record.str;
|
|
436761
|
+
}
|
|
436762
|
+
return null;
|
|
436763
|
+
}
|
|
436764
|
+
store(bytes, value) {
|
|
436765
|
+
const records = this.caches[bytes.length - 1];
|
|
436766
|
+
const record = { bytes, str: value };
|
|
436767
|
+
if (records.length >= this.maxLengthPerKey) {
|
|
436768
|
+
records[Math.random() * records.length | 0] = record;
|
|
436769
|
+
} else {
|
|
436770
|
+
records.push(record);
|
|
436771
|
+
}
|
|
436772
|
+
}
|
|
436773
|
+
decode(bytes, inputOffset, byteLength) {
|
|
436774
|
+
const cachedValue = this.find(bytes, inputOffset, byteLength);
|
|
436775
|
+
if (cachedValue != null) {
|
|
436776
|
+
this.hit++;
|
|
436777
|
+
return cachedValue;
|
|
436778
|
+
}
|
|
436779
|
+
this.miss++;
|
|
436780
|
+
const str = (0, utf8_ts_1.utf8DecodeJs)(bytes, inputOffset, byteLength);
|
|
436781
|
+
const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
|
|
436782
|
+
this.store(slicedCopyOfBytes, str);
|
|
436783
|
+
return str;
|
|
436784
|
+
}
|
|
436785
|
+
};
|
|
436786
|
+
exports.CachedKeyDecoder = CachedKeyDecoder;
|
|
436787
|
+
}
|
|
436788
|
+
});
|
|
436789
|
+
|
|
436790
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/Decoder.cjs
|
|
436791
|
+
var require_Decoder = __commonJS({
|
|
436792
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/Decoder.cjs"(exports) {
|
|
436793
|
+
"use strict";
|
|
436794
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
436795
|
+
exports.Decoder = void 0;
|
|
436796
|
+
var prettyByte_ts_1 = require_prettyByte();
|
|
436797
|
+
var ExtensionCodec_ts_1 = require_ExtensionCodec();
|
|
436798
|
+
var int_ts_1 = require_int2();
|
|
436799
|
+
var utf8_ts_1 = require_utf8();
|
|
436800
|
+
var typedArrays_ts_1 = require_typedArrays();
|
|
436801
|
+
var CachedKeyDecoder_ts_1 = require_CachedKeyDecoder();
|
|
436802
|
+
var DecodeError_ts_1 = require_DecodeError();
|
|
436803
|
+
var STATE_ARRAY = "array";
|
|
436804
|
+
var STATE_MAP_KEY = "map_key";
|
|
436805
|
+
var STATE_MAP_VALUE = "map_value";
|
|
436806
|
+
var mapKeyConverter = (key2) => {
|
|
436807
|
+
if (typeof key2 === "string" || typeof key2 === "number") {
|
|
436808
|
+
return key2;
|
|
436809
|
+
}
|
|
436810
|
+
throw new DecodeError_ts_1.DecodeError("The type of key must be string or number but " + typeof key2);
|
|
436811
|
+
};
|
|
436812
|
+
var StackPool = class {
|
|
436813
|
+
stack = [];
|
|
436814
|
+
stackHeadPosition = -1;
|
|
436815
|
+
get length() {
|
|
436816
|
+
return this.stackHeadPosition + 1;
|
|
436817
|
+
}
|
|
436818
|
+
top() {
|
|
436819
|
+
return this.stack[this.stackHeadPosition];
|
|
436820
|
+
}
|
|
436821
|
+
pushArrayState(size) {
|
|
436822
|
+
const state = this.getUninitializedStateFromPool();
|
|
436823
|
+
state.type = STATE_ARRAY;
|
|
436824
|
+
state.position = 0;
|
|
436825
|
+
state.size = size;
|
|
436826
|
+
state.array = new Array(size);
|
|
436827
|
+
}
|
|
436828
|
+
pushMapState(size) {
|
|
436829
|
+
const state = this.getUninitializedStateFromPool();
|
|
436830
|
+
state.type = STATE_MAP_KEY;
|
|
436831
|
+
state.readCount = 0;
|
|
436832
|
+
state.size = size;
|
|
436833
|
+
state.map = {};
|
|
436834
|
+
}
|
|
436835
|
+
getUninitializedStateFromPool() {
|
|
436836
|
+
this.stackHeadPosition++;
|
|
436837
|
+
if (this.stackHeadPosition === this.stack.length) {
|
|
436838
|
+
const partialState = {
|
|
436839
|
+
type: void 0,
|
|
436840
|
+
size: 0,
|
|
436841
|
+
array: void 0,
|
|
436842
|
+
position: 0,
|
|
436843
|
+
readCount: 0,
|
|
436844
|
+
map: void 0,
|
|
436845
|
+
key: null
|
|
436846
|
+
};
|
|
436847
|
+
this.stack.push(partialState);
|
|
436848
|
+
}
|
|
436849
|
+
return this.stack[this.stackHeadPosition];
|
|
436850
|
+
}
|
|
436851
|
+
release(state) {
|
|
436852
|
+
const topStackState = this.stack[this.stackHeadPosition];
|
|
436853
|
+
if (topStackState !== state) {
|
|
436854
|
+
throw new Error("Invalid stack state. Released state is not on top of the stack.");
|
|
436855
|
+
}
|
|
436856
|
+
if (state.type === STATE_ARRAY) {
|
|
436857
|
+
const partialState = state;
|
|
436858
|
+
partialState.size = 0;
|
|
436859
|
+
partialState.array = void 0;
|
|
436860
|
+
partialState.position = 0;
|
|
436861
|
+
partialState.type = void 0;
|
|
436862
|
+
}
|
|
436863
|
+
if (state.type === STATE_MAP_KEY || state.type === STATE_MAP_VALUE) {
|
|
436864
|
+
const partialState = state;
|
|
436865
|
+
partialState.size = 0;
|
|
436866
|
+
partialState.map = void 0;
|
|
436867
|
+
partialState.readCount = 0;
|
|
436868
|
+
partialState.type = void 0;
|
|
436869
|
+
}
|
|
436870
|
+
this.stackHeadPosition--;
|
|
436871
|
+
}
|
|
436872
|
+
reset() {
|
|
436873
|
+
this.stack.length = 0;
|
|
436874
|
+
this.stackHeadPosition = -1;
|
|
436875
|
+
}
|
|
436876
|
+
};
|
|
436877
|
+
var HEAD_BYTE_REQUIRED = -1;
|
|
436878
|
+
var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
|
|
436879
|
+
var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
|
|
436880
|
+
try {
|
|
436881
|
+
EMPTY_VIEW.getInt8(0);
|
|
436882
|
+
} catch (e) {
|
|
436883
|
+
if (!(e instanceof RangeError)) {
|
|
436884
|
+
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
|
|
436885
|
+
}
|
|
436886
|
+
}
|
|
436887
|
+
var MORE_DATA = new RangeError("Insufficient data");
|
|
436888
|
+
var sharedCachedKeyDecoder = new CachedKeyDecoder_ts_1.CachedKeyDecoder();
|
|
436889
|
+
var Decoder = class _Decoder {
|
|
436890
|
+
extensionCodec;
|
|
436891
|
+
context;
|
|
436892
|
+
useBigInt64;
|
|
436893
|
+
rawStrings;
|
|
436894
|
+
maxStrLength;
|
|
436895
|
+
maxBinLength;
|
|
436896
|
+
maxArrayLength;
|
|
436897
|
+
maxMapLength;
|
|
436898
|
+
maxExtLength;
|
|
436899
|
+
keyDecoder;
|
|
436900
|
+
mapKeyConverter;
|
|
436901
|
+
totalPos = 0;
|
|
436902
|
+
pos = 0;
|
|
436903
|
+
view = EMPTY_VIEW;
|
|
436904
|
+
bytes = EMPTY_BYTES;
|
|
436905
|
+
headByte = HEAD_BYTE_REQUIRED;
|
|
436906
|
+
stack = new StackPool();
|
|
436907
|
+
entered = false;
|
|
436908
|
+
constructor(options) {
|
|
436909
|
+
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec_ts_1.ExtensionCodec.defaultCodec;
|
|
436910
|
+
this.context = options?.context;
|
|
436911
|
+
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
436912
|
+
this.rawStrings = options?.rawStrings ?? false;
|
|
436913
|
+
this.maxStrLength = options?.maxStrLength ?? int_ts_1.UINT32_MAX;
|
|
436914
|
+
this.maxBinLength = options?.maxBinLength ?? int_ts_1.UINT32_MAX;
|
|
436915
|
+
this.maxArrayLength = options?.maxArrayLength ?? int_ts_1.UINT32_MAX;
|
|
436916
|
+
this.maxMapLength = options?.maxMapLength ?? int_ts_1.UINT32_MAX;
|
|
436917
|
+
this.maxExtLength = options?.maxExtLength ?? int_ts_1.UINT32_MAX;
|
|
436918
|
+
this.keyDecoder = options?.keyDecoder !== void 0 ? options.keyDecoder : sharedCachedKeyDecoder;
|
|
436919
|
+
this.mapKeyConverter = options?.mapKeyConverter ?? mapKeyConverter;
|
|
436920
|
+
}
|
|
436921
|
+
clone() {
|
|
436922
|
+
return new _Decoder({
|
|
436923
|
+
extensionCodec: this.extensionCodec,
|
|
436924
|
+
context: this.context,
|
|
436925
|
+
useBigInt64: this.useBigInt64,
|
|
436926
|
+
rawStrings: this.rawStrings,
|
|
436927
|
+
maxStrLength: this.maxStrLength,
|
|
436928
|
+
maxBinLength: this.maxBinLength,
|
|
436929
|
+
maxArrayLength: this.maxArrayLength,
|
|
436930
|
+
maxMapLength: this.maxMapLength,
|
|
436931
|
+
maxExtLength: this.maxExtLength,
|
|
436932
|
+
keyDecoder: this.keyDecoder
|
|
436933
|
+
});
|
|
436934
|
+
}
|
|
436935
|
+
reinitializeState() {
|
|
436936
|
+
this.totalPos = 0;
|
|
436937
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
436938
|
+
this.stack.reset();
|
|
436939
|
+
}
|
|
436940
|
+
setBuffer(buffer) {
|
|
436941
|
+
const bytes = (0, typedArrays_ts_1.ensureUint8Array)(buffer);
|
|
436942
|
+
this.bytes = bytes;
|
|
436943
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
436944
|
+
this.pos = 0;
|
|
436945
|
+
}
|
|
436946
|
+
appendBuffer(buffer) {
|
|
436947
|
+
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
|
|
436948
|
+
this.setBuffer(buffer);
|
|
436949
|
+
} else {
|
|
436950
|
+
const remainingData = this.bytes.subarray(this.pos);
|
|
436951
|
+
const newData = (0, typedArrays_ts_1.ensureUint8Array)(buffer);
|
|
436952
|
+
const newBuffer = new Uint8Array(remainingData.length + newData.length);
|
|
436953
|
+
newBuffer.set(remainingData);
|
|
436954
|
+
newBuffer.set(newData, remainingData.length);
|
|
436955
|
+
this.setBuffer(newBuffer);
|
|
436956
|
+
}
|
|
436957
|
+
}
|
|
436958
|
+
hasRemaining(size) {
|
|
436959
|
+
return this.view.byteLength - this.pos >= size;
|
|
436960
|
+
}
|
|
436961
|
+
createExtraByteError(posToShow) {
|
|
436962
|
+
const { view, pos } = this;
|
|
436963
|
+
return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
|
|
436964
|
+
}
|
|
436965
|
+
/**
|
|
436966
|
+
* @throws {@link DecodeError}
|
|
436967
|
+
* @throws {@link RangeError}
|
|
436968
|
+
*/
|
|
436969
|
+
decode(buffer) {
|
|
436970
|
+
if (this.entered) {
|
|
436971
|
+
const instance = this.clone();
|
|
436972
|
+
return instance.decode(buffer);
|
|
436973
|
+
}
|
|
436974
|
+
try {
|
|
436975
|
+
this.entered = true;
|
|
436976
|
+
this.reinitializeState();
|
|
436977
|
+
this.setBuffer(buffer);
|
|
436978
|
+
const object = this.doDecodeSync();
|
|
436979
|
+
if (this.hasRemaining(1)) {
|
|
436980
|
+
throw this.createExtraByteError(this.pos);
|
|
436981
|
+
}
|
|
436982
|
+
return object;
|
|
436983
|
+
} finally {
|
|
436984
|
+
this.entered = false;
|
|
436985
|
+
}
|
|
436986
|
+
}
|
|
436987
|
+
*decodeMulti(buffer) {
|
|
436988
|
+
if (this.entered) {
|
|
436989
|
+
const instance = this.clone();
|
|
436990
|
+
yield* instance.decodeMulti(buffer);
|
|
436991
|
+
return;
|
|
436992
|
+
}
|
|
436993
|
+
try {
|
|
436994
|
+
this.entered = true;
|
|
436995
|
+
this.reinitializeState();
|
|
436996
|
+
this.setBuffer(buffer);
|
|
436997
|
+
while (this.hasRemaining(1)) {
|
|
436998
|
+
yield this.doDecodeSync();
|
|
436999
|
+
}
|
|
437000
|
+
} finally {
|
|
437001
|
+
this.entered = false;
|
|
437002
|
+
}
|
|
437003
|
+
}
|
|
437004
|
+
async decodeAsync(stream) {
|
|
437005
|
+
if (this.entered) {
|
|
437006
|
+
const instance = this.clone();
|
|
437007
|
+
return instance.decodeAsync(stream);
|
|
437008
|
+
}
|
|
437009
|
+
try {
|
|
437010
|
+
this.entered = true;
|
|
437011
|
+
let decoded = false;
|
|
437012
|
+
let object;
|
|
437013
|
+
for await (const buffer of stream) {
|
|
437014
|
+
if (decoded) {
|
|
437015
|
+
this.entered = false;
|
|
437016
|
+
throw this.createExtraByteError(this.totalPos);
|
|
437017
|
+
}
|
|
437018
|
+
this.appendBuffer(buffer);
|
|
437019
|
+
try {
|
|
437020
|
+
object = this.doDecodeSync();
|
|
437021
|
+
decoded = true;
|
|
437022
|
+
} catch (e) {
|
|
437023
|
+
if (!(e instanceof RangeError)) {
|
|
437024
|
+
throw e;
|
|
437025
|
+
}
|
|
437026
|
+
}
|
|
437027
|
+
this.totalPos += this.pos;
|
|
437028
|
+
}
|
|
437029
|
+
if (decoded) {
|
|
437030
|
+
if (this.hasRemaining(1)) {
|
|
437031
|
+
throw this.createExtraByteError(this.totalPos);
|
|
437032
|
+
}
|
|
437033
|
+
return object;
|
|
437034
|
+
}
|
|
437035
|
+
const { headByte, pos, totalPos } = this;
|
|
437036
|
+
throw new RangeError(`Insufficient data in parsing ${(0, prettyByte_ts_1.prettyByte)(headByte)} at ${totalPos} (${pos} in the current buffer)`);
|
|
437037
|
+
} finally {
|
|
437038
|
+
this.entered = false;
|
|
437039
|
+
}
|
|
437040
|
+
}
|
|
437041
|
+
decodeArrayStream(stream) {
|
|
437042
|
+
return this.decodeMultiAsync(stream, true);
|
|
437043
|
+
}
|
|
437044
|
+
decodeStream(stream) {
|
|
437045
|
+
return this.decodeMultiAsync(stream, false);
|
|
437046
|
+
}
|
|
437047
|
+
async *decodeMultiAsync(stream, isArray5) {
|
|
437048
|
+
if (this.entered) {
|
|
437049
|
+
const instance = this.clone();
|
|
437050
|
+
yield* instance.decodeMultiAsync(stream, isArray5);
|
|
437051
|
+
return;
|
|
437052
|
+
}
|
|
437053
|
+
try {
|
|
437054
|
+
this.entered = true;
|
|
437055
|
+
let isArrayHeaderRequired = isArray5;
|
|
437056
|
+
let arrayItemsLeft = -1;
|
|
437057
|
+
for await (const buffer of stream) {
|
|
437058
|
+
if (isArray5 && arrayItemsLeft === 0) {
|
|
437059
|
+
throw this.createExtraByteError(this.totalPos);
|
|
437060
|
+
}
|
|
437061
|
+
this.appendBuffer(buffer);
|
|
437062
|
+
if (isArrayHeaderRequired) {
|
|
437063
|
+
arrayItemsLeft = this.readArraySize();
|
|
437064
|
+
isArrayHeaderRequired = false;
|
|
437065
|
+
this.complete();
|
|
437066
|
+
}
|
|
437067
|
+
try {
|
|
437068
|
+
while (true) {
|
|
437069
|
+
yield this.doDecodeSync();
|
|
437070
|
+
if (--arrayItemsLeft === 0) {
|
|
437071
|
+
break;
|
|
437072
|
+
}
|
|
437073
|
+
}
|
|
437074
|
+
} catch (e) {
|
|
437075
|
+
if (!(e instanceof RangeError)) {
|
|
437076
|
+
throw e;
|
|
437077
|
+
}
|
|
437078
|
+
}
|
|
437079
|
+
this.totalPos += this.pos;
|
|
437080
|
+
}
|
|
437081
|
+
} finally {
|
|
437082
|
+
this.entered = false;
|
|
437083
|
+
}
|
|
437084
|
+
}
|
|
437085
|
+
doDecodeSync() {
|
|
437086
|
+
DECODE: while (true) {
|
|
437087
|
+
const headByte = this.readHeadByte();
|
|
437088
|
+
let object;
|
|
437089
|
+
if (headByte >= 224) {
|
|
437090
|
+
object = headByte - 256;
|
|
437091
|
+
} else if (headByte < 192) {
|
|
437092
|
+
if (headByte < 128) {
|
|
437093
|
+
object = headByte;
|
|
437094
|
+
} else if (headByte < 144) {
|
|
437095
|
+
const size = headByte - 128;
|
|
437096
|
+
if (size !== 0) {
|
|
437097
|
+
this.pushMapState(size);
|
|
437098
|
+
this.complete();
|
|
437099
|
+
continue DECODE;
|
|
437100
|
+
} else {
|
|
437101
|
+
object = {};
|
|
437102
|
+
}
|
|
437103
|
+
} else if (headByte < 160) {
|
|
437104
|
+
const size = headByte - 144;
|
|
437105
|
+
if (size !== 0) {
|
|
437106
|
+
this.pushArrayState(size);
|
|
437107
|
+
this.complete();
|
|
437108
|
+
continue DECODE;
|
|
437109
|
+
} else {
|
|
437110
|
+
object = [];
|
|
437111
|
+
}
|
|
437112
|
+
} else {
|
|
437113
|
+
const byteLength = headByte - 160;
|
|
437114
|
+
object = this.decodeString(byteLength, 0);
|
|
437115
|
+
}
|
|
437116
|
+
} else if (headByte === 192) {
|
|
437117
|
+
object = null;
|
|
437118
|
+
} else if (headByte === 194) {
|
|
437119
|
+
object = false;
|
|
437120
|
+
} else if (headByte === 195) {
|
|
437121
|
+
object = true;
|
|
437122
|
+
} else if (headByte === 202) {
|
|
437123
|
+
object = this.readF32();
|
|
437124
|
+
} else if (headByte === 203) {
|
|
437125
|
+
object = this.readF64();
|
|
437126
|
+
} else if (headByte === 204) {
|
|
437127
|
+
object = this.readU8();
|
|
437128
|
+
} else if (headByte === 205) {
|
|
437129
|
+
object = this.readU16();
|
|
437130
|
+
} else if (headByte === 206) {
|
|
437131
|
+
object = this.readU32();
|
|
437132
|
+
} else if (headByte === 207) {
|
|
437133
|
+
if (this.useBigInt64) {
|
|
437134
|
+
object = this.readU64AsBigInt();
|
|
437135
|
+
} else {
|
|
437136
|
+
object = this.readU64();
|
|
437137
|
+
}
|
|
437138
|
+
} else if (headByte === 208) {
|
|
437139
|
+
object = this.readI8();
|
|
437140
|
+
} else if (headByte === 209) {
|
|
437141
|
+
object = this.readI16();
|
|
437142
|
+
} else if (headByte === 210) {
|
|
437143
|
+
object = this.readI32();
|
|
437144
|
+
} else if (headByte === 211) {
|
|
437145
|
+
if (this.useBigInt64) {
|
|
437146
|
+
object = this.readI64AsBigInt();
|
|
437147
|
+
} else {
|
|
437148
|
+
object = this.readI64();
|
|
437149
|
+
}
|
|
437150
|
+
} else if (headByte === 217) {
|
|
437151
|
+
const byteLength = this.lookU8();
|
|
437152
|
+
object = this.decodeString(byteLength, 1);
|
|
437153
|
+
} else if (headByte === 218) {
|
|
437154
|
+
const byteLength = this.lookU16();
|
|
437155
|
+
object = this.decodeString(byteLength, 2);
|
|
437156
|
+
} else if (headByte === 219) {
|
|
437157
|
+
const byteLength = this.lookU32();
|
|
437158
|
+
object = this.decodeString(byteLength, 4);
|
|
437159
|
+
} else if (headByte === 220) {
|
|
437160
|
+
const size = this.readU16();
|
|
437161
|
+
if (size !== 0) {
|
|
437162
|
+
this.pushArrayState(size);
|
|
437163
|
+
this.complete();
|
|
437164
|
+
continue DECODE;
|
|
437165
|
+
} else {
|
|
437166
|
+
object = [];
|
|
437167
|
+
}
|
|
437168
|
+
} else if (headByte === 221) {
|
|
437169
|
+
const size = this.readU32();
|
|
437170
|
+
if (size !== 0) {
|
|
437171
|
+
this.pushArrayState(size);
|
|
437172
|
+
this.complete();
|
|
437173
|
+
continue DECODE;
|
|
437174
|
+
} else {
|
|
437175
|
+
object = [];
|
|
437176
|
+
}
|
|
437177
|
+
} else if (headByte === 222) {
|
|
437178
|
+
const size = this.readU16();
|
|
437179
|
+
if (size !== 0) {
|
|
437180
|
+
this.pushMapState(size);
|
|
437181
|
+
this.complete();
|
|
437182
|
+
continue DECODE;
|
|
437183
|
+
} else {
|
|
437184
|
+
object = {};
|
|
437185
|
+
}
|
|
437186
|
+
} else if (headByte === 223) {
|
|
437187
|
+
const size = this.readU32();
|
|
437188
|
+
if (size !== 0) {
|
|
437189
|
+
this.pushMapState(size);
|
|
437190
|
+
this.complete();
|
|
437191
|
+
continue DECODE;
|
|
437192
|
+
} else {
|
|
437193
|
+
object = {};
|
|
437194
|
+
}
|
|
437195
|
+
} else if (headByte === 196) {
|
|
437196
|
+
const size = this.lookU8();
|
|
437197
|
+
object = this.decodeBinary(size, 1);
|
|
437198
|
+
} else if (headByte === 197) {
|
|
437199
|
+
const size = this.lookU16();
|
|
437200
|
+
object = this.decodeBinary(size, 2);
|
|
437201
|
+
} else if (headByte === 198) {
|
|
437202
|
+
const size = this.lookU32();
|
|
437203
|
+
object = this.decodeBinary(size, 4);
|
|
437204
|
+
} else if (headByte === 212) {
|
|
437205
|
+
object = this.decodeExtension(1, 0);
|
|
437206
|
+
} else if (headByte === 213) {
|
|
437207
|
+
object = this.decodeExtension(2, 0);
|
|
437208
|
+
} else if (headByte === 214) {
|
|
437209
|
+
object = this.decodeExtension(4, 0);
|
|
437210
|
+
} else if (headByte === 215) {
|
|
437211
|
+
object = this.decodeExtension(8, 0);
|
|
437212
|
+
} else if (headByte === 216) {
|
|
437213
|
+
object = this.decodeExtension(16, 0);
|
|
437214
|
+
} else if (headByte === 199) {
|
|
437215
|
+
const size = this.lookU8();
|
|
437216
|
+
object = this.decodeExtension(size, 1);
|
|
437217
|
+
} else if (headByte === 200) {
|
|
437218
|
+
const size = this.lookU16();
|
|
437219
|
+
object = this.decodeExtension(size, 2);
|
|
437220
|
+
} else if (headByte === 201) {
|
|
437221
|
+
const size = this.lookU32();
|
|
437222
|
+
object = this.decodeExtension(size, 4);
|
|
437223
|
+
} else {
|
|
437224
|
+
throw new DecodeError_ts_1.DecodeError(`Unrecognized type byte: ${(0, prettyByte_ts_1.prettyByte)(headByte)}`);
|
|
437225
|
+
}
|
|
437226
|
+
this.complete();
|
|
437227
|
+
const stack = this.stack;
|
|
437228
|
+
while (stack.length > 0) {
|
|
437229
|
+
const state = stack.top();
|
|
437230
|
+
if (state.type === STATE_ARRAY) {
|
|
437231
|
+
state.array[state.position] = object;
|
|
437232
|
+
state.position++;
|
|
437233
|
+
if (state.position === state.size) {
|
|
437234
|
+
object = state.array;
|
|
437235
|
+
stack.release(state);
|
|
437236
|
+
} else {
|
|
437237
|
+
continue DECODE;
|
|
437238
|
+
}
|
|
437239
|
+
} else if (state.type === STATE_MAP_KEY) {
|
|
437240
|
+
if (object === "__proto__") {
|
|
437241
|
+
throw new DecodeError_ts_1.DecodeError("The key __proto__ is not allowed");
|
|
437242
|
+
}
|
|
437243
|
+
state.key = this.mapKeyConverter(object);
|
|
437244
|
+
state.type = STATE_MAP_VALUE;
|
|
437245
|
+
continue DECODE;
|
|
437246
|
+
} else {
|
|
437247
|
+
state.map[state.key] = object;
|
|
437248
|
+
state.readCount++;
|
|
437249
|
+
if (state.readCount === state.size) {
|
|
437250
|
+
object = state.map;
|
|
437251
|
+
stack.release(state);
|
|
437252
|
+
} else {
|
|
437253
|
+
state.key = null;
|
|
437254
|
+
state.type = STATE_MAP_KEY;
|
|
437255
|
+
continue DECODE;
|
|
437256
|
+
}
|
|
437257
|
+
}
|
|
437258
|
+
}
|
|
437259
|
+
return object;
|
|
437260
|
+
}
|
|
437261
|
+
}
|
|
437262
|
+
readHeadByte() {
|
|
437263
|
+
if (this.headByte === HEAD_BYTE_REQUIRED) {
|
|
437264
|
+
this.headByte = this.readU8();
|
|
437265
|
+
}
|
|
437266
|
+
return this.headByte;
|
|
437267
|
+
}
|
|
437268
|
+
complete() {
|
|
437269
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
437270
|
+
}
|
|
437271
|
+
readArraySize() {
|
|
437272
|
+
const headByte = this.readHeadByte();
|
|
437273
|
+
switch (headByte) {
|
|
437274
|
+
case 220:
|
|
437275
|
+
return this.readU16();
|
|
437276
|
+
case 221:
|
|
437277
|
+
return this.readU32();
|
|
437278
|
+
default: {
|
|
437279
|
+
if (headByte < 160) {
|
|
437280
|
+
return headByte - 144;
|
|
437281
|
+
} else {
|
|
437282
|
+
throw new DecodeError_ts_1.DecodeError(`Unrecognized array type byte: ${(0, prettyByte_ts_1.prettyByte)(headByte)}`);
|
|
437283
|
+
}
|
|
437284
|
+
}
|
|
437285
|
+
}
|
|
437286
|
+
}
|
|
437287
|
+
pushMapState(size) {
|
|
437288
|
+
if (size > this.maxMapLength) {
|
|
437289
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
|
|
437290
|
+
}
|
|
437291
|
+
this.stack.pushMapState(size);
|
|
437292
|
+
}
|
|
437293
|
+
pushArrayState(size) {
|
|
437294
|
+
if (size > this.maxArrayLength) {
|
|
437295
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
|
|
437296
|
+
}
|
|
437297
|
+
this.stack.pushArrayState(size);
|
|
437298
|
+
}
|
|
437299
|
+
decodeString(byteLength, headerOffset) {
|
|
437300
|
+
if (!this.rawStrings || this.stateIsMapKey()) {
|
|
437301
|
+
return this.decodeUtf8String(byteLength, headerOffset);
|
|
437302
|
+
}
|
|
437303
|
+
return this.decodeBinary(byteLength, headerOffset);
|
|
437304
|
+
}
|
|
437305
|
+
/**
|
|
437306
|
+
* @throws {@link RangeError}
|
|
437307
|
+
*/
|
|
437308
|
+
decodeUtf8String(byteLength, headerOffset) {
|
|
437309
|
+
if (byteLength > this.maxStrLength) {
|
|
437310
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`);
|
|
437311
|
+
}
|
|
437312
|
+
if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
|
|
437313
|
+
throw MORE_DATA;
|
|
437314
|
+
}
|
|
437315
|
+
const offset = this.pos + headerOffset;
|
|
437316
|
+
let object;
|
|
437317
|
+
if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) {
|
|
437318
|
+
object = this.keyDecoder.decode(this.bytes, offset, byteLength);
|
|
437319
|
+
} else {
|
|
437320
|
+
object = (0, utf8_ts_1.utf8Decode)(this.bytes, offset, byteLength);
|
|
437321
|
+
}
|
|
437322
|
+
this.pos += headerOffset + byteLength;
|
|
437323
|
+
return object;
|
|
437324
|
+
}
|
|
437325
|
+
stateIsMapKey() {
|
|
437326
|
+
if (this.stack.length > 0) {
|
|
437327
|
+
const state = this.stack.top();
|
|
437328
|
+
return state.type === STATE_MAP_KEY;
|
|
437329
|
+
}
|
|
437330
|
+
return false;
|
|
437331
|
+
}
|
|
437332
|
+
/**
|
|
437333
|
+
* @throws {@link RangeError}
|
|
437334
|
+
*/
|
|
437335
|
+
decodeBinary(byteLength, headOffset) {
|
|
437336
|
+
if (byteLength > this.maxBinLength) {
|
|
437337
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
|
|
437338
|
+
}
|
|
437339
|
+
if (!this.hasRemaining(byteLength + headOffset)) {
|
|
437340
|
+
throw MORE_DATA;
|
|
437341
|
+
}
|
|
437342
|
+
const offset = this.pos + headOffset;
|
|
437343
|
+
const object = this.bytes.subarray(offset, offset + byteLength);
|
|
437344
|
+
this.pos += headOffset + byteLength;
|
|
437345
|
+
return object;
|
|
437346
|
+
}
|
|
437347
|
+
decodeExtension(size, headOffset) {
|
|
437348
|
+
if (size > this.maxExtLength) {
|
|
437349
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
|
|
437350
|
+
}
|
|
437351
|
+
const extType = this.view.getInt8(this.pos + headOffset);
|
|
437352
|
+
const data = this.decodeBinary(
|
|
437353
|
+
size,
|
|
437354
|
+
headOffset + 1
|
|
437355
|
+
/* extType */
|
|
437356
|
+
);
|
|
437357
|
+
return this.extensionCodec.decode(data, extType, this.context);
|
|
437358
|
+
}
|
|
437359
|
+
lookU8() {
|
|
437360
|
+
return this.view.getUint8(this.pos);
|
|
437361
|
+
}
|
|
437362
|
+
lookU16() {
|
|
437363
|
+
return this.view.getUint16(this.pos);
|
|
437364
|
+
}
|
|
437365
|
+
lookU32() {
|
|
437366
|
+
return this.view.getUint32(this.pos);
|
|
437367
|
+
}
|
|
437368
|
+
readU8() {
|
|
437369
|
+
const value = this.view.getUint8(this.pos);
|
|
437370
|
+
this.pos++;
|
|
437371
|
+
return value;
|
|
437372
|
+
}
|
|
437373
|
+
readI8() {
|
|
437374
|
+
const value = this.view.getInt8(this.pos);
|
|
437375
|
+
this.pos++;
|
|
437376
|
+
return value;
|
|
437377
|
+
}
|
|
437378
|
+
readU16() {
|
|
437379
|
+
const value = this.view.getUint16(this.pos);
|
|
437380
|
+
this.pos += 2;
|
|
437381
|
+
return value;
|
|
437382
|
+
}
|
|
437383
|
+
readI16() {
|
|
437384
|
+
const value = this.view.getInt16(this.pos);
|
|
437385
|
+
this.pos += 2;
|
|
437386
|
+
return value;
|
|
437387
|
+
}
|
|
437388
|
+
readU32() {
|
|
437389
|
+
const value = this.view.getUint32(this.pos);
|
|
437390
|
+
this.pos += 4;
|
|
437391
|
+
return value;
|
|
437392
|
+
}
|
|
437393
|
+
readI32() {
|
|
437394
|
+
const value = this.view.getInt32(this.pos);
|
|
437395
|
+
this.pos += 4;
|
|
437396
|
+
return value;
|
|
437397
|
+
}
|
|
437398
|
+
readU64() {
|
|
437399
|
+
const value = (0, int_ts_1.getUint64)(this.view, this.pos);
|
|
437400
|
+
this.pos += 8;
|
|
437401
|
+
return value;
|
|
437402
|
+
}
|
|
437403
|
+
readI64() {
|
|
437404
|
+
const value = (0, int_ts_1.getInt64)(this.view, this.pos);
|
|
437405
|
+
this.pos += 8;
|
|
437406
|
+
return value;
|
|
437407
|
+
}
|
|
437408
|
+
readU64AsBigInt() {
|
|
437409
|
+
const value = this.view.getBigUint64(this.pos);
|
|
437410
|
+
this.pos += 8;
|
|
437411
|
+
return value;
|
|
437412
|
+
}
|
|
437413
|
+
readI64AsBigInt() {
|
|
437414
|
+
const value = this.view.getBigInt64(this.pos);
|
|
437415
|
+
this.pos += 8;
|
|
437416
|
+
return value;
|
|
437417
|
+
}
|
|
437418
|
+
readF32() {
|
|
437419
|
+
const value = this.view.getFloat32(this.pos);
|
|
437420
|
+
this.pos += 4;
|
|
437421
|
+
return value;
|
|
437422
|
+
}
|
|
437423
|
+
readF64() {
|
|
437424
|
+
const value = this.view.getFloat64(this.pos);
|
|
437425
|
+
this.pos += 8;
|
|
437426
|
+
return value;
|
|
437427
|
+
}
|
|
437428
|
+
};
|
|
437429
|
+
exports.Decoder = Decoder;
|
|
437430
|
+
}
|
|
437431
|
+
});
|
|
437432
|
+
|
|
437433
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/decode.cjs
|
|
437434
|
+
var require_decode = __commonJS({
|
|
437435
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/decode.cjs"(exports) {
|
|
437436
|
+
"use strict";
|
|
437437
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437438
|
+
exports.decode = decode;
|
|
437439
|
+
exports.decodeMulti = decodeMulti;
|
|
437440
|
+
var Decoder_ts_1 = require_Decoder();
|
|
437441
|
+
function decode(buffer, options) {
|
|
437442
|
+
const decoder2 = new Decoder_ts_1.Decoder(options);
|
|
437443
|
+
return decoder2.decode(buffer);
|
|
437444
|
+
}
|
|
437445
|
+
function decodeMulti(buffer, options) {
|
|
437446
|
+
const decoder2 = new Decoder_ts_1.Decoder(options);
|
|
437447
|
+
return decoder2.decodeMulti(buffer);
|
|
437448
|
+
}
|
|
437449
|
+
}
|
|
437450
|
+
});
|
|
437451
|
+
|
|
437452
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/stream.cjs
|
|
437453
|
+
var require_stream3 = __commonJS({
|
|
437454
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/utils/stream.cjs"(exports) {
|
|
437455
|
+
"use strict";
|
|
437456
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437457
|
+
exports.isAsyncIterable = isAsyncIterable3;
|
|
437458
|
+
exports.asyncIterableFromStream = asyncIterableFromStream;
|
|
437459
|
+
exports.ensureAsyncIterable = ensureAsyncIterable;
|
|
437460
|
+
function isAsyncIterable3(object) {
|
|
437461
|
+
return object[Symbol.asyncIterator] != null;
|
|
437462
|
+
}
|
|
437463
|
+
async function* asyncIterableFromStream(stream) {
|
|
437464
|
+
const reader = stream.getReader();
|
|
437465
|
+
try {
|
|
437466
|
+
while (true) {
|
|
437467
|
+
const { done, value } = await reader.read();
|
|
437468
|
+
if (done) {
|
|
437469
|
+
return;
|
|
437470
|
+
}
|
|
437471
|
+
yield value;
|
|
437472
|
+
}
|
|
437473
|
+
} finally {
|
|
437474
|
+
reader.releaseLock();
|
|
437475
|
+
}
|
|
437476
|
+
}
|
|
437477
|
+
function ensureAsyncIterable(streamLike) {
|
|
437478
|
+
if (isAsyncIterable3(streamLike)) {
|
|
437479
|
+
return streamLike;
|
|
437480
|
+
} else {
|
|
437481
|
+
return asyncIterableFromStream(streamLike);
|
|
437482
|
+
}
|
|
437483
|
+
}
|
|
437484
|
+
}
|
|
437485
|
+
});
|
|
437486
|
+
|
|
437487
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/decodeAsync.cjs
|
|
437488
|
+
var require_decodeAsync = __commonJS({
|
|
437489
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/decodeAsync.cjs"(exports) {
|
|
437490
|
+
"use strict";
|
|
437491
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437492
|
+
exports.decodeAsync = decodeAsync;
|
|
437493
|
+
exports.decodeArrayStream = decodeArrayStream;
|
|
437494
|
+
exports.decodeMultiStream = decodeMultiStream;
|
|
437495
|
+
var Decoder_ts_1 = require_Decoder();
|
|
437496
|
+
var stream_ts_1 = require_stream3();
|
|
437497
|
+
async function decodeAsync(streamLike, options) {
|
|
437498
|
+
const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
|
|
437499
|
+
const decoder2 = new Decoder_ts_1.Decoder(options);
|
|
437500
|
+
return decoder2.decodeAsync(stream);
|
|
437501
|
+
}
|
|
437502
|
+
function decodeArrayStream(streamLike, options) {
|
|
437503
|
+
const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
|
|
437504
|
+
const decoder2 = new Decoder_ts_1.Decoder(options);
|
|
437505
|
+
return decoder2.decodeArrayStream(stream);
|
|
437506
|
+
}
|
|
437507
|
+
function decodeMultiStream(streamLike, options) {
|
|
437508
|
+
const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
|
|
437509
|
+
const decoder2 = new Decoder_ts_1.Decoder(options);
|
|
437510
|
+
return decoder2.decodeStream(stream);
|
|
437511
|
+
}
|
|
437512
|
+
}
|
|
437513
|
+
});
|
|
437514
|
+
|
|
437515
|
+
// ../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/index.cjs
|
|
437516
|
+
var require_dist15 = __commonJS({
|
|
437517
|
+
"../../node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.cjs/index.cjs"(exports) {
|
|
437518
|
+
"use strict";
|
|
437519
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437520
|
+
exports.decodeTimestampExtension = exports.encodeTimestampExtension = exports.decodeTimestampToTimeSpec = exports.encodeTimeSpecToTimestamp = exports.encodeDateToTimeSpec = exports.EXT_TIMESTAMP = exports.ExtData = exports.ExtensionCodec = exports.Encoder = exports.DecodeError = exports.Decoder = exports.decodeMultiStream = exports.decodeArrayStream = exports.decodeAsync = exports.decodeMulti = exports.decode = exports.encode = void 0;
|
|
437521
|
+
var encode_ts_1 = require_encode();
|
|
437522
|
+
Object.defineProperty(exports, "encode", { enumerable: true, get: function() {
|
|
437523
|
+
return encode_ts_1.encode;
|
|
437524
|
+
} });
|
|
437525
|
+
var decode_ts_1 = require_decode();
|
|
437526
|
+
Object.defineProperty(exports, "decode", { enumerable: true, get: function() {
|
|
437527
|
+
return decode_ts_1.decode;
|
|
437528
|
+
} });
|
|
437529
|
+
Object.defineProperty(exports, "decodeMulti", { enumerable: true, get: function() {
|
|
437530
|
+
return decode_ts_1.decodeMulti;
|
|
437531
|
+
} });
|
|
437532
|
+
var decodeAsync_ts_1 = require_decodeAsync();
|
|
437533
|
+
Object.defineProperty(exports, "decodeAsync", { enumerable: true, get: function() {
|
|
437534
|
+
return decodeAsync_ts_1.decodeAsync;
|
|
437535
|
+
} });
|
|
437536
|
+
Object.defineProperty(exports, "decodeArrayStream", { enumerable: true, get: function() {
|
|
437537
|
+
return decodeAsync_ts_1.decodeArrayStream;
|
|
437538
|
+
} });
|
|
437539
|
+
Object.defineProperty(exports, "decodeMultiStream", { enumerable: true, get: function() {
|
|
437540
|
+
return decodeAsync_ts_1.decodeMultiStream;
|
|
437541
|
+
} });
|
|
437542
|
+
var Decoder_ts_1 = require_Decoder();
|
|
437543
|
+
Object.defineProperty(exports, "Decoder", { enumerable: true, get: function() {
|
|
437544
|
+
return Decoder_ts_1.Decoder;
|
|
437545
|
+
} });
|
|
437546
|
+
var DecodeError_ts_1 = require_DecodeError();
|
|
437547
|
+
Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {
|
|
437548
|
+
return DecodeError_ts_1.DecodeError;
|
|
437549
|
+
} });
|
|
437550
|
+
var Encoder_ts_1 = require_Encoder();
|
|
437551
|
+
Object.defineProperty(exports, "Encoder", { enumerable: true, get: function() {
|
|
437552
|
+
return Encoder_ts_1.Encoder;
|
|
437553
|
+
} });
|
|
437554
|
+
var ExtensionCodec_ts_1 = require_ExtensionCodec();
|
|
437555
|
+
Object.defineProperty(exports, "ExtensionCodec", { enumerable: true, get: function() {
|
|
437556
|
+
return ExtensionCodec_ts_1.ExtensionCodec;
|
|
437557
|
+
} });
|
|
437558
|
+
var ExtData_ts_1 = require_ExtData();
|
|
437559
|
+
Object.defineProperty(exports, "ExtData", { enumerable: true, get: function() {
|
|
437560
|
+
return ExtData_ts_1.ExtData;
|
|
437561
|
+
} });
|
|
437562
|
+
var timestamp_ts_1 = require_timestamp2();
|
|
437563
|
+
Object.defineProperty(exports, "EXT_TIMESTAMP", { enumerable: true, get: function() {
|
|
437564
|
+
return timestamp_ts_1.EXT_TIMESTAMP;
|
|
437565
|
+
} });
|
|
437566
|
+
Object.defineProperty(exports, "encodeDateToTimeSpec", { enumerable: true, get: function() {
|
|
437567
|
+
return timestamp_ts_1.encodeDateToTimeSpec;
|
|
437568
|
+
} });
|
|
437569
|
+
Object.defineProperty(exports, "encodeTimeSpecToTimestamp", { enumerable: true, get: function() {
|
|
437570
|
+
return timestamp_ts_1.encodeTimeSpecToTimestamp;
|
|
437571
|
+
} });
|
|
437572
|
+
Object.defineProperty(exports, "decodeTimestampToTimeSpec", { enumerable: true, get: function() {
|
|
437573
|
+
return timestamp_ts_1.decodeTimestampToTimeSpec;
|
|
437574
|
+
} });
|
|
437575
|
+
Object.defineProperty(exports, "encodeTimestampExtension", { enumerable: true, get: function() {
|
|
437576
|
+
return timestamp_ts_1.encodeTimestampExtension;
|
|
437577
|
+
} });
|
|
437578
|
+
Object.defineProperty(exports, "decodeTimestampExtension", { enumerable: true, get: function() {
|
|
437579
|
+
return timestamp_ts_1.decodeTimestampExtension;
|
|
437580
|
+
} });
|
|
437581
|
+
}
|
|
437582
|
+
});
|
|
437583
|
+
|
|
437584
|
+
// ../../node_modules/.pnpm/robot3@0.4.1/node_modules/robot3/dist/machine.js
|
|
437585
|
+
var require_machine = __commonJS({
|
|
437586
|
+
"../../node_modules/.pnpm/robot3@0.4.1/node_modules/robot3/dist/machine.js"(exports) {
|
|
437587
|
+
"use strict";
|
|
437588
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437589
|
+
function valueEnumerable(value) {
|
|
437590
|
+
return { enumerable: true, value };
|
|
437591
|
+
}
|
|
437592
|
+
function valueEnumerableWritable(value) {
|
|
437593
|
+
return { enumerable: true, writable: true, value };
|
|
437594
|
+
}
|
|
437595
|
+
var d = {};
|
|
437596
|
+
var truthy = () => true;
|
|
437597
|
+
var empty = () => ({});
|
|
437598
|
+
var identity3 = (a) => a;
|
|
437599
|
+
var callBoth = (par, fn, self2, args) => par.apply(self2, args) && fn.apply(self2, args);
|
|
437600
|
+
var callForward = (par, fn, self2, [a, b]) => fn.call(self2, par.call(self2, a, b), b);
|
|
437601
|
+
var create3 = (a, b) => Object.freeze(Object.create(a, b));
|
|
437602
|
+
function stack(fns, def, caller) {
|
|
437603
|
+
return fns.reduce((par, fn) => {
|
|
437604
|
+
return function(...args) {
|
|
437605
|
+
return caller(par, fn, this, args);
|
|
437606
|
+
};
|
|
437607
|
+
}, def);
|
|
437608
|
+
}
|
|
437609
|
+
function fnType(fn) {
|
|
437610
|
+
return create3(this, { fn: valueEnumerable(fn) });
|
|
437611
|
+
}
|
|
437612
|
+
var reduceType = {};
|
|
437613
|
+
var reduce = fnType.bind(reduceType);
|
|
437614
|
+
var action = (fn) => reduce((ctx, ev) => !!~fn(ctx, ev) && ctx);
|
|
437615
|
+
var guardType = {};
|
|
437616
|
+
var guard = fnType.bind(guardType);
|
|
437617
|
+
function filter4(Type, arr) {
|
|
437618
|
+
return arr.filter((value) => Type.isPrototypeOf(value));
|
|
437619
|
+
}
|
|
437620
|
+
function makeTransition(from3, to, ...args) {
|
|
437621
|
+
let guards = stack(filter4(guardType, args).map((t) => t.fn), truthy, callBoth);
|
|
437622
|
+
let reducers = stack(filter4(reduceType, args).map((t) => t.fn), identity3, callForward);
|
|
437623
|
+
return create3(this, {
|
|
437624
|
+
from: valueEnumerable(from3),
|
|
437625
|
+
to: valueEnumerable(to),
|
|
437626
|
+
guards: valueEnumerable(guards),
|
|
437627
|
+
reducers: valueEnumerable(reducers)
|
|
437628
|
+
});
|
|
437629
|
+
}
|
|
437630
|
+
var transitionType = {};
|
|
437631
|
+
var immediateType = {};
|
|
437632
|
+
var transition = makeTransition.bind(transitionType);
|
|
437633
|
+
var immediate = makeTransition.bind(immediateType, null);
|
|
437634
|
+
function enterImmediate(machine2, service2, event) {
|
|
437635
|
+
return transitionTo(service2, machine2, event, this.immediates) || machine2;
|
|
437636
|
+
}
|
|
437637
|
+
function transitionsToMap(transitions) {
|
|
437638
|
+
let m = /* @__PURE__ */ new Map();
|
|
437639
|
+
for (let t of transitions) {
|
|
437640
|
+
if (!m.has(t.from)) m.set(t.from, []);
|
|
437641
|
+
m.get(t.from).push(t);
|
|
437642
|
+
}
|
|
437643
|
+
return m;
|
|
437644
|
+
}
|
|
437645
|
+
var stateType = { enter: identity3 };
|
|
437646
|
+
function state(...args) {
|
|
437647
|
+
let transitions = filter4(transitionType, args);
|
|
437648
|
+
let immediates = filter4(immediateType, args);
|
|
437649
|
+
let desc = {
|
|
437650
|
+
final: valueEnumerable(args.length === 0),
|
|
437651
|
+
transitions: valueEnumerable(transitionsToMap(transitions))
|
|
437652
|
+
};
|
|
437653
|
+
if (immediates.length) {
|
|
437654
|
+
desc.immediates = valueEnumerable(immediates);
|
|
437655
|
+
desc.enter = valueEnumerable(enterImmediate);
|
|
437656
|
+
}
|
|
437657
|
+
return create3(stateType, desc);
|
|
437658
|
+
}
|
|
437659
|
+
var invokeFnType = {
|
|
437660
|
+
enter(machine2, service2, event) {
|
|
437661
|
+
let rn = this.fn.call(service2, service2.context, event);
|
|
437662
|
+
if (machine.isPrototypeOf(rn))
|
|
437663
|
+
return create3(invokeMachineType, {
|
|
437664
|
+
machine: valueEnumerable(rn),
|
|
437665
|
+
transitions: valueEnumerable(this.transitions)
|
|
437666
|
+
}).enter(machine2, service2, event);
|
|
437667
|
+
rn.then((data) => service2.send({ type: "done", data })).catch((error) => service2.send({ type: "error", error }));
|
|
437668
|
+
return machine2;
|
|
437669
|
+
}
|
|
437670
|
+
};
|
|
437671
|
+
var invokeMachineType = {
|
|
437672
|
+
enter(machine2, service2, event) {
|
|
437673
|
+
service2.child = interpret(this.machine, (s) => {
|
|
437674
|
+
service2.onChange(s);
|
|
437675
|
+
if (service2.child == s && s.machine.state.value.final) {
|
|
437676
|
+
delete service2.child;
|
|
437677
|
+
service2.send({ type: "done", data: s.context });
|
|
437678
|
+
}
|
|
437679
|
+
}, service2.context, event);
|
|
437680
|
+
if (service2.child.machine.state.value.final) {
|
|
437681
|
+
let data = service2.child.context;
|
|
437682
|
+
delete service2.child;
|
|
437683
|
+
return transitionTo(service2, machine2, { type: "done", data }, this.transitions.get("done"));
|
|
437684
|
+
}
|
|
437685
|
+
return machine2;
|
|
437686
|
+
}
|
|
437687
|
+
};
|
|
437688
|
+
function invoke(fn, ...transitions) {
|
|
437689
|
+
let t = valueEnumerable(transitionsToMap(transitions));
|
|
437690
|
+
return machine.isPrototypeOf(fn) ? create3(invokeMachineType, {
|
|
437691
|
+
machine: valueEnumerable(fn),
|
|
437692
|
+
transitions: t
|
|
437693
|
+
}) : create3(invokeFnType, {
|
|
437694
|
+
fn: valueEnumerable(fn),
|
|
437695
|
+
transitions: t
|
|
437696
|
+
});
|
|
437697
|
+
}
|
|
437698
|
+
var machine = {
|
|
437699
|
+
get state() {
|
|
437700
|
+
return {
|
|
437701
|
+
name: this.current,
|
|
437702
|
+
value: this.states[this.current]
|
|
437703
|
+
};
|
|
437704
|
+
}
|
|
437705
|
+
};
|
|
437706
|
+
function createMachine(current, states, contextFn = empty) {
|
|
437707
|
+
if (typeof current !== "string") {
|
|
437708
|
+
contextFn = states || empty;
|
|
437709
|
+
states = current;
|
|
437710
|
+
current = Object.keys(states)[0];
|
|
437711
|
+
}
|
|
437712
|
+
if (d._create) d._create(current, states);
|
|
437713
|
+
return create3(machine, {
|
|
437714
|
+
context: valueEnumerable(contextFn),
|
|
437715
|
+
current: valueEnumerable(current),
|
|
437716
|
+
states: valueEnumerable(states)
|
|
437717
|
+
});
|
|
437718
|
+
}
|
|
437719
|
+
function transitionTo(service2, machine2, fromEvent3, candidates) {
|
|
437720
|
+
let { context: context3 } = service2;
|
|
437721
|
+
for (let { to, guards, reducers } of candidates) {
|
|
437722
|
+
if (guards(context3, fromEvent3)) {
|
|
437723
|
+
service2.context = reducers.call(service2, context3, fromEvent3);
|
|
437724
|
+
let original = machine2.original || machine2;
|
|
437725
|
+
let newMachine = create3(original, {
|
|
437726
|
+
current: valueEnumerable(to),
|
|
437727
|
+
original: { value: original }
|
|
437728
|
+
});
|
|
437729
|
+
if (d._onEnter) d._onEnter(machine2, to, service2.context, context3, fromEvent3);
|
|
437730
|
+
let state2 = newMachine.state.value;
|
|
437731
|
+
return state2.enter(newMachine, service2, fromEvent3);
|
|
437732
|
+
}
|
|
437733
|
+
}
|
|
437734
|
+
}
|
|
437735
|
+
function send(service2, event) {
|
|
437736
|
+
let eventName = event.type || event;
|
|
437737
|
+
let { machine: machine2 } = service2;
|
|
437738
|
+
let { value: state2, name: currentStateName } = machine2.state;
|
|
437739
|
+
if (state2.transitions.has(eventName)) {
|
|
437740
|
+
return transitionTo(service2, machine2, event, state2.transitions.get(eventName)) || machine2;
|
|
437741
|
+
} else {
|
|
437742
|
+
if (d._send) d._send(eventName, currentStateName);
|
|
437743
|
+
}
|
|
437744
|
+
return machine2;
|
|
437745
|
+
}
|
|
437746
|
+
var service = {
|
|
437747
|
+
send(event) {
|
|
437748
|
+
this.machine = send(this, event);
|
|
437749
|
+
this.onChange(this);
|
|
437750
|
+
}
|
|
437751
|
+
};
|
|
437752
|
+
function interpret(machine2, onChange, initialContext, event) {
|
|
437753
|
+
let s = Object.create(service, {
|
|
437754
|
+
machine: valueEnumerableWritable(machine2),
|
|
437755
|
+
context: valueEnumerableWritable(machine2.context(initialContext, event)),
|
|
437756
|
+
onChange: valueEnumerable(onChange)
|
|
437757
|
+
});
|
|
437758
|
+
s.send = s.send.bind(s);
|
|
437759
|
+
s.machine = s.machine.state.value.enter(s.machine, s, event);
|
|
437760
|
+
return s;
|
|
437761
|
+
}
|
|
437762
|
+
exports.action = action;
|
|
437763
|
+
exports.createMachine = createMachine;
|
|
437764
|
+
exports.d = d;
|
|
437765
|
+
exports.guard = guard;
|
|
437766
|
+
exports.immediate = immediate;
|
|
437767
|
+
exports.interpret = interpret;
|
|
437768
|
+
exports.invoke = invoke;
|
|
437769
|
+
exports.reduce = reduce;
|
|
437770
|
+
exports.state = state;
|
|
437771
|
+
exports.transition = transition;
|
|
437772
|
+
}
|
|
437773
|
+
});
|
|
437774
|
+
|
|
437775
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/realtime.js
|
|
437776
|
+
var require_realtime = __commonJS({
|
|
437777
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/realtime.js"(exports) {
|
|
437778
|
+
"use strict";
|
|
437779
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
437780
|
+
function adopt(value) {
|
|
437781
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
437782
|
+
resolve44(value);
|
|
437783
|
+
});
|
|
437784
|
+
}
|
|
437785
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
437786
|
+
function fulfilled(value) {
|
|
437787
|
+
try {
|
|
437788
|
+
step(generator.next(value));
|
|
437789
|
+
} catch (e) {
|
|
437790
|
+
reject(e);
|
|
437791
|
+
}
|
|
437792
|
+
}
|
|
437793
|
+
function rejected(value) {
|
|
437794
|
+
try {
|
|
437795
|
+
step(generator["throw"](value));
|
|
437796
|
+
} catch (e) {
|
|
437797
|
+
reject(e);
|
|
437798
|
+
}
|
|
437799
|
+
}
|
|
437800
|
+
function step(result) {
|
|
437801
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
437802
|
+
}
|
|
437803
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
437804
|
+
});
|
|
437805
|
+
};
|
|
437806
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437807
|
+
exports.createRealtimeClient = createRealtimeClient;
|
|
437808
|
+
var msgpack_1 = require_dist15();
|
|
437809
|
+
var robot3_1 = require_machine();
|
|
437810
|
+
var auth_1 = require_auth();
|
|
437811
|
+
var response_1 = require_response();
|
|
437812
|
+
var runtime_1 = require_runtime3();
|
|
437813
|
+
var utils_1 = require_utils4();
|
|
437814
|
+
var initialState = () => ({
|
|
437815
|
+
enqueuedMessage: void 0
|
|
437816
|
+
});
|
|
437817
|
+
function hasToken(context3) {
|
|
437818
|
+
return context3.token !== void 0;
|
|
437819
|
+
}
|
|
437820
|
+
function noToken(context3) {
|
|
437821
|
+
return !hasToken(context3);
|
|
437822
|
+
}
|
|
437823
|
+
function enqueueMessage(context3, event) {
|
|
437824
|
+
return Object.assign(Object.assign({}, context3), { enqueuedMessage: event.message });
|
|
437825
|
+
}
|
|
437826
|
+
function closeConnection(context3) {
|
|
437827
|
+
if (context3.websocket && context3.websocket.readyState === WebSocket.OPEN) {
|
|
437828
|
+
context3.websocket.close();
|
|
437829
|
+
}
|
|
437830
|
+
return Object.assign(Object.assign({}, context3), { websocket: void 0 });
|
|
437831
|
+
}
|
|
437832
|
+
function sendMessage(context3, event) {
|
|
437833
|
+
if (context3.websocket && context3.websocket.readyState === WebSocket.OPEN) {
|
|
437834
|
+
if (event.message instanceof Uint8Array) {
|
|
437835
|
+
context3.websocket.send(event.message);
|
|
437836
|
+
} else if (typeof event.message === "string") {
|
|
437837
|
+
context3.websocket.send(event.message);
|
|
437838
|
+
} else {
|
|
437839
|
+
context3.websocket.send((0, msgpack_1.encode)(event.message));
|
|
437840
|
+
}
|
|
437841
|
+
return Object.assign(Object.assign({}, context3), { enqueuedMessage: void 0 });
|
|
437842
|
+
}
|
|
437843
|
+
return Object.assign(Object.assign({}, context3), { enqueuedMessage: event.message });
|
|
437844
|
+
}
|
|
437845
|
+
function expireToken(context3) {
|
|
437846
|
+
return Object.assign(Object.assign({}, context3), { token: void 0 });
|
|
437847
|
+
}
|
|
437848
|
+
function setToken(context3, event) {
|
|
437849
|
+
return Object.assign(Object.assign({}, context3), { token: event.token });
|
|
437850
|
+
}
|
|
437851
|
+
function connectionEstablished(context3, event) {
|
|
437852
|
+
return Object.assign(Object.assign({}, context3), { websocket: event.websocket });
|
|
437853
|
+
}
|
|
437854
|
+
var connectionStateMachine = (0, robot3_1.createMachine)("idle", {
|
|
437855
|
+
idle: (0, robot3_1.state)((0, robot3_1.transition)("send", "connecting", (0, robot3_1.reduce)(enqueueMessage)), (0, robot3_1.transition)("close", "idle", (0, robot3_1.reduce)(closeConnection))),
|
|
437856
|
+
connecting: (0, robot3_1.state)((0, robot3_1.transition)("connecting", "connecting"), (0, robot3_1.transition)("connected", "active", (0, robot3_1.reduce)(connectionEstablished)), (0, robot3_1.transition)("connectionClosed", "idle", (0, robot3_1.reduce)(closeConnection)), (0, robot3_1.transition)("send", "connecting", (0, robot3_1.reduce)(enqueueMessage)), (0, robot3_1.transition)("close", "idle", (0, robot3_1.reduce)(closeConnection)), (0, robot3_1.immediate)("authRequired", (0, robot3_1.guard)(noToken))),
|
|
437857
|
+
authRequired: (0, robot3_1.state)((0, robot3_1.transition)("initiateAuth", "authInProgress"), (0, robot3_1.transition)("send", "authRequired", (0, robot3_1.reduce)(enqueueMessage)), (0, robot3_1.transition)("close", "idle", (0, robot3_1.reduce)(closeConnection))),
|
|
437858
|
+
authInProgress: (0, robot3_1.state)((0, robot3_1.transition)("authenticated", "connecting", (0, robot3_1.reduce)(setToken)), (0, robot3_1.transition)("unauthorized", "idle", (0, robot3_1.reduce)(expireToken), (0, robot3_1.reduce)(closeConnection)), (0, robot3_1.transition)("send", "authInProgress", (0, robot3_1.reduce)(enqueueMessage)), (0, robot3_1.transition)("close", "idle", (0, robot3_1.reduce)(closeConnection))),
|
|
437859
|
+
active: (0, robot3_1.state)((0, robot3_1.transition)("send", "active", (0, robot3_1.reduce)(sendMessage)), (0, robot3_1.transition)("authenticated", "active", (0, robot3_1.reduce)(setToken)), (0, robot3_1.transition)("unauthorized", "idle", (0, robot3_1.reduce)(expireToken)), (0, robot3_1.transition)("connectionClosed", "idle", (0, robot3_1.reduce)(expireToken), (0, robot3_1.reduce)(closeConnection)), (0, robot3_1.transition)("close", "idle", (0, robot3_1.reduce)(expireToken), (0, robot3_1.reduce)(closeConnection)))
|
|
437860
|
+
}, initialState);
|
|
437861
|
+
function buildRealtimeUrl(app, { token, maxBuffering, path: path14 }) {
|
|
437862
|
+
var _a7;
|
|
437863
|
+
if (maxBuffering !== void 0 && (maxBuffering < 1 || maxBuffering > 60)) {
|
|
437864
|
+
throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");
|
|
437865
|
+
}
|
|
437866
|
+
const queryParams = new URLSearchParams({
|
|
437867
|
+
fal_jwt_token: token
|
|
437868
|
+
});
|
|
437869
|
+
if (maxBuffering !== void 0) {
|
|
437870
|
+
queryParams.set("max_buffering", maxBuffering.toFixed(0));
|
|
437871
|
+
}
|
|
437872
|
+
const appId = (0, utils_1.ensureEndpointIdFormat)(app);
|
|
437873
|
+
const resolvedPath = (_a7 = (0, utils_1.resolveEndpointPath)(app, path14, "/realtime")) !== null && _a7 !== void 0 ? _a7 : "";
|
|
437874
|
+
return `wss://fal.run/${appId}${resolvedPath}?${queryParams.toString()}`;
|
|
437875
|
+
}
|
|
437876
|
+
var DEFAULT_THROTTLE_INTERVAL = 128;
|
|
437877
|
+
function isUnauthorizedError(message) {
|
|
437878
|
+
return message["status"] === "error" && message["error"] === "Unauthorized";
|
|
437879
|
+
}
|
|
437880
|
+
var WebSocketErrorCodes = {
|
|
437881
|
+
NORMAL_CLOSURE: 1e3,
|
|
437882
|
+
GOING_AWAY: 1001
|
|
437883
|
+
};
|
|
437884
|
+
var connectionCache = /* @__PURE__ */ new Map();
|
|
437885
|
+
var connectionCallbacks = /* @__PURE__ */ new Map();
|
|
437886
|
+
function reuseInterpreter(key2, throttleInterval, onChange) {
|
|
437887
|
+
if (!connectionCache.has(key2)) {
|
|
437888
|
+
const service = (0, robot3_1.interpret)(connectionStateMachine, onChange);
|
|
437889
|
+
connectionCache.set(key2, {
|
|
437890
|
+
service,
|
|
437891
|
+
throttledSend: throttleInterval > 0 ? (0, utils_1.throttle)(service.send, throttleInterval, true) : service.send
|
|
437892
|
+
});
|
|
437893
|
+
}
|
|
437894
|
+
return connectionCache.get(key2);
|
|
437895
|
+
}
|
|
437896
|
+
var noop3 = () => {
|
|
437897
|
+
};
|
|
437898
|
+
var NoOpConnection = {
|
|
437899
|
+
send: noop3,
|
|
437900
|
+
close: noop3
|
|
437901
|
+
};
|
|
437902
|
+
function isSuccessfulResult(data) {
|
|
437903
|
+
return data.status !== "error" && data.type !== "x-fal-message" && !isFalErrorResult(data);
|
|
437904
|
+
}
|
|
437905
|
+
function isFalErrorResult(data) {
|
|
437906
|
+
return data.type === "x-fal-error";
|
|
437907
|
+
}
|
|
437908
|
+
function decodeRealtimeMessage(data) {
|
|
437909
|
+
return __awaiter4(this, void 0, void 0, function* () {
|
|
437910
|
+
if (typeof data === "string") {
|
|
437911
|
+
return JSON.parse(data);
|
|
437912
|
+
}
|
|
437913
|
+
const toUint8Array = (value) => __awaiter4(this, void 0, void 0, function* () {
|
|
437914
|
+
if (value instanceof Uint8Array) {
|
|
437915
|
+
return value;
|
|
437916
|
+
}
|
|
437917
|
+
if (value instanceof Blob) {
|
|
437918
|
+
return new Uint8Array(yield value.arrayBuffer());
|
|
437919
|
+
}
|
|
437920
|
+
return new Uint8Array(value);
|
|
437921
|
+
});
|
|
437922
|
+
if (data instanceof ArrayBuffer || data instanceof Uint8Array) {
|
|
437923
|
+
return (0, msgpack_1.decode)(yield toUint8Array(data));
|
|
437924
|
+
}
|
|
437925
|
+
if (data instanceof Blob) {
|
|
437926
|
+
return (0, msgpack_1.decode)(yield toUint8Array(data));
|
|
437927
|
+
}
|
|
437928
|
+
return data;
|
|
437929
|
+
});
|
|
437930
|
+
}
|
|
437931
|
+
function encodeRealtimeMessage(input3) {
|
|
437932
|
+
if (input3 instanceof Uint8Array) {
|
|
437933
|
+
return input3;
|
|
437934
|
+
}
|
|
437935
|
+
if (typeof input3 === "string") {
|
|
437936
|
+
return (0, msgpack_1.encode)(input3);
|
|
437937
|
+
}
|
|
437938
|
+
return (0, msgpack_1.encode)(input3);
|
|
437939
|
+
}
|
|
437940
|
+
function handleRealtimeMessage({ data, decodeMessage, onResult, onError, send }) {
|
|
437941
|
+
const handleDecoded = (decoded) => {
|
|
437942
|
+
if (isUnauthorizedError(decoded)) {
|
|
437943
|
+
send({
|
|
437944
|
+
type: "unauthorized",
|
|
437945
|
+
error: new Error("Unauthorized")
|
|
437946
|
+
});
|
|
437947
|
+
return;
|
|
437948
|
+
}
|
|
437949
|
+
if (isSuccessfulResult(decoded)) {
|
|
437950
|
+
onResult(decoded);
|
|
437951
|
+
return;
|
|
437952
|
+
}
|
|
437953
|
+
if (isFalErrorResult(decoded)) {
|
|
437954
|
+
if (decoded.error === "TIMEOUT") {
|
|
437955
|
+
return;
|
|
437956
|
+
}
|
|
437957
|
+
onError(new response_1.ApiError({
|
|
437958
|
+
message: `${decoded.error}: ${decoded.reason}`,
|
|
437959
|
+
// TODO better error status code
|
|
437960
|
+
status: 400,
|
|
437961
|
+
body: decoded
|
|
437962
|
+
}));
|
|
437963
|
+
return;
|
|
437964
|
+
}
|
|
437965
|
+
};
|
|
437966
|
+
Promise.resolve(decodeMessage ? decodeMessage(data) : data).then(handleDecoded).catch((error) => {
|
|
437967
|
+
var _a7;
|
|
437968
|
+
onError(new response_1.ApiError({
|
|
437969
|
+
message: (_a7 = error === null || error === void 0 ? void 0 : error.message) !== null && _a7 !== void 0 ? _a7 : "Failed to decode realtime message",
|
|
437970
|
+
status: 400
|
|
437971
|
+
}));
|
|
437972
|
+
});
|
|
437973
|
+
}
|
|
437974
|
+
function createRealtimeClient({ config: config4 }) {
|
|
437975
|
+
return {
|
|
437976
|
+
connect(app, handler4) {
|
|
437977
|
+
const {
|
|
437978
|
+
// if running on React in the server, set clientOnly to true by default
|
|
437979
|
+
clientOnly = (0, utils_1.isReact)() && !(0, runtime_1.isBrowser)(),
|
|
437980
|
+
connectionKey = crypto.randomUUID(),
|
|
437981
|
+
maxBuffering,
|
|
437982
|
+
path: path14,
|
|
437983
|
+
throttleInterval = DEFAULT_THROTTLE_INTERVAL,
|
|
437984
|
+
encodeMessage: encodeMessageOverride,
|
|
437985
|
+
decodeMessage: decodeMessageOverride,
|
|
437986
|
+
tokenProvider,
|
|
437987
|
+
tokenExpirationSeconds
|
|
437988
|
+
} = handler4;
|
|
437989
|
+
if (clientOnly && !(0, runtime_1.isBrowser)()) {
|
|
437990
|
+
return NoOpConnection;
|
|
437991
|
+
}
|
|
437992
|
+
const encodeMessageFn = encodeMessageOverride !== null && encodeMessageOverride !== void 0 ? encodeMessageOverride : ((input3) => encodeRealtimeMessage(input3));
|
|
437993
|
+
const decodeMessageFn = decodeMessageOverride !== null && decodeMessageOverride !== void 0 ? decodeMessageOverride : ((data) => decodeRealtimeMessage(data));
|
|
437994
|
+
let previousState;
|
|
437995
|
+
let latestEnqueuedMessage;
|
|
437996
|
+
let tokenRefreshTimer;
|
|
437997
|
+
let tokenRefreshGeneration = 0;
|
|
437998
|
+
connectionCallbacks.set(connectionKey, {
|
|
437999
|
+
decodeMessage: decodeMessageFn,
|
|
438000
|
+
onError: handler4.onError,
|
|
438001
|
+
onResult: handler4.onResult
|
|
438002
|
+
});
|
|
438003
|
+
const getCallbacks = () => connectionCallbacks.get(connectionKey);
|
|
438004
|
+
const stateMachine = reuseInterpreter(connectionKey, throttleInterval, ({ context: context3, machine, send: send2 }) => {
|
|
438005
|
+
var _a7;
|
|
438006
|
+
const { enqueuedMessage, token, websocket } = context3;
|
|
438007
|
+
latestEnqueuedMessage = enqueuedMessage;
|
|
438008
|
+
if (machine.current === "active" && enqueuedMessage && (websocket === null || websocket === void 0 ? void 0 : websocket.readyState) === WebSocket.OPEN) {
|
|
438009
|
+
send2({ type: "send", message: enqueuedMessage });
|
|
438010
|
+
}
|
|
438011
|
+
if (machine.current === "authRequired" && token === void 0 && previousState !== machine.current) {
|
|
438012
|
+
send2({ type: "initiateAuth" });
|
|
438013
|
+
tokenRefreshGeneration++;
|
|
438014
|
+
const generation = tokenRefreshGeneration;
|
|
438015
|
+
const appId = (0, utils_1.ensureEndpointIdFormat)(app);
|
|
438016
|
+
const resolvedPath = (_a7 = (0, utils_1.resolveEndpointPath)(app, path14, "/realtime")) !== null && _a7 !== void 0 ? _a7 : "";
|
|
438017
|
+
const fetchToken = tokenProvider ? () => tokenProvider(`${appId}${resolvedPath}`) : () => {
|
|
438018
|
+
console.warn("[fal.realtime] Using the default token provider is deprecated. Please provide a `tokenProvider` function to `fal.realtime.connect()`. See https://docs.fal.ai/model-apis/client#client-side-usage-with-token-provider for more information.");
|
|
438019
|
+
return (0, auth_1.getTemporaryAuthToken)(app, config4);
|
|
438020
|
+
};
|
|
438021
|
+
const effectiveExpiration = tokenProvider ? tokenExpirationSeconds : auth_1.TOKEN_EXPIRATION_SECONDS;
|
|
438022
|
+
const scheduleTokenRefresh = effectiveExpiration !== void 0 ? () => {
|
|
438023
|
+
clearTimeout(tokenRefreshTimer);
|
|
438024
|
+
const refreshMs = Math.round(effectiveExpiration * 0.9 * 1e3);
|
|
438025
|
+
tokenRefreshTimer = setTimeout(() => {
|
|
438026
|
+
if (generation !== tokenRefreshGeneration) {
|
|
438027
|
+
return;
|
|
438028
|
+
}
|
|
438029
|
+
fetchToken().then((newToken) => {
|
|
438030
|
+
if (generation !== tokenRefreshGeneration) {
|
|
438031
|
+
return;
|
|
438032
|
+
}
|
|
438033
|
+
queueMicrotask(() => {
|
|
438034
|
+
send2({ type: "authenticated", token: newToken });
|
|
438035
|
+
});
|
|
438036
|
+
scheduleTokenRefresh();
|
|
438037
|
+
}).catch(() => {
|
|
438038
|
+
if (generation !== tokenRefreshGeneration) {
|
|
438039
|
+
return;
|
|
438040
|
+
}
|
|
438041
|
+
const retryMs = Math.round(effectiveExpiration * 0.05 * 1e3);
|
|
438042
|
+
tokenRefreshTimer = setTimeout(() => {
|
|
438043
|
+
scheduleTokenRefresh();
|
|
438044
|
+
}, retryMs);
|
|
438045
|
+
});
|
|
438046
|
+
}, refreshMs);
|
|
438047
|
+
} : noop3;
|
|
438048
|
+
fetchToken().then((token2) => {
|
|
438049
|
+
queueMicrotask(() => {
|
|
438050
|
+
send2({ type: "authenticated", token: token2 });
|
|
438051
|
+
});
|
|
438052
|
+
scheduleTokenRefresh();
|
|
438053
|
+
}).catch((error) => {
|
|
438054
|
+
queueMicrotask(() => {
|
|
438055
|
+
send2({ type: "unauthorized", error });
|
|
438056
|
+
});
|
|
438057
|
+
});
|
|
438058
|
+
}
|
|
438059
|
+
if (machine.current === "connecting" && previousState !== machine.current && token !== void 0) {
|
|
438060
|
+
const ws = new WebSocket(buildRealtimeUrl(app, { token, maxBuffering, path: path14 }));
|
|
438061
|
+
ws.onopen = () => {
|
|
438062
|
+
var _a8, _b3;
|
|
438063
|
+
send2({ type: "connected", websocket: ws });
|
|
438064
|
+
const queued = (_b3 = (_a8 = stateMachine.service.context) === null || _a8 === void 0 ? void 0 : _a8.enqueuedMessage) !== null && _b3 !== void 0 ? _b3 : latestEnqueuedMessage;
|
|
438065
|
+
if (queued) {
|
|
438066
|
+
ws.send(encodeMessageFn(queued));
|
|
438067
|
+
stateMachine.service.context = Object.assign(Object.assign({}, stateMachine.service.context), { enqueuedMessage: void 0 });
|
|
438068
|
+
}
|
|
438069
|
+
};
|
|
438070
|
+
ws.onclose = (event) => {
|
|
438071
|
+
if (event.code !== WebSocketErrorCodes.NORMAL_CLOSURE) {
|
|
438072
|
+
const { onError = noop3 } = getCallbacks();
|
|
438073
|
+
onError(new response_1.ApiError({
|
|
438074
|
+
message: `Error closing the connection: ${event.reason}`,
|
|
438075
|
+
status: event.code
|
|
438076
|
+
}));
|
|
438077
|
+
}
|
|
438078
|
+
send2({ type: "connectionClosed", code: event.code });
|
|
438079
|
+
};
|
|
438080
|
+
ws.onerror = (event) => {
|
|
438081
|
+
const { onError = noop3 } = getCallbacks();
|
|
438082
|
+
onError(new response_1.ApiError({ message: "Unknown error", status: 500 }));
|
|
438083
|
+
};
|
|
438084
|
+
ws.onmessage = (event) => {
|
|
438085
|
+
const { decodeMessage = decodeMessageFn, onResult, onError = noop3 } = getCallbacks();
|
|
438086
|
+
handleRealtimeMessage({
|
|
438087
|
+
data: event.data,
|
|
438088
|
+
decodeMessage,
|
|
438089
|
+
onResult,
|
|
438090
|
+
onError,
|
|
438091
|
+
send: send2
|
|
438092
|
+
});
|
|
438093
|
+
};
|
|
438094
|
+
}
|
|
438095
|
+
if (previousState === "active" && machine.current !== "active") {
|
|
438096
|
+
clearTimeout(tokenRefreshTimer);
|
|
438097
|
+
tokenRefreshTimer = void 0;
|
|
438098
|
+
}
|
|
438099
|
+
previousState = machine.current;
|
|
438100
|
+
});
|
|
438101
|
+
const send = (input3) => {
|
|
438102
|
+
stateMachine.throttledSend({
|
|
438103
|
+
type: "send",
|
|
438104
|
+
message: encodeMessageFn(input3)
|
|
438105
|
+
});
|
|
438106
|
+
};
|
|
438107
|
+
const close = () => {
|
|
438108
|
+
stateMachine.service.send({ type: "close" });
|
|
438109
|
+
};
|
|
438110
|
+
return {
|
|
438111
|
+
send,
|
|
438112
|
+
close
|
|
438113
|
+
};
|
|
438114
|
+
}
|
|
438115
|
+
};
|
|
438116
|
+
}
|
|
438117
|
+
}
|
|
438118
|
+
});
|
|
438119
|
+
|
|
438120
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/client.js
|
|
438121
|
+
var require_client = __commonJS({
|
|
438122
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/client.js"(exports) {
|
|
438123
|
+
"use strict";
|
|
438124
|
+
var __awaiter4 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
438125
|
+
function adopt(value) {
|
|
438126
|
+
return value instanceof P ? value : new P(function(resolve44) {
|
|
438127
|
+
resolve44(value);
|
|
438128
|
+
});
|
|
438129
|
+
}
|
|
438130
|
+
return new (P || (P = Promise))(function(resolve44, reject) {
|
|
438131
|
+
function fulfilled(value) {
|
|
438132
|
+
try {
|
|
438133
|
+
step(generator.next(value));
|
|
438134
|
+
} catch (e) {
|
|
438135
|
+
reject(e);
|
|
438136
|
+
}
|
|
438137
|
+
}
|
|
438138
|
+
function rejected(value) {
|
|
438139
|
+
try {
|
|
438140
|
+
step(generator["throw"](value));
|
|
438141
|
+
} catch (e) {
|
|
438142
|
+
reject(e);
|
|
438143
|
+
}
|
|
438144
|
+
}
|
|
438145
|
+
function step(result) {
|
|
438146
|
+
result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
438147
|
+
}
|
|
438148
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
438149
|
+
});
|
|
438150
|
+
};
|
|
438151
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
438152
|
+
exports.createFalClient = createFalClient2;
|
|
438153
|
+
var config_1 = require_config();
|
|
438154
|
+
var headers_1 = require_headers3();
|
|
438155
|
+
var queue_1 = require_queue();
|
|
438156
|
+
var realtime_1 = require_realtime();
|
|
438157
|
+
var request_1 = require_request();
|
|
438158
|
+
var response_1 = require_response();
|
|
438159
|
+
var storage_1 = require_storage();
|
|
438160
|
+
var streaming_1 = require_streaming();
|
|
438161
|
+
function createFalClient2(userConfig = {}) {
|
|
438162
|
+
const config4 = (0, config_1.createConfig)(userConfig);
|
|
438163
|
+
const storage = (0, storage_1.createStorageClient)({ config: config4 });
|
|
438164
|
+
const queue = (0, queue_1.createQueueClient)({ config: config4, storage });
|
|
438165
|
+
const streaming = (0, streaming_1.createStreamingClient)({ config: config4, storage });
|
|
438166
|
+
const realtime = (0, realtime_1.createRealtimeClient)({ config: config4 });
|
|
438167
|
+
return {
|
|
438168
|
+
queue,
|
|
438169
|
+
realtime,
|
|
438170
|
+
storage,
|
|
438171
|
+
streaming,
|
|
438172
|
+
stream: streaming.stream,
|
|
438173
|
+
run(endpointId_1) {
|
|
438174
|
+
return __awaiter4(this, arguments, void 0, function* (endpointId, options = {}) {
|
|
438175
|
+
const input3 = options.input ? yield storage.transformInput(options.input) : void 0;
|
|
438176
|
+
return (0, request_1.dispatchRequest)({
|
|
438177
|
+
method: options.method,
|
|
438178
|
+
targetUrl: (0, request_1.buildUrl)(endpointId, options),
|
|
438179
|
+
input: input3,
|
|
438180
|
+
// TODO: consider supporting custom headers in fal.run() as well
|
|
438181
|
+
headers: Object.assign(Object.assign({}, (0, storage_1.buildObjectLifecycleHeaders)(options.storageSettings)), (0, headers_1.buildTimeoutHeaders)(options.startTimeout)),
|
|
438182
|
+
config: Object.assign(Object.assign({}, config4), { responseHandler: response_1.resultResponseHandler }),
|
|
438183
|
+
options: {
|
|
438184
|
+
signal: options.abortSignal,
|
|
438185
|
+
retry: {
|
|
438186
|
+
maxRetries: 3,
|
|
438187
|
+
baseDelay: 500,
|
|
438188
|
+
maxDelay: 15e3
|
|
438189
|
+
}
|
|
438190
|
+
}
|
|
438191
|
+
});
|
|
438192
|
+
});
|
|
438193
|
+
},
|
|
438194
|
+
subscribe: (endpointId, options) => __awaiter4(this, void 0, void 0, function* () {
|
|
438195
|
+
const { request_id: requestId } = yield queue.submit(endpointId, options);
|
|
438196
|
+
if (options.onEnqueue) {
|
|
438197
|
+
options.onEnqueue(requestId);
|
|
438198
|
+
}
|
|
438199
|
+
yield queue.subscribeToStatus(endpointId, Object.assign({ requestId }, options));
|
|
438200
|
+
return queue.result(endpointId, { requestId });
|
|
438201
|
+
})
|
|
438202
|
+
};
|
|
438203
|
+
}
|
|
438204
|
+
}
|
|
438205
|
+
});
|
|
438206
|
+
|
|
438207
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/types/common.js
|
|
438208
|
+
var require_common6 = __commonJS({
|
|
438209
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/types/common.js"(exports) {
|
|
438210
|
+
"use strict";
|
|
438211
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
438212
|
+
exports.isQueueStatus = isQueueStatus;
|
|
438213
|
+
exports.isCompletedQueueStatus = isCompletedQueueStatus;
|
|
438214
|
+
function isQueueStatus(obj) {
|
|
438215
|
+
return obj && obj.status && obj.response_url;
|
|
438216
|
+
}
|
|
438217
|
+
function isCompletedQueueStatus(obj) {
|
|
438218
|
+
return isQueueStatus(obj) && obj.status === "COMPLETED";
|
|
438219
|
+
}
|
|
438220
|
+
}
|
|
438221
|
+
});
|
|
438222
|
+
|
|
438223
|
+
// ../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/index.js
|
|
438224
|
+
var require_src3 = __commonJS({
|
|
438225
|
+
"../../node_modules/.pnpm/@fal-ai+client@1.10.0/node_modules/@fal-ai/client/src/index.js"(exports) {
|
|
438226
|
+
"use strict";
|
|
438227
|
+
var __createBinding3 = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
438228
|
+
if (k2 === void 0) k2 = k;
|
|
438229
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
438230
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
438231
|
+
desc = { enumerable: true, get: function() {
|
|
438232
|
+
return m[k];
|
|
438233
|
+
} };
|
|
438234
|
+
}
|
|
438235
|
+
Object.defineProperty(o, k2, desc);
|
|
438236
|
+
}) : (function(o, m, k, k2) {
|
|
438237
|
+
if (k2 === void 0) k2 = k;
|
|
438238
|
+
o[k2] = m[k];
|
|
438239
|
+
}));
|
|
438240
|
+
var __exportStar3 = exports && exports.__exportStar || function(m, exports2) {
|
|
438241
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding3(exports2, m, p);
|
|
438242
|
+
};
|
|
438243
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
438244
|
+
exports.fal = exports.parseEndpointId = exports.isRetryableError = exports.ValidationError = exports.ApiError = exports.withProxy = exports.withMiddleware = exports.createFalClient = void 0;
|
|
438245
|
+
var client_1 = require_client();
|
|
438246
|
+
var client_2 = require_client();
|
|
438247
|
+
Object.defineProperty(exports, "createFalClient", { enumerable: true, get: function() {
|
|
438248
|
+
return client_2.createFalClient;
|
|
438249
|
+
} });
|
|
438250
|
+
var middleware_1 = require_middleware();
|
|
438251
|
+
Object.defineProperty(exports, "withMiddleware", { enumerable: true, get: function() {
|
|
438252
|
+
return middleware_1.withMiddleware;
|
|
438253
|
+
} });
|
|
438254
|
+
Object.defineProperty(exports, "withProxy", { enumerable: true, get: function() {
|
|
438255
|
+
return middleware_1.withProxy;
|
|
438256
|
+
} });
|
|
438257
|
+
var response_1 = require_response();
|
|
438258
|
+
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function() {
|
|
438259
|
+
return response_1.ApiError;
|
|
438260
|
+
} });
|
|
438261
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
|
|
438262
|
+
return response_1.ValidationError;
|
|
438263
|
+
} });
|
|
438264
|
+
var retry_1 = require_retry();
|
|
438265
|
+
Object.defineProperty(exports, "isRetryableError", { enumerable: true, get: function() {
|
|
438266
|
+
return retry_1.isRetryableError;
|
|
438267
|
+
} });
|
|
438268
|
+
__exportStar3(require_common6(), exports);
|
|
438269
|
+
var utils_1 = require_utils4();
|
|
438270
|
+
Object.defineProperty(exports, "parseEndpointId", { enumerable: true, get: function() {
|
|
438271
|
+
return utils_1.parseEndpointId;
|
|
438272
|
+
} });
|
|
438273
|
+
exports.fal = (function createSingletonFalClient() {
|
|
438274
|
+
let currentInstance = (0, client_1.createFalClient)();
|
|
438275
|
+
return {
|
|
438276
|
+
config(config4) {
|
|
438277
|
+
currentInstance = (0, client_1.createFalClient)(config4);
|
|
438278
|
+
},
|
|
438279
|
+
get queue() {
|
|
438280
|
+
return currentInstance.queue;
|
|
438281
|
+
},
|
|
438282
|
+
get realtime() {
|
|
438283
|
+
return currentInstance.realtime;
|
|
438284
|
+
},
|
|
438285
|
+
get storage() {
|
|
438286
|
+
return currentInstance.storage;
|
|
438287
|
+
},
|
|
438288
|
+
get streaming() {
|
|
438289
|
+
return currentInstance.streaming;
|
|
438290
|
+
},
|
|
438291
|
+
run(id, options) {
|
|
438292
|
+
return currentInstance.run(id, options);
|
|
438293
|
+
},
|
|
438294
|
+
subscribe(endpointId, options) {
|
|
438295
|
+
return currentInstance.subscribe(endpointId, options);
|
|
438296
|
+
},
|
|
438297
|
+
stream(endpointId, options) {
|
|
438298
|
+
return currentInstance.stream(endpointId, options);
|
|
438299
|
+
}
|
|
438300
|
+
};
|
|
438301
|
+
})();
|
|
438302
|
+
}
|
|
438303
|
+
});
|
|
438304
|
+
|
|
438305
|
+
// ../ai-providers/dist/fal/FalProvider.js
|
|
438306
|
+
function pickReferenceImageUrl(input3) {
|
|
438307
|
+
if (typeof input3 !== "string")
|
|
438308
|
+
return void 0;
|
|
438309
|
+
if (input3.startsWith("http://") || input3.startsWith("https://"))
|
|
438310
|
+
return input3;
|
|
438311
|
+
return void 0;
|
|
438312
|
+
}
|
|
438313
|
+
function normaliseAspect(value) {
|
|
438314
|
+
if (!value)
|
|
438315
|
+
return "auto";
|
|
438316
|
+
return VALID_ASPECTS.includes(value) ? value : "auto";
|
|
438317
|
+
}
|
|
438318
|
+
function normaliseResolution(value) {
|
|
438319
|
+
if (!value)
|
|
438320
|
+
return "720p";
|
|
438321
|
+
if (VALID_RESOLUTIONS.includes(value)) {
|
|
438322
|
+
return value;
|
|
438323
|
+
}
|
|
438324
|
+
if (value === "4k")
|
|
438325
|
+
return "1080p";
|
|
438326
|
+
return "720p";
|
|
438327
|
+
}
|
|
438328
|
+
function normaliseDuration(value) {
|
|
438329
|
+
if (typeof value !== "number")
|
|
438330
|
+
return "auto";
|
|
438331
|
+
if (!Number.isFinite(value))
|
|
438332
|
+
return "auto";
|
|
438333
|
+
return Math.max(4, Math.min(15, Math.round(value)));
|
|
438334
|
+
}
|
|
438335
|
+
var import_client, ENDPOINT_TEXT_TO_VIDEO, ENDPOINT_IMAGE_TO_VIDEO, DEFAULT_VARIANT, VALID_RESOLUTIONS, VALID_ASPECTS, FalProvider, falProvider;
|
|
438336
|
+
var init_FalProvider = __esm({
|
|
438337
|
+
"../ai-providers/dist/fal/FalProvider.js"() {
|
|
438338
|
+
"use strict";
|
|
438339
|
+
import_client = __toESM(require_src3(), 1);
|
|
438340
|
+
ENDPOINT_TEXT_TO_VIDEO = {
|
|
438341
|
+
"seedance-2.0": "bytedance/seedance-2.0/text-to-video",
|
|
438342
|
+
"seedance-2.0-fast": "bytedance/seedance-2.0/fast/text-to-video"
|
|
438343
|
+
};
|
|
438344
|
+
ENDPOINT_IMAGE_TO_VIDEO = {
|
|
438345
|
+
"seedance-2.0": "bytedance/seedance-2.0/image-to-video",
|
|
438346
|
+
"seedance-2.0-fast": "bytedance/seedance-2.0/fast/image-to-video"
|
|
438347
|
+
};
|
|
438348
|
+
DEFAULT_VARIANT = "seedance-2.0";
|
|
438349
|
+
VALID_RESOLUTIONS = ["480p", "720p", "1080p"];
|
|
438350
|
+
VALID_ASPECTS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16", "auto"];
|
|
438351
|
+
FalProvider = class {
|
|
438352
|
+
constructor() {
|
|
438353
|
+
this.id = "fal";
|
|
438354
|
+
this.name = "fal.ai (Seedance 2.0)";
|
|
438355
|
+
this.description = "fal.ai hosting ByteDance Seedance 2.0 \u2014 Artificial Analysis #2 on both text-to-video and image-to-video leaderboards";
|
|
438356
|
+
this.capabilities = ["text-to-video", "image-to-video"];
|
|
438357
|
+
this.iconUrl = "/icons/fal.svg";
|
|
438358
|
+
this.isAvailable = true;
|
|
438359
|
+
}
|
|
438360
|
+
async initialize(config4) {
|
|
438361
|
+
this.apiKey = config4.apiKey;
|
|
438362
|
+
if (!this.apiKey)
|
|
438363
|
+
return;
|
|
438364
|
+
this.client = (0, import_client.createFalClient)({ credentials: this.apiKey });
|
|
438365
|
+
}
|
|
438366
|
+
isConfigured() {
|
|
438367
|
+
return !!this.apiKey && !!this.client;
|
|
438368
|
+
}
|
|
438369
|
+
/**
|
|
438370
|
+
* Generate a video from a text prompt — or from a reference image when
|
|
438371
|
+
* `options.referenceImage` is set (treated as an image-to-video
|
|
438372
|
+
* request, routed to a different endpoint).
|
|
438373
|
+
*
|
|
438374
|
+
* fal.subscribe blocks until the final result is available. It also
|
|
438375
|
+
* surfaces queue / log events through `onQueueUpdate`, which we drop
|
|
438376
|
+
* silently for now — the CLI's existing spinner is the user-facing
|
|
438377
|
+
* progress UI.
|
|
438378
|
+
*/
|
|
438379
|
+
async generateVideo(prompt3, options) {
|
|
438380
|
+
if (!this.client) {
|
|
438381
|
+
return {
|
|
438382
|
+
id: "",
|
|
438383
|
+
status: "failed",
|
|
438384
|
+
error: "fal.ai API key not configured. Set FAL_KEY in .env."
|
|
438385
|
+
};
|
|
438386
|
+
}
|
|
438387
|
+
const variant = options?.model ?? DEFAULT_VARIANT;
|
|
438388
|
+
if (!Object.hasOwn(ENDPOINT_TEXT_TO_VIDEO, variant)) {
|
|
438389
|
+
return {
|
|
438390
|
+
id: "",
|
|
438391
|
+
status: "failed",
|
|
438392
|
+
error: `Unknown Seedance variant: ${variant}. Valid: ${Object.keys(ENDPOINT_TEXT_TO_VIDEO).join(", ")}.`
|
|
438393
|
+
};
|
|
438394
|
+
}
|
|
438395
|
+
const referenceImage = pickReferenceImageUrl(options?.referenceImage);
|
|
438396
|
+
const isImageToVideo = !!referenceImage;
|
|
438397
|
+
const endpointId = isImageToVideo ? ENDPOINT_IMAGE_TO_VIDEO[variant] : ENDPOINT_TEXT_TO_VIDEO[variant];
|
|
438398
|
+
const aspect = normaliseAspect(options?.aspectRatio);
|
|
438399
|
+
const resolution = normaliseResolution(options?.resolution);
|
|
438400
|
+
const duration = normaliseDuration(options?.duration);
|
|
438401
|
+
const input3 = {
|
|
438402
|
+
prompt: prompt3,
|
|
438403
|
+
aspect_ratio: aspect,
|
|
438404
|
+
resolution,
|
|
438405
|
+
duration
|
|
438406
|
+
};
|
|
438407
|
+
if (referenceImage)
|
|
438408
|
+
input3.image_url = referenceImage;
|
|
438409
|
+
if (options?.negativePrompt)
|
|
438410
|
+
input3.negative_prompt = options.negativePrompt;
|
|
438411
|
+
if (typeof options?.seed === "number")
|
|
438412
|
+
input3.seed = options.seed;
|
|
438413
|
+
if (options?.lastFrame)
|
|
438414
|
+
input3.end_image_url = options.lastFrame;
|
|
438415
|
+
try {
|
|
438416
|
+
const out = await this.client.subscribe(endpointId, { input: input3, logs: false });
|
|
438417
|
+
const data = out?.data ?? {};
|
|
438418
|
+
const url = data.video?.url;
|
|
438419
|
+
if (!url) {
|
|
438420
|
+
return {
|
|
438421
|
+
id: typeof out?.requestId === "string" ? out.requestId : "",
|
|
438422
|
+
status: "failed",
|
|
438423
|
+
error: "fal.subscribe returned without a video URL"
|
|
438424
|
+
};
|
|
438425
|
+
}
|
|
438426
|
+
return {
|
|
438427
|
+
id: typeof out?.requestId === "string" ? out.requestId : "",
|
|
438428
|
+
status: "completed",
|
|
438429
|
+
videoUrl: url,
|
|
438430
|
+
progress: 100
|
|
438431
|
+
};
|
|
438432
|
+
} catch (err) {
|
|
438433
|
+
return {
|
|
438434
|
+
id: "",
|
|
438435
|
+
status: "failed",
|
|
438436
|
+
error: err instanceof Error ? err.message : String(err)
|
|
438437
|
+
};
|
|
438438
|
+
}
|
|
438439
|
+
}
|
|
438440
|
+
};
|
|
438441
|
+
falProvider = new FalProvider();
|
|
438442
|
+
}
|
|
438443
|
+
});
|
|
438444
|
+
|
|
438445
|
+
// ../ai-providers/dist/fal/index.js
|
|
438446
|
+
var init_fal = __esm({
|
|
438447
|
+
"../ai-providers/dist/fal/index.js"() {
|
|
438448
|
+
"use strict";
|
|
438449
|
+
init_FalProvider();
|
|
438450
|
+
}
|
|
438451
|
+
});
|
|
438452
|
+
|
|
434191
438453
|
// ../ai-providers/dist/replicate/ReplicateProvider.js
|
|
434192
438454
|
var ReplicateProvider, replicateProvider;
|
|
434193
438455
|
var init_ReplicateProvider = __esm({
|
|
@@ -434842,6 +439104,7 @@ var dist_exports2 = {};
|
|
|
434842
439104
|
__export(dist_exports2, {
|
|
434843
439105
|
ClaudeProvider: () => ClaudeProvider,
|
|
434844
439106
|
ElevenLabsProvider: () => ElevenLabsProvider,
|
|
439107
|
+
FalProvider: () => FalProvider,
|
|
434845
439108
|
GeminiProvider: () => GeminiProvider,
|
|
434846
439109
|
GrokProvider: () => GrokProvider,
|
|
434847
439110
|
KNOWN_VOICES: () => KNOWN_VOICES,
|
|
@@ -434857,6 +439120,7 @@ __export(dist_exports2, {
|
|
|
434857
439120
|
WhisperProvider: () => WhisperProvider,
|
|
434858
439121
|
claudeProvider: () => claudeProvider,
|
|
434859
439122
|
elevenLabsProvider: () => elevenLabsProvider,
|
|
439123
|
+
falProvider: () => falProvider,
|
|
434860
439124
|
geminiProvider: () => geminiProvider,
|
|
434861
439125
|
getBestProviderForCapability: () => getBestProviderForCapability,
|
|
434862
439126
|
grokProvider: () => grokProvider,
|
|
@@ -434887,12 +439151,13 @@ var init_dist2 = __esm({
|
|
|
434887
439151
|
init_runway();
|
|
434888
439152
|
init_kling();
|
|
434889
439153
|
init_grok();
|
|
439154
|
+
init_fal();
|
|
434890
439155
|
init_replicate();
|
|
434891
439156
|
}
|
|
434892
439157
|
});
|
|
434893
439158
|
|
|
434894
439159
|
// ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
434895
|
-
var
|
|
439160
|
+
var require_package4 = __commonJS({
|
|
434896
439161
|
"../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(exports, module) {
|
|
434897
439162
|
module.exports = {
|
|
434898
439163
|
name: "dotenv",
|
|
@@ -434966,7 +439231,7 @@ var require_main4 = __commonJS({
|
|
|
434966
439231
|
var path14 = __require("path");
|
|
434967
439232
|
var os11 = __require("os");
|
|
434968
439233
|
var crypto3 = __require("crypto");
|
|
434969
|
-
var packageJson =
|
|
439234
|
+
var packageJson = require_package4();
|
|
434970
439235
|
var version = packageJson.version;
|
|
434971
439236
|
var TIPS = [
|
|
434972
439237
|
"\u{1F510} encrypt with Dotenvx: https://dotenvx.com",
|
|
@@ -437685,7 +441950,7 @@ var require_float2 = __commonJS({
|
|
|
437685
441950
|
});
|
|
437686
441951
|
|
|
437687
441952
|
// ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/int.js
|
|
437688
|
-
var
|
|
441953
|
+
var require_int3 = __commonJS({
|
|
437689
441954
|
"../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/int.js"(exports) {
|
|
437690
441955
|
"use strict";
|
|
437691
441956
|
var stringifyNumber = require_stringifyNumber();
|
|
@@ -437739,7 +442004,7 @@ var require_schema2 = __commonJS({
|
|
|
437739
442004
|
var string = require_string();
|
|
437740
442005
|
var bool = require_bool2();
|
|
437741
442006
|
var float = require_float2();
|
|
437742
|
-
var int =
|
|
442007
|
+
var int = require_int3();
|
|
437743
442008
|
var schema = [
|
|
437744
442009
|
map3.map,
|
|
437745
442010
|
seq.seq,
|
|
@@ -438128,7 +442393,7 @@ var require_float3 = __commonJS({
|
|
|
438128
442393
|
});
|
|
438129
442394
|
|
|
438130
442395
|
// ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/int.js
|
|
438131
|
-
var
|
|
442396
|
+
var require_int4 = __commonJS({
|
|
438132
442397
|
"../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports) {
|
|
438133
442398
|
"use strict";
|
|
438134
442399
|
var stringifyNumber = require_stringifyNumber();
|
|
@@ -438296,7 +442561,7 @@ var require_set2 = __commonJS({
|
|
|
438296
442561
|
});
|
|
438297
442562
|
|
|
438298
442563
|
// ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
|
|
438299
|
-
var
|
|
442564
|
+
var require_timestamp3 = __commonJS({
|
|
438300
442565
|
"../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
438301
442566
|
"use strict";
|
|
438302
442567
|
var stringifyNumber = require_stringifyNumber();
|
|
@@ -438394,12 +442659,12 @@ var require_schema4 = __commonJS({
|
|
|
438394
442659
|
var binary = require_binary2();
|
|
438395
442660
|
var bool = require_bool3();
|
|
438396
442661
|
var float = require_float3();
|
|
438397
|
-
var int =
|
|
442662
|
+
var int = require_int4();
|
|
438398
442663
|
var merge3 = require_merge3();
|
|
438399
442664
|
var omap = require_omap2();
|
|
438400
442665
|
var pairs = require_pairs2();
|
|
438401
442666
|
var set = require_set2();
|
|
438402
|
-
var timestamp =
|
|
442667
|
+
var timestamp = require_timestamp3();
|
|
438403
442668
|
var schema = [
|
|
438404
442669
|
map3.map,
|
|
438405
442670
|
seq.seq,
|
|
@@ -438437,7 +442702,7 @@ var require_tags = __commonJS({
|
|
|
438437
442702
|
var string = require_string();
|
|
438438
442703
|
var bool = require_bool2();
|
|
438439
442704
|
var float = require_float2();
|
|
438440
|
-
var int =
|
|
442705
|
+
var int = require_int3();
|
|
438441
442706
|
var schema = require_schema2();
|
|
438442
442707
|
var schema$1 = require_schema3();
|
|
438443
442708
|
var binary = require_binary2();
|
|
@@ -438446,7 +442711,7 @@ var require_tags = __commonJS({
|
|
|
438446
442711
|
var pairs = require_pairs2();
|
|
438447
442712
|
var schema$2 = require_schema4();
|
|
438448
442713
|
var set = require_set2();
|
|
438449
|
-
var timestamp =
|
|
442714
|
+
var timestamp = require_timestamp3();
|
|
438450
442715
|
var schemas = /* @__PURE__ */ new Map([
|
|
438451
442716
|
["core", schema.schema],
|
|
438452
442717
|
["failsafe", [map3.map, seq.seq, string.string]],
|
|
@@ -442526,7 +446791,7 @@ var require_public_api = __commonJS({
|
|
|
442526
446791
|
});
|
|
442527
446792
|
|
|
442528
446793
|
// ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/index.js
|
|
442529
|
-
var
|
|
446794
|
+
var require_dist16 = __commonJS({
|
|
442530
446795
|
"../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/index.js"(exports) {
|
|
442531
446796
|
"use strict";
|
|
442532
446797
|
var composer = require_composer();
|
|
@@ -442650,7 +446915,7 @@ var import_yaml, CONFIG_DIR, CONFIG_PATH;
|
|
|
442650
446915
|
var init_config = __esm({
|
|
442651
446916
|
"../cli/src/config/index.ts"() {
|
|
442652
446917
|
"use strict";
|
|
442653
|
-
import_yaml = __toESM(
|
|
446918
|
+
import_yaml = __toESM(require_dist16(), 1);
|
|
442654
446919
|
init_schema();
|
|
442655
446920
|
init_schema();
|
|
442656
446921
|
CONFIG_DIR = resolve14(homedir4(), ".vibeframe");
|
|
@@ -446388,7 +450653,7 @@ var import_yaml2, ASPECT_DIMS;
|
|
|
446388
450653
|
var init_scene_project = __esm({
|
|
446389
450654
|
"../cli/src/commands/_shared/scene-project.ts"() {
|
|
446390
450655
|
"use strict";
|
|
446391
|
-
import_yaml2 = __toESM(
|
|
450656
|
+
import_yaml2 = __toESM(require_dist16(), 1);
|
|
446392
450657
|
ASPECT_DIMS = {
|
|
446393
450658
|
"16:9": { width: 1920, height: 1080 },
|
|
446394
450659
|
"9:16": { width: 1080, height: 1920 },
|
|
@@ -446459,9 +450724,7 @@ function buildPreset(input3) {
|
|
|
446459
450724
|
const captionInner = useWordSync ? renderTranscriptSpans(transcript) : esc(captionText);
|
|
446460
450725
|
const wordCss = useWordSync ? `
|
|
446461
450726
|
${scope} .caption .word { display: inline-block; opacity: 0; }` : "";
|
|
446462
|
-
const timeline = useWordSync ?
|
|
446463
|
-
tl.to('${scope} .caption', { opacity: 0, duration: 0.4, ease: 'power2.in' }, ${(dur - 0.4).toFixed(2)});` : `tl.from('${scope} .caption', { opacity: 0, y: 28, duration: 0.6, ease: 'power2.out' }, 0.1);
|
|
446464
|
-
tl.to('${scope} .caption', { opacity: 0, duration: 0.4, ease: 'power2.in' }, ${(dur - 0.4).toFixed(2)});`;
|
|
450727
|
+
const timeline = useWordSync ? buildTranscriptTweens(transcript, `${scope} .caption .word`) : `tl.from('${scope} .caption', { opacity: 0, y: 28, duration: 0.45, ease: 'power3.out' }, 0.05);`;
|
|
446465
450728
|
return {
|
|
446466
450729
|
css: `${scope} {
|
|
446467
450730
|
position: absolute; inset: 0; width: 100%; height: 100%;
|
|
@@ -446509,8 +450772,11 @@ function buildPreset(input3) {
|
|
|
446509
450772
|
}`,
|
|
446510
450773
|
body: `${backdropMarkup}
|
|
446511
450774
|
<div class="announce"><h1 id="headline">${esc(headline)}</h1></div>`,
|
|
446512
|
-
|
|
446513
|
-
|
|
450775
|
+
// Faster, snappier entrance and no tail fade-out — see the
|
|
450776
|
+
// matching note in the `simple` case above. The headline stays
|
|
450777
|
+
// on screen until the producer cuts to the next clip; the next
|
|
450778
|
+
// scene's own fade-in handles the visual transition.
|
|
450779
|
+
timeline: `tl.from('${scope} #headline', { opacity: 0, scale: 0.92, duration: 0.55, ease: 'power3.out' }, 0.05);`
|
|
446514
450780
|
};
|
|
446515
450781
|
}
|
|
446516
450782
|
case "explainer": {
|
|
@@ -448328,7 +452594,7 @@ var import_yaml3, DEFAULT_VIDEO_RETRIES, RETRY_DELAY_MS;
|
|
|
448328
452594
|
var init_ai_script_pipeline = __esm({
|
|
448329
452595
|
"../cli/src/commands/ai-script-pipeline.ts"() {
|
|
448330
452596
|
"use strict";
|
|
448331
|
-
import_yaml3 = __toESM(
|
|
452597
|
+
import_yaml3 = __toESM(require_dist16(), 1);
|
|
448332
452598
|
init_source();
|
|
448333
452599
|
init_dist2();
|
|
448334
452600
|
init_api_key();
|
|
@@ -450360,11 +454626,12 @@ var init_provider_resolver = __esm({
|
|
|
450360
454626
|
"use strict";
|
|
450361
454627
|
init_api_key();
|
|
450362
454628
|
IMAGE_PROVIDERS = [
|
|
450363
|
-
{ name: "gemini", envVar: "GOOGLE_API_KEY", label: "Gemini" },
|
|
450364
454629
|
{ name: "openai", envVar: "OPENAI_API_KEY", label: "OpenAI" },
|
|
454630
|
+
{ name: "gemini", envVar: "GOOGLE_API_KEY", label: "Gemini" },
|
|
450365
454631
|
{ name: "grok", envVar: "XAI_API_KEY", label: "Grok" }
|
|
450366
454632
|
];
|
|
450367
454633
|
VIDEO_PROVIDERS = [
|
|
454634
|
+
{ name: "fal", envVar: "FAL_KEY", label: "fal.ai (Seedance 2.0)" },
|
|
450368
454635
|
{ name: "grok", envVar: "XAI_API_KEY", label: "Grok" },
|
|
450369
454636
|
{ name: "veo", envVar: "GOOGLE_API_KEY", label: "Veo" },
|
|
450370
454637
|
{ name: "kling", envVar: "KLING_API_KEY", label: "Kling" },
|
|
@@ -451179,7 +455446,7 @@ Examples:
|
|
|
451179
455446
|
exitWithError(apiError(`Image generation failed: ${error.message}`));
|
|
451180
455447
|
}
|
|
451181
455448
|
});
|
|
451182
|
-
generateCommand.command("video").alias("vid").description("Generate video using AI (Kling, Runway, Veo, or Grok)").argument("[prompt]", "Text prompt describing the video (interactive if omitted)").option("-p, --provider <provider>", "Provider: grok (default), kling, runway, veo", "grok").option("-k, --api-key <key>", "API key (or set XAI_API_KEY / RUNWAY_API_SECRET / KLING_API_KEY / GOOGLE_API_KEY env)").option("-o, --output <path>", "Output file path (downloads video)").option("-i, --image <path>", "Reference image for image-to-video").option("-d, --duration <sec>", "Duration: 5 or 10 seconds", "5").option("-r, --ratio <ratio>", "Aspect ratio: 16:9, 9:16, or 1:1 (auto-detected from image if omitted)").option("-s, --seed <number>", "Random seed for reproducibility (Runway only)").option("-m, --mode <mode>", "Generation mode: std or pro (Kling only)", "std").option("-n, --negative <prompt>", "Negative prompt - what to avoid (Kling/Veo)").option("--resolution <res>", "Video resolution: 720p, 1080p, 4k (Veo only)").option("--last-frame <path>", "Last frame image for frame interpolation (Veo only)").option("--ref-images <paths...>", "Reference images for character consistency (Veo 3.1 only, max 3)").option("--person <mode>", "Person generation: allow_all, allow_adult (Veo only)").option("--veo-model <model>", "Veo model: 3.0, 3.1, 3.1-fast (default: 3.1-fast)", "3.1-fast").option("--runway-model <model>", "Runway model: gen4.5 (default, text+image-to-video), gen4_turbo (image-to-video only)", "gen4.5").option("--no-wait", "Start generation and return task ID without waiting").option("--dry-run", "Preview parameters without executing").addHelpText("after", `
|
|
455449
|
+
generateCommand.command("video").alias("vid").description("Generate video using AI (Kling, Runway, Veo, or Grok)").argument("[prompt]", "Text prompt describing the video (interactive if omitted)").option("-p, --provider <provider>", "Provider: grok (default), kling, runway, veo, fal (Seedance 2.0)", "grok").option("-k, --api-key <key>", "API key (or set XAI_API_KEY / RUNWAY_API_SECRET / KLING_API_KEY / GOOGLE_API_KEY env)").option("-o, --output <path>", "Output file path (downloads video)").option("-i, --image <path>", "Reference image for image-to-video").option("-d, --duration <sec>", "Duration: 5 or 10 seconds", "5").option("-r, --ratio <ratio>", "Aspect ratio: 16:9, 9:16, or 1:1 (auto-detected from image if omitted)").option("-s, --seed <number>", "Random seed for reproducibility (Runway only)").option("-m, --mode <mode>", "Generation mode: std or pro (Kling only)", "std").option("-n, --negative <prompt>", "Negative prompt - what to avoid (Kling/Veo)").option("--resolution <res>", "Video resolution: 720p, 1080p, 4k (Veo only)").option("--last-frame <path>", "Last frame image for frame interpolation (Veo only)").option("--ref-images <paths...>", "Reference images for character consistency (Veo 3.1 only, max 3)").option("--person <mode>", "Person generation: allow_all, allow_adult (Veo only)").option("--veo-model <model>", "Veo model: 3.0, 3.1, 3.1-fast (default: 3.1-fast)", "3.1-fast").option("--runway-model <model>", "Runway model: gen4.5 (default, text+image-to-video), gen4_turbo (image-to-video only)", "gen4.5").option("--no-wait", "Start generation and return task ID without waiting").option("--dry-run", "Preview parameters without executing").addHelpText("after", `
|
|
451183
455450
|
Examples:
|
|
451184
455451
|
$ vibe generate video "dancing cat" -o cat.mp4 # Grok (default)
|
|
451185
455452
|
$ vibe gen vid "city timelapse" -o city.mp4 -p kling # Kling
|
|
@@ -451210,7 +455477,8 @@ Examples:
|
|
|
451210
455477
|
grok: "XAI_API_KEY",
|
|
451211
455478
|
veo: "GOOGLE_API_KEY",
|
|
451212
455479
|
kling: "KLING_API_KEY",
|
|
451213
|
-
runway: "RUNWAY_API_SECRET"
|
|
455480
|
+
runway: "RUNWAY_API_SECRET",
|
|
455481
|
+
fal: "FAL_KEY"
|
|
451214
455482
|
};
|
|
451215
455483
|
if (videoEnvMap[provider] && !hasApiKey(videoEnvMap[provider]) && !options.apiKey) {
|
|
451216
455484
|
const resolved = resolveProvider("video");
|
|
@@ -451482,6 +455750,37 @@ Examples:
|
|
|
451482
455750
|
},
|
|
451483
455751
|
3e5
|
|
451484
455752
|
);
|
|
455753
|
+
} else if (provider === "fal") {
|
|
455754
|
+
const fal = new FalProvider();
|
|
455755
|
+
await fal.initialize({ apiKey });
|
|
455756
|
+
let falImage = referenceImage;
|
|
455757
|
+
if (falImage && falImage.startsWith("data:")) {
|
|
455758
|
+
spinner2.text = "Uploading image to ImgBB for fal...";
|
|
455759
|
+
const imgbbKey = await getApiKeyFromConfig("imgbb") || process.env.IMGBB_API_KEY;
|
|
455760
|
+
if (!imgbbKey) {
|
|
455761
|
+
spinner2.fail("ImgBB API key required for fal image-to-video");
|
|
455762
|
+
exitWithError(authError("IMGBB_API_KEY", "ImgBB"));
|
|
455763
|
+
}
|
|
455764
|
+
const base64Data = falImage.split(",")[1];
|
|
455765
|
+
const imageBuffer = Buffer.from(base64Data, "base64");
|
|
455766
|
+
const uploadResult = await uploadToImgbb(imageBuffer, imgbbKey);
|
|
455767
|
+
if (!uploadResult.success || !uploadResult.url) {
|
|
455768
|
+
spinner2.fail("ImgBB upload failed");
|
|
455769
|
+
exitWithError(apiError(`ImgBB upload failed: ${uploadResult.error}`, true));
|
|
455770
|
+
}
|
|
455771
|
+
falImage = uploadResult.url;
|
|
455772
|
+
}
|
|
455773
|
+
spinner2.text = "Generating video with Seedance 2.0 (this may take 1-3 minutes)...";
|
|
455774
|
+
const falModel = options.model === "fast" ? "seedance-2.0-fast" : "seedance-2.0";
|
|
455775
|
+
result = await fal.generateVideo(prompt3, {
|
|
455776
|
+
prompt: prompt3,
|
|
455777
|
+
referenceImage: falImage,
|
|
455778
|
+
duration: options.duration ? parseInt(options.duration) : void 0,
|
|
455779
|
+
aspectRatio: options.ratio,
|
|
455780
|
+
negativePrompt: options.negative,
|
|
455781
|
+
model: falModel
|
|
455782
|
+
});
|
|
455783
|
+
finalResult = result;
|
|
451485
455784
|
}
|
|
451486
455785
|
if (!finalResult || finalResult.status !== "completed") {
|
|
451487
455786
|
spinner2.fail(finalResult?.error || "Generation failed");
|
|
@@ -457660,7 +461959,7 @@ Analyze both VISUALS (expressions, actions, scene changes) and AUDIO (speech, re
|
|
|
457660
461959
|
}
|
|
457661
461960
|
|
|
457662
461961
|
// ../cli/src/pipeline/executor.ts
|
|
457663
|
-
var import_yaml4 = __toESM(
|
|
461962
|
+
var import_yaml4 = __toESM(require_dist16(), 1);
|
|
457664
461963
|
import { resolve as resolve35 } from "node:path";
|
|
457665
461964
|
import { readFile as readFile21, writeFile as writeFile22, mkdir as mkdir16 } from "node:fs/promises";
|
|
457666
461965
|
import { existsSync as existsSync34 } from "node:fs";
|
|
@@ -459513,7 +463812,7 @@ init_scene_lint();
|
|
|
459513
463812
|
import { resolve as resolve41 } from "node:path";
|
|
459514
463813
|
|
|
459515
463814
|
// ../cli/src/commands/_shared/scene-render.ts
|
|
459516
|
-
var import_yaml5 = __toESM(
|
|
463815
|
+
var import_yaml5 = __toESM(require_dist16(), 1);
|
|
459517
463816
|
init_dist();
|
|
459518
463817
|
init_chrome();
|
|
459519
463818
|
init_scene_lint();
|
|
@@ -459856,7 +464155,7 @@ async function safeStat(p) {
|
|
|
459856
464155
|
init_esm();
|
|
459857
464156
|
init_source();
|
|
459858
464157
|
init_ora();
|
|
459859
|
-
var import_yaml6 = __toESM(
|
|
464158
|
+
var import_yaml6 = __toESM(require_dist16(), 1);
|
|
459860
464159
|
init_dist2();
|
|
459861
464160
|
import { basename as basename18, resolve as resolve40, relative as relative7, dirname as dirname25 } from "node:path";
|
|
459862
464161
|
import { mkdir as mkdir19, readFile as readFile24, writeFile as writeFile25, access as access5, copyFile as copyFile4 } from "node:fs/promises";
|
|
@@ -459922,10 +464221,10 @@ init_scene_lint();
|
|
|
459922
464221
|
init_output();
|
|
459923
464222
|
init_api_key();
|
|
459924
464223
|
init_audio();
|
|
459925
|
-
var
|
|
464224
|
+
var VALID_ASPECTS2 = ["16:9", "9:16", "1:1", "4:5"];
|
|
459926
464225
|
function validateAspect(value) {
|
|
459927
|
-
if (!
|
|
459928
|
-
exitWithError(usageError(`Invalid aspect ratio: ${value}`, `Valid: ${
|
|
464226
|
+
if (!VALID_ASPECTS2.includes(value)) {
|
|
464227
|
+
exitWithError(usageError(`Invalid aspect ratio: ${value}`, `Valid: ${VALID_ASPECTS2.join(", ")}`));
|
|
459929
464228
|
}
|
|
459930
464229
|
return value;
|
|
459931
464230
|
}
|