@byte_fluffy/nexra-sdk 0.1.0-alpha.29 → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/dist/{assets-dUJMQNJD.d.ts → assets-Cusrjj7_.d.ts} +2 -2
- package/dist/catalog.d.ts +3 -3
- package/dist/catalog.js +2 -2
- package/dist/{chunk-ESV6ODRA.js → chunk-3CF6PDT3.js} +96 -18
- package/dist/chunk-DKQZWIQ7.js +730 -0
- package/dist/index.d.ts +59 -17
- package/dist/index.js +2 -2
- package/dist/{json-Drjj1OKl.d.ts → json-Cz0MkWQn.d.ts} +1 -1
- package/dist/language.d.ts +2 -2
- package/dist/language.js +2 -2
- package/dist/{media-geometry-nJ7I7ohO.d.ts → media-geometry-DAVFGry1.d.ts} +2 -2
- package/dist/media.d.ts +2 -2
- package/dist/media.js +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/{types-B3Xee2AJ.d.ts → voices-Cl4ygZHV.d.ts} +97 -85
- package/package.json +1 -1
- package/dist/chunk-IEBCNRT4.js +0 -399
package/dist/chunk-IEBCNRT4.js
DELETED
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
// ../contracts/src/assets.ts
|
|
2
|
-
var MEDIA_KINDS = [
|
|
3
|
-
"image",
|
|
4
|
-
"video",
|
|
5
|
-
"audio",
|
|
6
|
-
"document",
|
|
7
|
-
"archive",
|
|
8
|
-
"other"
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
// ../contracts/src/media-api.ts
|
|
12
|
-
var NEXRA_MEDIA_API_VERSION = 1;
|
|
13
|
-
var NEXRA_GENERATION_OPERATIONS = [
|
|
14
|
-
"text.generate",
|
|
15
|
-
"image.generate",
|
|
16
|
-
"video.generate",
|
|
17
|
-
"audio.generate",
|
|
18
|
-
"image.upscale",
|
|
19
|
-
"video.upscale"
|
|
20
|
-
];
|
|
21
|
-
var NEXRA_MEDIA_OPERATIONS = [
|
|
22
|
-
"image.generate",
|
|
23
|
-
"video.generate",
|
|
24
|
-
"audio.generate",
|
|
25
|
-
"image.upscale",
|
|
26
|
-
"video.upscale"
|
|
27
|
-
];
|
|
28
|
-
var NEXRA_PUBLISHED_MEDIA_OPERATIONS = [
|
|
29
|
-
"image.generate",
|
|
30
|
-
"video.generate",
|
|
31
|
-
"audio.generate",
|
|
32
|
-
"image.upscale"
|
|
33
|
-
];
|
|
34
|
-
var NEXRA_MEDIA_FEATURES = [
|
|
35
|
-
"text-to-image",
|
|
36
|
-
"image-to-image",
|
|
37
|
-
"image-reference",
|
|
38
|
-
"image-edit",
|
|
39
|
-
"image-inpaint",
|
|
40
|
-
"image-control",
|
|
41
|
-
"text-to-video",
|
|
42
|
-
"first-frame",
|
|
43
|
-
"first-last-frame",
|
|
44
|
-
"image-to-video",
|
|
45
|
-
"video-to-video",
|
|
46
|
-
"audio-to-video",
|
|
47
|
-
"avatar-video",
|
|
48
|
-
"reference-image",
|
|
49
|
-
"reference-video",
|
|
50
|
-
"reference-audio",
|
|
51
|
-
"omni-reference",
|
|
52
|
-
"tts",
|
|
53
|
-
"music",
|
|
54
|
-
"sfx",
|
|
55
|
-
"voice-reference",
|
|
56
|
-
"voice-design",
|
|
57
|
-
"scale-factor",
|
|
58
|
-
"target-resolution"
|
|
59
|
-
];
|
|
60
|
-
var NEXRA_MEDIA_OPERATION_DEFINITIONS = Object.freeze([
|
|
61
|
-
{
|
|
62
|
-
operation: "image.generate",
|
|
63
|
-
status: "active",
|
|
64
|
-
outputKind: "image",
|
|
65
|
-
features: ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control"],
|
|
66
|
-
parameterKeys: ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed"]
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
operation: "video.generate",
|
|
70
|
-
status: "active",
|
|
71
|
-
outputKind: "video",
|
|
72
|
-
features: ["text-to-video", "first-frame", "first-last-frame", "image-to-video", "video-to-video", "audio-to-video", "avatar-video", "reference-image", "reference-video", "reference-audio", "omni-reference"],
|
|
73
|
-
parameterKeys: ["voice", "aspect_ratio", "resolution", "quality", "duration", "fit", "title", "generate_audio", "output_format", "seed", "watermark"]
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
operation: "audio.generate",
|
|
77
|
-
status: "active",
|
|
78
|
-
outputKind: "audio",
|
|
79
|
-
features: ["tts", "music", "sfx", "voice-reference", "voice-design"],
|
|
80
|
-
parameterKeys: ["voice", "language", "duration", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion", "instrumental", "loop", "prompt_influence", "seed"]
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
operation: "image.upscale",
|
|
84
|
-
status: "active",
|
|
85
|
-
outputKind: "image",
|
|
86
|
-
features: ["scale-factor", "target-resolution"],
|
|
87
|
-
parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
operation: "video.upscale",
|
|
91
|
-
status: "hold",
|
|
92
|
-
outputKind: "video",
|
|
93
|
-
features: ["scale-factor", "target-resolution"],
|
|
94
|
-
parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
|
|
95
|
-
}
|
|
96
|
-
]);
|
|
97
|
-
var mediaSourceSchema = {
|
|
98
|
-
oneOf: [
|
|
99
|
-
{ type: "string", minLength: 1 },
|
|
100
|
-
{
|
|
101
|
-
type: "object",
|
|
102
|
-
properties: { assetId: { type: "string", minLength: 1 } },
|
|
103
|
-
required: ["assetId"],
|
|
104
|
-
additionalProperties: false
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
};
|
|
108
|
-
function textPartSchema(roles) {
|
|
109
|
-
return {
|
|
110
|
-
type: "object",
|
|
111
|
-
properties: {
|
|
112
|
-
type: { const: "text" },
|
|
113
|
-
text: { type: "string", minLength: 1 },
|
|
114
|
-
role: { type: "string", enum: [...roles] }
|
|
115
|
-
},
|
|
116
|
-
required: ["type", "text"],
|
|
117
|
-
additionalProperties: false
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function mediaPartSchema(type, roles) {
|
|
121
|
-
return {
|
|
122
|
-
type: "object",
|
|
123
|
-
properties: {
|
|
124
|
-
type: { const: type },
|
|
125
|
-
source: structuredClone(mediaSourceSchema),
|
|
126
|
-
role: { type: "string", enum: [...roles] },
|
|
127
|
-
...type === "image" ? { name: { type: "string", minLength: 1, maxLength: 64, pattern: "^[^\\s@]+$" } } : {}
|
|
128
|
-
},
|
|
129
|
-
required: ["type", "source"],
|
|
130
|
-
additionalProperties: false
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function inputSchema(contentItems, properties, contentBounds = {}) {
|
|
134
|
-
return {
|
|
135
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
136
|
-
type: "object",
|
|
137
|
-
properties: {
|
|
138
|
-
content: {
|
|
139
|
-
type: "array",
|
|
140
|
-
minItems: contentBounds.minItems ?? 1,
|
|
141
|
-
...contentBounds.maxItems === void 0 ? {} : { maxItems: contentBounds.maxItems },
|
|
142
|
-
items: { oneOf: contentItems.map((item) => structuredClone(item)) },
|
|
143
|
-
"x-ui": { control: "content-parts", order: 0 }
|
|
144
|
-
},
|
|
145
|
-
...properties
|
|
146
|
-
},
|
|
147
|
-
required: ["content"],
|
|
148
|
-
additionalProperties: false
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
var imagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background"]);
|
|
152
|
-
var videoImagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background", "keyframe"]);
|
|
153
|
-
var videoPart = mediaPartSchema("video", ["source", "reference", "edit", "extend"]);
|
|
154
|
-
var audioPart = mediaPartSchema("audio", ["source", "reference", "voice_reference"]);
|
|
155
|
-
var draftPart = {
|
|
156
|
-
type: "object",
|
|
157
|
-
properties: {
|
|
158
|
-
type: { const: "draft_task" },
|
|
159
|
-
draft_task: { type: "object", properties: { id: { type: "string", minLength: 1 } }, required: ["id"], additionalProperties: false }
|
|
160
|
-
},
|
|
161
|
-
required: ["type", "draft_task"],
|
|
162
|
-
additionalProperties: false
|
|
163
|
-
};
|
|
164
|
-
var NEXRA_MEDIA_INPUT_SCHEMAS = Object.freeze({
|
|
165
|
-
"image.generate": inputSchema(
|
|
166
|
-
[textPartSchema(["prompt", "negative_prompt"]), imagePart],
|
|
167
|
-
{
|
|
168
|
-
aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
|
|
169
|
-
resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
|
|
170
|
-
quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
|
|
171
|
-
count: { type: "integer", minimum: 1, "x-ui": { order: 13, control: "number" } },
|
|
172
|
-
output_format: { type: "string", minLength: 1, "x-ui": { order: 14 } },
|
|
173
|
-
seed: { type: "integer", minimum: 0, "x-ui": { order: 15, control: "number" } }
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
"video.generate": inputSchema(
|
|
177
|
-
[textPartSchema(["prompt", "negative_prompt", "script"]), videoImagePart, videoPart, audioPart, draftPart],
|
|
178
|
-
{
|
|
179
|
-
voice: { type: "string", minLength: 1, "x-ui": { order: 9, control: "resource", resource: "voice" } },
|
|
180
|
-
draft: { type: "boolean", "x-ui": { control: "switch" } },
|
|
181
|
-
watermark: { type: "boolean", const: false, "x-ui": { hidden: true } },
|
|
182
|
-
aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
|
|
183
|
-
resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
|
|
184
|
-
quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
|
|
185
|
-
duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 13, control: "number" } },
|
|
186
|
-
fit: { type: "string", enum: ["contain", "cover"], "x-ui": { order: 15, control: "segmented" } },
|
|
187
|
-
title: { type: "string", minLength: 1, "x-ui": { order: 16 } },
|
|
188
|
-
generate_audio: { type: "boolean", "x-ui": { order: 14, control: "switch" } },
|
|
189
|
-
output_format: { type: "string", minLength: 1, "x-ui": { order: 15 } },
|
|
190
|
-
seed: { type: "integer", minimum: 0, "x-ui": { order: 16, control: "number" } }
|
|
191
|
-
}
|
|
192
|
-
),
|
|
193
|
-
"audio.generate": inputSchema(
|
|
194
|
-
[textPartSchema(["prompt", "script", "lyrics"]), audioPart],
|
|
195
|
-
{
|
|
196
|
-
voice: { type: "string", minLength: 1, "x-ui": { order: 10, control: "resource", resource: "voice" } },
|
|
197
|
-
language: { type: "string", minLength: 1, "x-ui": { order: 11 } },
|
|
198
|
-
duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 12, control: "number" } },
|
|
199
|
-
output_format: { type: "string", minLength: 1, "x-ui": { order: 13 } },
|
|
200
|
-
sample_rate: { type: "integer", minimum: 1, "x-ui": { order: 14, control: "number" } },
|
|
201
|
-
speed: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 15, control: "number" } },
|
|
202
|
-
volume: { type: "number", "x-ui": { order: 16, control: "number" } },
|
|
203
|
-
pitch: { type: "number", "x-ui": { order: 17, control: "number" } },
|
|
204
|
-
emotion: { type: "string", minLength: 1, "x-ui": { order: 18 } },
|
|
205
|
-
instrumental: { type: "boolean", "x-ui": { order: 19, control: "switch" } },
|
|
206
|
-
loop: { type: "boolean", "x-ui": { order: 20, control: "switch" } },
|
|
207
|
-
prompt_influence: { type: "number", minimum: 0, maximum: 1, "x-ui": { order: 21, control: "number" } },
|
|
208
|
-
seed: { type: "integer", minimum: 0, "x-ui": { order: 22, control: "number" } }
|
|
209
|
-
}
|
|
210
|
-
),
|
|
211
|
-
"image.upscale": inputSchema(
|
|
212
|
-
[mediaPartSchema("image", ["source"])],
|
|
213
|
-
{
|
|
214
|
-
scale: { type: "number", exclusiveMinimum: 1, "x-ui": { order: 10, control: "number" } },
|
|
215
|
-
resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
|
|
216
|
-
output_format: { type: "string", minLength: 1, "x-ui": { order: 12 } },
|
|
217
|
-
preserve_details: { type: "boolean", "x-ui": { order: 13, control: "switch" } }
|
|
218
|
-
},
|
|
219
|
-
{ minItems: 1, maxItems: 1 }
|
|
220
|
-
)
|
|
221
|
-
});
|
|
222
|
-
function nexraMediaInputSchema(operation) {
|
|
223
|
-
if (!(operation in NEXRA_MEDIA_INPUT_SCHEMAS)) return void 0;
|
|
224
|
-
return structuredClone(NEXRA_MEDIA_INPUT_SCHEMAS[operation]);
|
|
225
|
-
}
|
|
226
|
-
function isNexraMediaInput(value) {
|
|
227
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
228
|
-
const input = value;
|
|
229
|
-
if ("model" in input) return false;
|
|
230
|
-
const content = input.content;
|
|
231
|
-
return Array.isArray(content) && content.length > 0 && content.every((part) => {
|
|
232
|
-
if (!part || typeof part !== "object" || Array.isArray(part)) return false;
|
|
233
|
-
if (part.type === "text") return typeof part.text === "string" && part.text.length > 0;
|
|
234
|
-
if (part.type === "draft_task") {
|
|
235
|
-
const reference = part.draft_task;
|
|
236
|
-
return Boolean(reference && typeof reference === "object" && !Array.isArray(reference) && typeof reference.id === "string" && reference.id.length > 0);
|
|
237
|
-
}
|
|
238
|
-
if (!["image", "video", "audio"].includes(String(part.type))) return false;
|
|
239
|
-
if (typeof part.source === "string") return part.source.length > 0;
|
|
240
|
-
return Boolean(part.source && typeof part.source === "object" && !Array.isArray(part.source) && typeof part.source.assetId === "string" && part.source.assetId.length > 0);
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
function nexraMediaOperationForMode(mode) {
|
|
244
|
-
if (["text-to-image", "image-to-image"].includes(mode)) return "image.generate";
|
|
245
|
-
if (["text-to-video", "image-to-video", "multimodal-to-video", "avatar-video"].includes(mode)) return "video.generate";
|
|
246
|
-
if (["text-to-speech", "text-to-music", "text-to-sfx"].includes(mode)) return "audio.generate";
|
|
247
|
-
if (mode === "image-upscale") return "image.upscale";
|
|
248
|
-
return void 0;
|
|
249
|
-
}
|
|
250
|
-
function nexraMediaInputSchemaForMode(mode) {
|
|
251
|
-
const operation = nexraMediaOperationForMode(mode);
|
|
252
|
-
const schema = operation ? nexraMediaInputSchema(operation) : void 0;
|
|
253
|
-
if (!schema) return void 0;
|
|
254
|
-
const properties = schema.properties;
|
|
255
|
-
const content = properties.content;
|
|
256
|
-
const items = content.items;
|
|
257
|
-
const variants = Array.isArray(items.oneOf) ? items.oneOf : [];
|
|
258
|
-
if (mode === "avatar-video") {
|
|
259
|
-
for (const variant of variants) {
|
|
260
|
-
const variantProperties = variant.properties;
|
|
261
|
-
if (variantProperties.type.const === "text") {
|
|
262
|
-
variantProperties.role = { type: "string", enum: ["script"] };
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
const allowed = mode === "text-to-image" || mode === "text-to-video" || mode === "text-to-music" || mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["text"]) : mode === "image-to-image" ? /* @__PURE__ */ new Set(["text", "image"]) : mode === "image-to-video" ? /* @__PURE__ */ new Set(["text", "image", "audio"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["text", "audio"]) : /* @__PURE__ */ new Set(["text", "image", "video", "audio"]);
|
|
267
|
-
items.oneOf = variants.filter((variant) => allowed.has(String(variant.properties.type.const)));
|
|
268
|
-
if (mode === "image-to-video") {
|
|
269
|
-
for (const variant of items.oneOf) {
|
|
270
|
-
const variantProperties = variant.properties;
|
|
271
|
-
if (variantProperties.type.const !== "image") continue;
|
|
272
|
-
variantProperties.role = { type: "string", enum: ["first_frame", "last_frame"] };
|
|
273
|
-
const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
|
|
274
|
-
required.add("role");
|
|
275
|
-
variant.required = [...required];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (mode === "multimodal-to-video") {
|
|
279
|
-
for (const variant of items.oneOf) {
|
|
280
|
-
const variantProperties = variant.properties;
|
|
281
|
-
const type = String(variantProperties.type.const);
|
|
282
|
-
if (!["image", "video", "audio"].includes(type)) continue;
|
|
283
|
-
variantProperties.role = type === "image" ? { type: "string", enum: ["reference", "subject", "background"] } : type === "video" ? { type: "string", enum: ["reference", "edit", "extend"] } : { type: "string", const: "reference" };
|
|
284
|
-
const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
|
|
285
|
-
required.add("role");
|
|
286
|
-
variant.required = [...required];
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
const requiredMedia = mode === "image-to-image" || mode === "image-to-video" || mode === "avatar-video" ? "image" : void 0;
|
|
290
|
-
const requiresReferenceMedia = mode === "multimodal-to-video";
|
|
291
|
-
content.allOf = [
|
|
292
|
-
...mode === "avatar-video" ? [] : [{
|
|
293
|
-
contains: { type: "object", properties: { type: { const: "text" } }, required: ["type"] },
|
|
294
|
-
minContains: 1
|
|
295
|
-
}],
|
|
296
|
-
...requiredMedia ? [{
|
|
297
|
-
contains: { type: "object", properties: { type: { const: requiredMedia } }, required: ["type"] },
|
|
298
|
-
minContains: 1
|
|
299
|
-
}] : [],
|
|
300
|
-
...requiresReferenceMedia ? [{
|
|
301
|
-
contains: { type: "object", properties: { type: { enum: ["image", "video", "audio"] } }, required: ["type"] },
|
|
302
|
-
minContains: 1
|
|
303
|
-
}] : []
|
|
304
|
-
];
|
|
305
|
-
if (mode === "text-to-speech") {
|
|
306
|
-
properties.voice = { ...properties.voice, "x-ui": { order: 10, control: "resource", resource: "voice" } };
|
|
307
|
-
}
|
|
308
|
-
const allowedParameters = mode === "avatar-video" ? /* @__PURE__ */ new Set(["content", "voice", "aspect_ratio", "resolution"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["content", "voice", "language", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion"]) : mode === "text-to-music" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "instrumental", "prompt_influence", "seed"]) : mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "loop", "prompt_influence", "seed"]) : void 0;
|
|
309
|
-
if (allowedParameters) {
|
|
310
|
-
schema.properties = Object.fromEntries(Object.entries(properties).filter(([key]) => allowedParameters.has(key)));
|
|
311
|
-
}
|
|
312
|
-
return schema;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// ../contracts/src/tasks.ts
|
|
316
|
-
var TASK_STATUSES = [
|
|
317
|
-
"queued",
|
|
318
|
-
"running",
|
|
319
|
-
"succeeded",
|
|
320
|
-
"failed",
|
|
321
|
-
"cancelling",
|
|
322
|
-
"cancelled"
|
|
323
|
-
];
|
|
324
|
-
var CREATE_TASK_CONTROL_FIELDS = [
|
|
325
|
-
"model",
|
|
326
|
-
"callback_url",
|
|
327
|
-
"metadata",
|
|
328
|
-
"quoteToken",
|
|
329
|
-
"submittedAt",
|
|
330
|
-
"schemaVersion",
|
|
331
|
-
"webhook"
|
|
332
|
-
];
|
|
333
|
-
function createTaskRequest(model, input, controls = {}) {
|
|
334
|
-
for (const field of [...CREATE_TASK_CONTROL_FIELDS, "input"]) {
|
|
335
|
-
if (Object.hasOwn(input, field)) {
|
|
336
|
-
throw new Error(`Nexra model parameters cannot use reserved Task field: ${field}`);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return { model, ...input, ...controls };
|
|
340
|
-
}
|
|
341
|
-
function isTerminalTaskStatus(status) {
|
|
342
|
-
return status === "succeeded" || status === "failed" || status === "cancelled";
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// ../contracts/src/admin-errors.ts
|
|
346
|
-
var CALL_ERROR_STATUSES = ["failed", "rejected", "delivery_failed"];
|
|
347
|
-
var CALL_ANOMALY_STATUSES = [...CALL_ERROR_STATUSES, "cancelled"];
|
|
348
|
-
|
|
349
|
-
// ../contracts/src/ratio-display-order.ts
|
|
350
|
-
function parseRatioParts(value) {
|
|
351
|
-
const matched = /^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(value);
|
|
352
|
-
if (!matched) return void 0;
|
|
353
|
-
const w = Number(matched[1]);
|
|
354
|
-
const h = Number(matched[2]);
|
|
355
|
-
return w > 0 && h > 0 ? { w, h } : void 0;
|
|
356
|
-
}
|
|
357
|
-
function ratioDisplayOrderKey(value) {
|
|
358
|
-
const normalized = value.trim();
|
|
359
|
-
const parts = parseRatioParts(normalized);
|
|
360
|
-
if (!parts) {
|
|
361
|
-
const auto = normalized.toLowerCase() === "auto" ? 0 : 1;
|
|
362
|
-
return [0, auto, 0, 0, value];
|
|
363
|
-
}
|
|
364
|
-
if (parts.w === parts.h) return [1, 0, 0, 0, value];
|
|
365
|
-
const long = Math.max(parts.w, parts.h);
|
|
366
|
-
const short = Math.min(parts.w, parts.h);
|
|
367
|
-
const landscape = parts.w > parts.h ? 1 : 0;
|
|
368
|
-
return short === 1 ? [3, long, landscape, -short, value] : [2, long, landscape, -short, value];
|
|
369
|
-
}
|
|
370
|
-
function compareRatioDisplayOrder(a, b) {
|
|
371
|
-
const ka = ratioDisplayOrderKey(a);
|
|
372
|
-
const kb = ratioDisplayOrderKey(b);
|
|
373
|
-
for (let index = 0; index < ka.length; index += 1) {
|
|
374
|
-
if (ka[index] !== kb[index]) return ka[index] < kb[index] ? -1 : 1;
|
|
375
|
-
}
|
|
376
|
-
return 0;
|
|
377
|
-
}
|
|
378
|
-
function sortRatioDisplayOrder(values) {
|
|
379
|
-
return [...values].sort(compareRatioDisplayOrder);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export {
|
|
383
|
-
MEDIA_KINDS,
|
|
384
|
-
NEXRA_MEDIA_API_VERSION,
|
|
385
|
-
NEXRA_GENERATION_OPERATIONS,
|
|
386
|
-
NEXRA_MEDIA_OPERATIONS,
|
|
387
|
-
NEXRA_PUBLISHED_MEDIA_OPERATIONS,
|
|
388
|
-
NEXRA_MEDIA_FEATURES,
|
|
389
|
-
NEXRA_MEDIA_OPERATION_DEFINITIONS,
|
|
390
|
-
NEXRA_MEDIA_INPUT_SCHEMAS,
|
|
391
|
-
nexraMediaInputSchema,
|
|
392
|
-
isNexraMediaInput,
|
|
393
|
-
nexraMediaOperationForMode,
|
|
394
|
-
nexraMediaInputSchemaForMode,
|
|
395
|
-
TASK_STATUSES,
|
|
396
|
-
createTaskRequest,
|
|
397
|
-
isTerminalTaskStatus,
|
|
398
|
-
sortRatioDisplayOrder
|
|
399
|
-
};
|