@nodaro/shared 3.18.0 → 3.20.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.cjs +203 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +202 -2
- package/dist/index.d.ts +202 -2
- package/dist/index.js +195 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/caption-plan.test.ts +27 -0
- package/src/__tests__/edit-plan-review.test.ts +379 -0
- package/src/__tests__/node-preset-extract.test.ts +62 -0
- package/src/caption-plan.ts +27 -0
- package/src/competitors.ts +40 -0
- package/src/edit-plan-review.ts +323 -0
- package/src/index.ts +10 -1
- package/src/node-preset-extract.ts +33 -1
- package/src/node-runtime-keys.ts +5 -0
- package/src/producer-types.ts +15 -0
package/dist/index.cjs
CHANGED
|
@@ -5816,6 +5816,10 @@ var FAN_OUT_EACH_HANDLES = {
|
|
|
5816
5816
|
// (decided 2026-10-04).
|
|
5817
5817
|
"camera-switch": { each: ["edl"], primary: "edl" }
|
|
5818
5818
|
};
|
|
5819
|
+
var OWN_LIST_NODE_TYPES = /* @__PURE__ */ new Set(["extract-field", "json-process"]);
|
|
5820
|
+
function ownsItsList(nodeType) {
|
|
5821
|
+
return typeof nodeType === "string" && OWN_LIST_NODE_TYPES.has(nodeType);
|
|
5822
|
+
}
|
|
5819
5823
|
function defaultEdgeOutputMode(sourceType, sourceHandle) {
|
|
5820
5824
|
if (typeof sourceType !== "string") return "last";
|
|
5821
5825
|
if (FAN_OUT_EACH_TYPES.has(sourceType)) return "each";
|
|
@@ -12793,6 +12797,11 @@ var EXECUTION_DATA_KEYS = /* @__PURE__ */ new Set([
|
|
|
12793
12797
|
"__pickedTotal",
|
|
12794
12798
|
"__restTotal",
|
|
12795
12799
|
"generatedJson",
|
|
12800
|
+
// Edit Plan: a person's review of the plan (`EditedEdl`, edit-plan-review.ts),
|
|
12801
|
+
// kept beside `generatedJson` and fingerprinted against it. Run-result data
|
|
12802
|
+
// (TA14, decided 2026-10-04): out of undo, presets, templates and exports,
|
|
12803
|
+
// and Clear results wipes it. Persisted — never transient.
|
|
12804
|
+
"editedEdl",
|
|
12796
12805
|
"subWorkflowProgress",
|
|
12797
12806
|
"outputResults",
|
|
12798
12807
|
"shots",
|
|
@@ -15686,9 +15695,31 @@ var PRESET_APPLY_CLEAR_KEYS = [
|
|
|
15686
15695
|
"referenceRoles"
|
|
15687
15696
|
];
|
|
15688
15697
|
var PROMPT_CONTENT_KEYS = ["prompt", "scenePrompt", "editPrompt", PROMPT_PREFIX_KEY, PROMPT_SUFFIX_KEY];
|
|
15689
|
-
function presetApplyClearKeys(presetData) {
|
|
15698
|
+
function presetApplyClearKeys(presetData, nodeType) {
|
|
15690
15699
|
const ownsPromptContent = PROMPT_CONTENT_KEYS.some((k) => presetData[k] !== void 0);
|
|
15691
|
-
|
|
15700
|
+
const base = ownsPromptContent ? [...PRESET_APPLY_CLEAR_KEYS, PROMPT_PREFIX_KEY, PROMPT_SUFFIX_KEY] : PRESET_APPLY_CLEAR_KEYS;
|
|
15701
|
+
const levers = presetLeverClearKeys(presetData, nodeType);
|
|
15702
|
+
return levers.length > 0 ? [...base, ...levers] : base;
|
|
15703
|
+
}
|
|
15704
|
+
var PRESET_LEVER_GROUPS = {
|
|
15705
|
+
"add-captions": [
|
|
15706
|
+
"look",
|
|
15707
|
+
"fontFamily",
|
|
15708
|
+
"fontWeight",
|
|
15709
|
+
"strokeColor",
|
|
15710
|
+
"strokeWidth",
|
|
15711
|
+
"highlightColor",
|
|
15712
|
+
"uppercase",
|
|
15713
|
+
"positionY",
|
|
15714
|
+
"animate",
|
|
15715
|
+
"maxWordsPerLine",
|
|
15716
|
+
"backgroundColor"
|
|
15717
|
+
]
|
|
15718
|
+
};
|
|
15719
|
+
function presetLeverClearKeys(presetData, nodeType) {
|
|
15720
|
+
if (!nodeType || !Object.hasOwn(PRESET_LEVER_GROUPS, nodeType)) return [];
|
|
15721
|
+
if (!Object.values(presetData).some((v) => v !== void 0)) return [];
|
|
15722
|
+
return PRESET_LEVER_GROUPS[nodeType].filter((k) => presetData[k] === void 0);
|
|
15692
15723
|
}
|
|
15693
15724
|
var PRESET_EXCLUDED_KEYS = /* @__PURE__ */ new Set([
|
|
15694
15725
|
"label",
|
|
@@ -21251,6 +21282,167 @@ function unwrapEditPlanOutput(outputData) {
|
|
|
21251
21282
|
return rest;
|
|
21252
21283
|
}
|
|
21253
21284
|
|
|
21285
|
+
// src/edit-plan-review.ts
|
|
21286
|
+
var EDITED_EDL_VERSION = 1;
|
|
21287
|
+
function canonicalJson(value) {
|
|
21288
|
+
if (value === null) return "null";
|
|
21289
|
+
switch (typeof value) {
|
|
21290
|
+
case "string":
|
|
21291
|
+
case "boolean":
|
|
21292
|
+
return JSON.stringify(value);
|
|
21293
|
+
case "number":
|
|
21294
|
+
return Number.isFinite(value) ? JSON.stringify(value) : "null";
|
|
21295
|
+
case "object": {
|
|
21296
|
+
const toJSON = value.toJSON;
|
|
21297
|
+
if (typeof toJSON === "function") return canonicalJson(value.toJSON());
|
|
21298
|
+
if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item) ?? "null").join(",")}]`;
|
|
21299
|
+
const parts = [];
|
|
21300
|
+
for (const key of Object.keys(value).sort()) {
|
|
21301
|
+
const text = canonicalJson(value[key]);
|
|
21302
|
+
if (text !== void 0) parts.push(`${JSON.stringify(key)}:${text}`);
|
|
21303
|
+
}
|
|
21304
|
+
return `{${parts.join(",")}}`;
|
|
21305
|
+
}
|
|
21306
|
+
default:
|
|
21307
|
+
return void 0;
|
|
21308
|
+
}
|
|
21309
|
+
}
|
|
21310
|
+
function fnv1a64(text) {
|
|
21311
|
+
let hi = 3421674724;
|
|
21312
|
+
let lo = 2216829733;
|
|
21313
|
+
const mix = (byte) => {
|
|
21314
|
+
lo = (lo ^ byte) >>> 0;
|
|
21315
|
+
const loProduct = lo * 435;
|
|
21316
|
+
const carry = Math.floor(loProduct / 4294967296);
|
|
21317
|
+
hi = hi * 435 + carry + (lo << 8 >>> 0) >>> 0;
|
|
21318
|
+
lo = loProduct >>> 0;
|
|
21319
|
+
};
|
|
21320
|
+
for (let i = 0; i < text.length; i++) {
|
|
21321
|
+
let code = text.charCodeAt(i);
|
|
21322
|
+
if (code >= 55296 && code <= 56319) {
|
|
21323
|
+
const next = i + 1 < text.length ? text.charCodeAt(i + 1) : 0;
|
|
21324
|
+
if (next >= 56320 && next <= 57343) {
|
|
21325
|
+
code = 65536 + (code - 55296 << 10) + (next - 56320);
|
|
21326
|
+
i++;
|
|
21327
|
+
} else code = 65533;
|
|
21328
|
+
} else if (code >= 56320 && code <= 57343) code = 65533;
|
|
21329
|
+
if (code < 128) mix(code);
|
|
21330
|
+
else if (code < 2048) {
|
|
21331
|
+
mix(192 | code >> 6);
|
|
21332
|
+
mix(128 | code & 63);
|
|
21333
|
+
} else if (code < 65536) {
|
|
21334
|
+
mix(224 | code >> 12);
|
|
21335
|
+
mix(128 | code >> 6 & 63);
|
|
21336
|
+
mix(128 | code & 63);
|
|
21337
|
+
} else {
|
|
21338
|
+
mix(240 | code >> 18);
|
|
21339
|
+
mix(128 | code >> 12 & 63);
|
|
21340
|
+
mix(128 | code >> 6 & 63);
|
|
21341
|
+
mix(128 | code & 63);
|
|
21342
|
+
}
|
|
21343
|
+
}
|
|
21344
|
+
return hi.toString(16).padStart(8, "0") + lo.toString(16).padStart(8, "0");
|
|
21345
|
+
}
|
|
21346
|
+
function editPlanBasis(plan) {
|
|
21347
|
+
return fnv1a64(canonicalJson(plan) ?? "");
|
|
21348
|
+
}
|
|
21349
|
+
var isRecord3 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
21350
|
+
function planShape(plan) {
|
|
21351
|
+
if (Array.isArray(plan)) return "clips";
|
|
21352
|
+
if (isRecord3(plan) && Array.isArray(plan.segments)) return "edl";
|
|
21353
|
+
return "other";
|
|
21354
|
+
}
|
|
21355
|
+
function checkEnvelope(edited, plan) {
|
|
21356
|
+
if (edited === void 0 || edited === null) return { status: "none" };
|
|
21357
|
+
if (!isRecord3(edited)) return { status: "invalid", issue: "editedEdl must be an object" };
|
|
21358
|
+
if (edited.v !== EDITED_EDL_VERSION) return { status: "invalid", issue: `editedEdl.v must be ${EDITED_EDL_VERSION}` };
|
|
21359
|
+
if (typeof edited.basis !== "string" || edited.basis.length === 0) {
|
|
21360
|
+
return { status: "invalid", issue: "editedEdl.basis must be a non-empty string" };
|
|
21361
|
+
}
|
|
21362
|
+
if (edited.kind !== "edl" && edited.kind !== "clips") {
|
|
21363
|
+
return { status: "invalid", issue: `editedEdl.kind must be "edl" or "clips"` };
|
|
21364
|
+
}
|
|
21365
|
+
if (edited.basis !== editPlanBasis(plan)) {
|
|
21366
|
+
return { status: "stale", issue: "editedEdl.basis does not match the plan: the plan changed since this edit was made" };
|
|
21367
|
+
}
|
|
21368
|
+
const shape = planShape(plan);
|
|
21369
|
+
if (edited.kind === "edl") {
|
|
21370
|
+
if (shape !== "edl") return { status: "invalid", issue: `an "edl" edit needs a Tighten plan (one EDL); this plan is ${describeShape(shape)}` };
|
|
21371
|
+
const edl = edited.edl;
|
|
21372
|
+
if (!isRecord3(edl) || !Array.isArray(edl.segments) || !Array.isArray(edl.dropped)) {
|
|
21373
|
+
return { status: "invalid", issue: "editedEdl.edl must hold a segments array and a dropped array" };
|
|
21374
|
+
}
|
|
21375
|
+
} else if (edited.kind === "clips") {
|
|
21376
|
+
if (shape !== "clips") return { status: "invalid", issue: `a "clips" edit needs a clip set; this plan is ${describeShape(shape)}` };
|
|
21377
|
+
const clips = edited.clips;
|
|
21378
|
+
if (!Array.isArray(clips)) return { status: "invalid", issue: "editedEdl.clips must be an array" };
|
|
21379
|
+
const planned = plan.length;
|
|
21380
|
+
if (clips.length !== planned) {
|
|
21381
|
+
return { status: "invalid", issue: `editedEdl.clips holds ${clips.length} decisions; the plan has ${planned} clips` };
|
|
21382
|
+
}
|
|
21383
|
+
const bad = clips.findIndex(
|
|
21384
|
+
(c) => !isRecord3(c) || typeof c.keep !== "boolean" || c.hook !== void 0 && typeof c.hook !== "string"
|
|
21385
|
+
);
|
|
21386
|
+
if (bad >= 0) return { status: "invalid", issue: `editedEdl.clips[${bad}] must be {keep: boolean, hook?: string}` };
|
|
21387
|
+
}
|
|
21388
|
+
return { status: "applied", edited };
|
|
21389
|
+
}
|
|
21390
|
+
function describeShape(shape) {
|
|
21391
|
+
return shape === "edl" ? "a Tighten plan" : shape === "clips" ? "a clip set" : "neither (a chapter list, or no plan)";
|
|
21392
|
+
}
|
|
21393
|
+
function plannedList(plan) {
|
|
21394
|
+
return plan.map((clip) => typeof clip === "string" ? clip : JSON.stringify(clip));
|
|
21395
|
+
}
|
|
21396
|
+
function asOutput(plan) {
|
|
21397
|
+
return Array.isArray(plan) ? { json: plan, listResults: plannedList(plan) } : { json: plan };
|
|
21398
|
+
}
|
|
21399
|
+
function withHook(clip, hook) {
|
|
21400
|
+
if (hook === void 0) return clip;
|
|
21401
|
+
let value = clip;
|
|
21402
|
+
if (typeof clip === "string") {
|
|
21403
|
+
try {
|
|
21404
|
+
value = JSON.parse(clip);
|
|
21405
|
+
} catch {
|
|
21406
|
+
return clip;
|
|
21407
|
+
}
|
|
21408
|
+
}
|
|
21409
|
+
if (!isRecord3(value)) return clip;
|
|
21410
|
+
const meta = isRecord3(value.meta) ? value.meta : {};
|
|
21411
|
+
return { ...value, meta: { ...meta, hook } };
|
|
21412
|
+
}
|
|
21413
|
+
function resolveEditPlanOutput(plan, editedEdl) {
|
|
21414
|
+
const check = checkEnvelope(editedEdl, plan);
|
|
21415
|
+
if (check.status !== "applied") return { status: check.status, ...asOutput(plan) };
|
|
21416
|
+
const edited = check.edited;
|
|
21417
|
+
if (edited.kind === "edl") {
|
|
21418
|
+
const json = { ...plan, segments: edited.edl.segments, dropped: edited.edl.dropped };
|
|
21419
|
+
return { status: "applied", json };
|
|
21420
|
+
}
|
|
21421
|
+
const rows = plan.map((clip, i) => {
|
|
21422
|
+
const decision = edited.clips[i];
|
|
21423
|
+
return decision.keep ? withHook(clip, decision.hook) : void 0;
|
|
21424
|
+
});
|
|
21425
|
+
return {
|
|
21426
|
+
status: "applied",
|
|
21427
|
+
json: rows.filter((clip) => clip !== void 0),
|
|
21428
|
+
listResults: rows.map((clip) => clip === void 0 ? "" : typeof clip === "string" ? clip : JSON.stringify(clip))
|
|
21429
|
+
};
|
|
21430
|
+
}
|
|
21431
|
+
function editPlanSavedOutput(data) {
|
|
21432
|
+
const plan = data.generatedJson;
|
|
21433
|
+
if (plan === void 0) return void 0;
|
|
21434
|
+
const { status: _status, ...output } = resolveEditPlanOutput(plan, data.editedEdl);
|
|
21435
|
+
return output;
|
|
21436
|
+
}
|
|
21437
|
+
function validateEditedEdl(editedEdl, plan) {
|
|
21438
|
+
const check = checkEnvelope(editedEdl, plan);
|
|
21439
|
+
if (check.status === "none") return { ok: false, issues: ["there is no edit"], warnings: [] };
|
|
21440
|
+
if (check.status !== "applied") return { ok: false, issues: [check.issue], warnings: [] };
|
|
21441
|
+
if (check.edited.kind === "clips") return { ok: true, issues: [], warnings: [] };
|
|
21442
|
+
const resolved = resolveEditPlanOutput(plan, editedEdl).json;
|
|
21443
|
+
return validateEdl(resolved);
|
|
21444
|
+
}
|
|
21445
|
+
|
|
21254
21446
|
exports.ACCESS_LEVELS = ACCESS_LEVELS;
|
|
21255
21447
|
exports.ACTION_CARD_KINDS = ACTION_CARD_KINDS;
|
|
21256
21448
|
exports.ACTIVE_SCENE_HELPERS = ACTIVE_SCENE_HELPERS;
|
|
@@ -21401,6 +21593,7 @@ exports.DETAIL_VARIANTS = DETAIL_VARIANTS;
|
|
|
21401
21593
|
exports.DURATION_PRICED_PROVIDERS = DURATION_PRICED_PROVIDERS;
|
|
21402
21594
|
exports.DYNAMIC_PRODUCER_TYPES = DYNAMIC_PRODUCER_TYPES;
|
|
21403
21595
|
exports.DetectionResultSchema = DetectionResultSchema;
|
|
21596
|
+
exports.EDITED_EDL_VERSION = EDITED_EDL_VERSION;
|
|
21404
21597
|
exports.EDIT_PLAN_BASE_CREDIT_ID = EDIT_PLAN_BASE_CREDIT_ID;
|
|
21405
21598
|
exports.EDIT_PLAN_BUCKET_MINUTES = EDIT_PLAN_BUCKET_MINUTES;
|
|
21406
21599
|
exports.EDIT_PLAN_DEFAULT_CLIP_COUNT = EDIT_PLAN_DEFAULT_CLIP_COUNT;
|
|
@@ -21640,6 +21833,7 @@ exports.OVERLAY_PLATFORM_IDS = OVERLAY_PLATFORM_IDS;
|
|
|
21640
21833
|
exports.OVERLAY_SHAPES = OVERLAY_SHAPES;
|
|
21641
21834
|
exports.OVERLAY_TEXT_ALIGNS = OVERLAY_TEXT_ALIGNS;
|
|
21642
21835
|
exports.OVERLAY_VARIANT_HANDLE_PREFIX = OVERLAY_VARIANT_HANDLE_PREFIX;
|
|
21836
|
+
exports.OWN_LIST_NODE_TYPES = OWN_LIST_NODE_TYPES;
|
|
21643
21837
|
exports.ObjectMetadataSchema = ObjectMetadataSchema;
|
|
21644
21838
|
exports.OptimizeForModelInputSchema = OptimizeForModelInputSchema;
|
|
21645
21839
|
exports.OptimizeForModelResultSchema = OptimizeForModelResultSchema;
|
|
@@ -21667,6 +21861,7 @@ exports.PLATFORM_SPECS = PLATFORM_SPECS;
|
|
|
21667
21861
|
exports.PRESET_APPLY_CLEAR_KEYS = PRESET_APPLY_CLEAR_KEYS;
|
|
21668
21862
|
exports.PRESET_EXCLUDED_KEYS = PRESET_EXCLUDED_KEYS;
|
|
21669
21863
|
exports.PRESET_LABELS = PRESET_LABELS;
|
|
21864
|
+
exports.PRESET_LEVER_GROUPS = PRESET_LEVER_GROUPS;
|
|
21670
21865
|
exports.PRESET_SETTING_KEYS = PRESET_SETTING_KEYS;
|
|
21671
21866
|
exports.PRICING_DEFAULT_DURATION_SEC = PRICING_DEFAULT_DURATION_SEC;
|
|
21672
21867
|
exports.PRICING_DEFAULT_RESOLUTION = PRICING_DEFAULT_RESOLUTION;
|
|
@@ -22156,7 +22351,9 @@ exports.detectVideoLinkPlatform = detectVideoLinkPlatform;
|
|
|
22156
22351
|
exports.dropUnknownBindings = dropUnknownBindings;
|
|
22157
22352
|
exports.dropUnknownSpeakers = dropUnknownSpeakers;
|
|
22158
22353
|
exports.durationsByMode = durationsByMode;
|
|
22354
|
+
exports.editPlanBasis = editPlanBasis;
|
|
22159
22355
|
exports.editPlanBucketMinutes = editPlanBucketMinutes;
|
|
22356
|
+
exports.editPlanSavedOutput = editPlanSavedOutput;
|
|
22160
22357
|
exports.editPlanSourceDurationSec = editPlanSourceDurationSec;
|
|
22161
22358
|
exports.editPlanTranscriptOrigin = editPlanTranscriptOrigin;
|
|
22162
22359
|
exports.edlDurationMs = edlDurationMs;
|
|
@@ -22428,6 +22625,7 @@ exports.overlayStrokeSchema = overlayStrokeSchema;
|
|
|
22428
22625
|
exports.overlayTextStyleSchema = overlayTextStyleSchema;
|
|
22429
22626
|
exports.overlayVariantHandle = overlayVariantHandle;
|
|
22430
22627
|
exports.overlayVariantIdFromHandle = overlayVariantIdFromHandle;
|
|
22628
|
+
exports.ownsItsList = ownsItsList;
|
|
22431
22629
|
exports.parseAspectToken = parseAspectToken;
|
|
22432
22630
|
exports.parseAttributedDialogue = parseAttributedDialogue;
|
|
22433
22631
|
exports.parseCharacterMentionToken = parseCharacterMentionToken;
|
|
@@ -22456,6 +22654,7 @@ exports.presentTypes = presentTypes;
|
|
|
22456
22654
|
exports.presetApplyClearKeys = presetApplyClearKeys;
|
|
22457
22655
|
exports.presetDataMatches = presetDataMatches;
|
|
22458
22656
|
exports.presetEntries = presetEntries;
|
|
22657
|
+
exports.presetLeverClearKeys = presetLeverClearKeys;
|
|
22459
22658
|
exports.previewHorizonMs = previewHorizonMs;
|
|
22460
22659
|
exports.pricedOutputDurationSec = pricedOutputDurationSec;
|
|
22461
22660
|
exports.pricedVideoSelection = pricedVideoSelection;
|
|
@@ -22494,6 +22693,7 @@ exports.resolveConditionValue = resolveConditionValue;
|
|
|
22494
22693
|
exports.resolveDefaultRole = resolveDefaultRole;
|
|
22495
22694
|
exports.resolveDescription = resolveDescription;
|
|
22496
22695
|
exports.resolveDialogueVoices = resolveDialogueVoices;
|
|
22696
|
+
exports.resolveEditPlanOutput = resolveEditPlanOutput;
|
|
22497
22697
|
exports.resolveEditPlanSources = resolveEditPlanSources;
|
|
22498
22698
|
exports.resolveEdlSegmentSlots = resolveEdlSegmentSlots;
|
|
22499
22699
|
exports.resolveEffectiveSourceType = resolveEffectiveSourceType;
|
|
@@ -22732,6 +22932,7 @@ exports.usdToCredits = usdToCredits;
|
|
|
22732
22932
|
exports.validateAiAvatarPayload = validateAiAvatarPayload;
|
|
22733
22933
|
exports.validateCinematicAvatarPayload = validateCinematicAvatarPayload;
|
|
22734
22934
|
exports.validateDurationForFormat = validateDurationForFormat;
|
|
22935
|
+
exports.validateEditedEdl = validateEditedEdl;
|
|
22735
22936
|
exports.validateEdl = validateEdl;
|
|
22736
22937
|
exports.validateEdlClipSet = validateEdlClipSet;
|
|
22737
22938
|
exports.validateModeActivation = validateModeActivation;
|