@hyperframes/studio 0.9.40 → 0.9.42
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/assets/{codec-BPK_2CLL.js → codec-CKqLGYc6.js} +1 -1
- package/dist/assets/{hyperframes-player-D7qTTDIp.js → hyperframes-player-DoEYqOIa.js} +1 -1
- package/dist/assets/{index-CdA00Ybn.js → index-DLyQ91Ek.js} +166 -166
- package/dist/assets/{index-QS-DuxAU.js → index-s9iqoWnr.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-Byzz98Gb.js → pausedVideoDecoder-B-ReRg6i.js} +1 -1
- package/dist/{chunk-KF6YVXJP.js → chunk-4QQMX4BX.js} +6 -3
- package/dist/{chunk-VZ5MD32A.js → chunk-GVW7AU57.js} +190 -254
- package/dist/{chunk-AV2PV7NE.js → chunk-VHV2ZDKY.js} +4 -40
- package/dist/{domEditingLayers-4KRREI5C.js → domEditingLayers-SA5KLSSS.js} +4 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.html +1 -1
- package/dist/index.js +1501 -818
- package/dist/player.js +2 -2
- package/package.json +10 -10
- package/src/components/editor/DomEditOverlay.tsx +3 -15
- package/src/components/editor/LayersPanel.opaque.test.ts +176 -0
- package/src/components/editor/LayersPanel.tsx +41 -10
- package/src/components/editor/clickAfterPreventedPress.test.tsx +17 -1
- package/src/components/editor/domEditInlineText.ts +1 -16
- package/src/components/editor/domEditOverlayBasis.ts +7 -2
- package/src/components/editor/domEditOverlayCrop.test.ts +1 -1
- package/src/components/editor/domEditOverlayCrop.ts +17 -3
- package/src/components/editor/domEditOverlayGeometry.ts +64 -139
- package/src/components/editor/domEditSelectionRules.ts +138 -0
- package/src/components/editor/domEditing.test.ts +6 -28
- package/src/components/editor/domEditingDom.preview.test.ts +3 -3
- package/src/components/editor/domEditingDom.ts +3 -76
- package/src/components/editor/domEditingElement.ts +19 -240
- package/src/components/editor/domEditingGroups.ts +0 -31
- package/src/components/editor/domEditingLayers.ts +95 -100
- package/src/components/editor/domEditingRootLayer.ts +35 -30
- package/src/components/editor/domEditingTypes.ts +10 -0
- package/src/components/editor/gestureUndoRevert.ts +18 -1
- package/src/components/editor/inlineTextStyleRange.fill.test.ts +129 -0
- package/src/components/editor/inlineTextStyleRange.test.ts +0 -82
- package/src/components/editor/layerKind.ts +2 -19
- package/src/components/editor/layersPanelSort.ts +2 -2
- package/src/components/editor/manualEdits.ts +1 -0
- package/src/components/editor/manualEditsSnapshot.ts +10 -0
- package/src/components/editor/manualOffsetDrag.test.ts +1 -1
- package/src/components/editor/manualOffsetDrag.ts +7 -1
- package/src/components/editor/marqueeCommit.ts +47 -4
- package/src/components/editor/plainTranslate.ts +35 -16
- package/src/components/editor/previewDrafts.test.ts +263 -0
- package/src/components/editor/previewDrafts.ts +73 -0
- package/src/components/editor/previewGestureStarts.ts +73 -10
- package/src/components/editor/previewLayers.test.ts +308 -0
- package/src/components/editor/previewLayers.ts +164 -0
- package/src/components/editor/previewOverlayRects.test.ts +316 -0
- package/src/components/editor/previewOverlayRects.ts +150 -0
- package/src/components/editor/previewPointerTargets.test.ts +327 -0
- package/src/components/editor/previewSelection.test.ts +481 -0
- package/src/components/editor/previewSelection.ts +516 -0
- package/src/components/editor/probeSourceElement.ts +19 -1
- package/src/components/editor/propertyPanelFill.tsx +5 -1
- package/src/components/editor/resizeDraft.ts +38 -0
- package/src/components/editor/useDomEditOverlayGestures.ts +2 -2
- package/src/components/editor/useDomEditOverlayRects.ts +80 -1
- package/src/components/editor/useInlineTextEditing.tsx +1 -6
- package/src/components/editor/useLayerDrag.ts +1 -1
- package/src/components/nle/NLEPreview.slowBoot.test.ts +0 -1
- package/src/hooks/domEditDeleteMembers.test.ts +7 -0
- package/src/hooks/domSelectionTestHarness.ts +1 -1
- package/src/hooks/domSelectionTimelineMirror.ts +3 -1
- package/src/hooks/timelineTimingSync.ts +4 -1
- package/src/hooks/useDomEditSession.test.tsx +23 -1
- package/src/hooks/useDomEditSession.ts +2 -1
- package/src/hooks/useDomSelection.ts +63 -47
- package/src/hooks/useEditorSave.test.tsx +22 -1
- package/src/hooks/useEditorSave.ts +3 -1
- package/src/hooks/useGsapSelectionHandlers.test.tsx +17 -0
- package/src/hooks/useGsapSelectionHandlers.ts +2 -1
- package/src/hooks/usePreviewInteraction.test.ts +10 -2
- package/src/hooks/usePreviewInteraction.ts +9 -5
- package/src/hooks/useProjectFileWriter.ts +7 -3
- package/src/hooks/useStudioSelectionPublisher.test.tsx +50 -0
- package/src/hooks/useStudioSelectionPublisher.ts +9 -7
- package/src/hooks/useTimelineSelectionPreviewSync.test.tsx +30 -0
- package/src/hooks/useTimelineSelectionPreviewSync.ts +7 -2
- package/src/player/lib/layerOrdering.ts +2 -11
- package/src/player/lib/previewChannel.ts +4 -3
- package/src/player/lib/previewElements.ts +143 -3
- package/src/styles/hex-baseline.json +1 -2
- package/src/test-setup.ts +2 -0
- package/src/utils/gsapSoftReload.ts +1 -1
- package/src/utils/studioFileHistory.ts +1 -1
- package/src/utils/studioHelpers.ts +27 -17
- package/src/utils/studioPreviewHelpers.test.ts +8 -8
- package/src/utils/studioPreviewHelpers.ts +26 -242
- package/src/utils/studioSaveDiagnostics.test.ts +34 -0
- package/src/utils/studioSaveDiagnostics.ts +35 -6
- package/src/utils/timelineCompositionInsert.ts +3 -1
- package/src/components/editor/domEditOverlayTransform.ts +0 -126
package/dist/index.js
CHANGED
|
@@ -59,8 +59,10 @@ import {
|
|
|
59
59
|
postRuntimeControlMessage,
|
|
60
60
|
previewClipManifest,
|
|
61
61
|
previewComputedStyles,
|
|
62
|
+
previewEditingClient,
|
|
62
63
|
previewFrameOpaque,
|
|
63
64
|
previewReloadBegun,
|
|
65
|
+
previewRequest,
|
|
64
66
|
previewSeekPainted,
|
|
65
67
|
previewStageSize,
|
|
66
68
|
readStudioUiPreferences,
|
|
@@ -87,7 +89,7 @@ import {
|
|
|
87
89
|
whileScriptWrites,
|
|
88
90
|
writeStudioUiPreferences,
|
|
89
91
|
zoomToSelectedClips
|
|
90
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-4QQMX4BX.js";
|
|
91
93
|
import {
|
|
92
94
|
Button,
|
|
93
95
|
ContextMenu,
|
|
@@ -136,25 +138,31 @@ import {
|
|
|
136
138
|
buildDomEditStylePatchOperation,
|
|
137
139
|
buildDomEditTextPatchOperation,
|
|
138
140
|
buildTextFieldChildLocator,
|
|
141
|
+
capabilityFacts,
|
|
142
|
+
chainLocked,
|
|
139
143
|
collectDomEditLayerItems,
|
|
144
|
+
coversCompositionRoot,
|
|
140
145
|
createDomEditLayerWalkCache,
|
|
141
146
|
domEditSelectionToFacts,
|
|
142
147
|
drainPendingLayerMutations,
|
|
148
|
+
existsInSourceFile,
|
|
143
149
|
findElementForSelection,
|
|
144
150
|
findElementForTimelineElement,
|
|
145
151
|
findPreviewNode,
|
|
146
152
|
getDomEditLayerKey,
|
|
147
153
|
getDomEditTargetKey,
|
|
148
|
-
getDomLayerPatchTarget,
|
|
149
154
|
isElementComputedVisible,
|
|
150
155
|
isTextEditableSelection,
|
|
151
156
|
liveLayerElement,
|
|
152
157
|
readHfId,
|
|
153
|
-
resolveAllVisualDomEditTargets,
|
|
154
158
|
resolveDomEditSelection,
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
selectionLookups,
|
|
160
|
+
selectionTargetIndex,
|
|
161
|
+
serializeDomEditTextFields,
|
|
162
|
+
timelineElementLookup
|
|
163
|
+
} from "./chunk-GVW7AU57.js";
|
|
157
164
|
import {
|
|
165
|
+
CURATED_STYLE_PROPERTIES,
|
|
158
166
|
LAYER_REVEAL_PRIOR_POSITION_ATTR,
|
|
159
167
|
LAYER_REVEAL_PRIOR_Z_ATTR,
|
|
160
168
|
STUDIO_FLAT_INSPECTOR_ENABLED,
|
|
@@ -162,6 +170,7 @@ import {
|
|
|
162
170
|
STUDIO_SDK_CUTOVER_FAMILIES,
|
|
163
171
|
STUDIO_SDK_RESOLVER_SHADOW_ENABLED,
|
|
164
172
|
applyMediaMetadataFromElement,
|
|
173
|
+
buildElementLabel,
|
|
165
174
|
buildProjectApiPath,
|
|
166
175
|
buildProjectHash,
|
|
167
176
|
buildStableSelector,
|
|
@@ -176,7 +185,9 @@ import {
|
|
|
176
185
|
formatCssColor,
|
|
177
186
|
furthestClipEndFromDocument,
|
|
178
187
|
getAdapterDuration,
|
|
188
|
+
getDataAttributes,
|
|
179
189
|
getDefaultStaticSeekPlaybackClock,
|
|
190
|
+
getInlineStyles,
|
|
180
191
|
getLogicalOpacity,
|
|
181
192
|
getSelectorIndex,
|
|
182
193
|
getSourceFileForElement,
|
|
@@ -206,6 +217,7 @@ import {
|
|
|
206
217
|
readTimelineElementZIndex,
|
|
207
218
|
readTimelineText,
|
|
208
219
|
releaseStaticSeekCache,
|
|
220
|
+
resolveElementSourceFile,
|
|
209
221
|
resolveMediaElement,
|
|
210
222
|
resolvePickerColor,
|
|
211
223
|
resolveStaticSeekFallback,
|
|
@@ -222,7 +234,7 @@ import {
|
|
|
222
234
|
toHexColor,
|
|
223
235
|
withSelectorIndexPass,
|
|
224
236
|
wrapTimeline
|
|
225
|
-
} from "./chunk-
|
|
237
|
+
} from "./chunk-VHV2ZDKY.js";
|
|
226
238
|
import {
|
|
227
239
|
MediaFetchError,
|
|
228
240
|
mediaUrlSourceOptions,
|
|
@@ -2851,21 +2863,12 @@ function getTimelinePlayheadTransform(time, pixelsPerSecond, contentOrigin, atRe
|
|
|
2851
2863
|
}
|
|
2852
2864
|
|
|
2853
2865
|
// src/player/lib/layerOrdering.ts
|
|
2866
|
+
import { elementZIndex } from "@hyperframes/core/runtime/editing-port";
|
|
2854
2867
|
function getElementZIndex(element) {
|
|
2855
2868
|
try {
|
|
2856
2869
|
const prior = readLayerRevealPriorZ(element);
|
|
2857
2870
|
if (prior != null) return prior;
|
|
2858
|
-
|
|
2859
|
-
if (inline && inline !== "auto") {
|
|
2860
|
-
const parsed2 = parseInt(inline, 10);
|
|
2861
|
-
if (Number.isFinite(parsed2)) return parsed2;
|
|
2862
|
-
}
|
|
2863
|
-
const win = element.ownerDocument?.defaultView;
|
|
2864
|
-
if (!win) return 0;
|
|
2865
|
-
const value = win.getComputedStyle(element).zIndex;
|
|
2866
|
-
if (value === "auto" || value === "") return 0;
|
|
2867
|
-
const parsed = parseInt(value, 10);
|
|
2868
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
2871
|
+
return elementZIndex(element);
|
|
2869
2872
|
} catch {
|
|
2870
2873
|
return 0;
|
|
2871
2874
|
}
|
|
@@ -9819,11 +9822,13 @@ var STUDIO_SAVE_ATTEMPT_PROPERTY = "__studioSaveAttempt";
|
|
|
9819
9822
|
var StudioSaveHttpError = class extends Error {
|
|
9820
9823
|
statusCode;
|
|
9821
9824
|
alreadyToasted;
|
|
9825
|
+
heldFile;
|
|
9822
9826
|
constructor(message, statusCode, options = {}) {
|
|
9823
9827
|
super(message);
|
|
9824
9828
|
this.name = "StudioSaveHttpError";
|
|
9825
9829
|
this.statusCode = statusCode;
|
|
9826
9830
|
this.alreadyToasted = options.alreadyToasted ?? false;
|
|
9831
|
+
this.heldFile = options.heldFile ?? false;
|
|
9827
9832
|
}
|
|
9828
9833
|
};
|
|
9829
9834
|
var StudioSaveNetworkError = class extends Error {
|
|
@@ -9944,6 +9949,20 @@ function trackStudioSaveFailure(input) {
|
|
|
9944
9949
|
function trackStudioEditBlocked(input) {
|
|
9945
9950
|
trackStudioEvent("edit_blocked", buildStudioSaveFailureProperties(input));
|
|
9946
9951
|
}
|
|
9952
|
+
var HELD_FILE_WORDS = {
|
|
9953
|
+
busy: (file) => `${file} is open in another program. Close it there, then try again.`,
|
|
9954
|
+
permission: (file) => `${file} can't be changed: it is read-only or protected. Check its permissions, then try again.`
|
|
9955
|
+
};
|
|
9956
|
+
function heldFileMessage(body, path) {
|
|
9957
|
+
if (!path) return null;
|
|
9958
|
+
try {
|
|
9959
|
+
const why = JSON.parse(body).why;
|
|
9960
|
+
if (why !== "busy" && why !== "permission") return null;
|
|
9961
|
+
return HELD_FILE_WORDS[why](path.split(/[\\/]/).pop() ?? path);
|
|
9962
|
+
} catch {
|
|
9963
|
+
return null;
|
|
9964
|
+
}
|
|
9965
|
+
}
|
|
9947
9966
|
async function createStudioSaveHttpError(response, fallbackMessage, options = {}) {
|
|
9948
9967
|
let body = "";
|
|
9949
9968
|
try {
|
|
@@ -9952,9 +9971,11 @@ async function createStudioSaveHttpError(response, fallbackMessage, options = {}
|
|
|
9952
9971
|
body = "";
|
|
9953
9972
|
}
|
|
9954
9973
|
const detail = body.trim().slice(0, 300);
|
|
9955
|
-
const
|
|
9956
|
-
|
|
9974
|
+
const held = heldFileMessage(body, options.path);
|
|
9975
|
+
const message = held ?? (detail ? `${fallbackMessage} (${response.status}): ${detail}` : `${fallbackMessage} (${response.status})`);
|
|
9976
|
+
return new StudioSaveHttpError(message, response.status, { ...options, heldFile: held !== null });
|
|
9957
9977
|
}
|
|
9978
|
+
var heldFileWords = (error) => error instanceof StudioSaveHttpError && error.heldFile ? error.message : null;
|
|
9958
9979
|
async function retryStudioSave(operation, options = {}) {
|
|
9959
9980
|
const retries = options.retries ?? 3;
|
|
9960
9981
|
const baseDelayMs = options.baseDelayMs ?? 500;
|
|
@@ -16960,11 +16981,11 @@ function escapeRegex(s) {
|
|
|
16960
16981
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16961
16982
|
}
|
|
16962
16983
|
function tagAttribute(tag, name) {
|
|
16963
|
-
return scanHtmlOpeningTags(tag)[0]?.attributes.find((
|
|
16984
|
+
return scanHtmlOpeningTags(tag)[0]?.attributes.find((attr2) => attr2.name === name.toLowerCase());
|
|
16964
16985
|
}
|
|
16965
16986
|
function patchTagAttribute(tag, name, edit) {
|
|
16966
16987
|
if (edit.kind === "remove") {
|
|
16967
|
-
const attributes = scanHtmlOpeningTags(tag)[0]?.attributes.filter((
|
|
16988
|
+
const attributes = scanHtmlOpeningTags(tag)[0]?.attributes.filter((attr3) => attr3.name === name.toLowerCase()) ?? [];
|
|
16968
16989
|
const parts = [];
|
|
16969
16990
|
let cursor = 0;
|
|
16970
16991
|
for (const attribute of attributes) {
|
|
@@ -16976,9 +16997,9 @@ function patchTagAttribute(tag, name, edit) {
|
|
|
16976
16997
|
parts.push(tag.slice(cursor));
|
|
16977
16998
|
return parts.join("");
|
|
16978
16999
|
}
|
|
16979
|
-
const
|
|
17000
|
+
const attr2 = tagAttribute(tag, name);
|
|
16980
17001
|
const replacement = edit.kind === "boolean" ? name : `${name}="${escapeHtmlAttribute(edit.value)}"`;
|
|
16981
|
-
if (
|
|
17002
|
+
if (attr2) return tag.slice(0, attr2.start) + replacement + tag.slice(attr2.end);
|
|
16982
17003
|
return tag.endsWith("/") ? `${tag.slice(0, -1).trimEnd()} ${replacement} /` : `${tag} ${replacement}`;
|
|
16983
17004
|
}
|
|
16984
17005
|
function escapeStyleAttributeValue(value, quote) {
|
|
@@ -17108,8 +17129,8 @@ function replaceTagAtMatch(html2, match, newTag) {
|
|
|
17108
17129
|
}
|
|
17109
17130
|
function findTagByAttribute(html2, name, value) {
|
|
17110
17131
|
const found = scanHtmlOpeningTags(html2).find((tag) => {
|
|
17111
|
-
const
|
|
17112
|
-
return tag.closed &&
|
|
17132
|
+
const attr2 = tag.attributes.find((attr3) => attr3.name === name);
|
|
17133
|
+
return tag.closed && attr2?.kind === "value" && decodeAuthoredAttribute(attr2.value) === value;
|
|
17113
17134
|
});
|
|
17114
17135
|
return found ? { tag: html2.slice(found.start, found.bodyEnd), start: found.start, end: found.bodyEnd } : null;
|
|
17115
17136
|
}
|
|
@@ -17117,8 +17138,8 @@ function findTagByClass(html2, target) {
|
|
|
17117
17138
|
const classMatch = target.selector?.match(/^\.([a-zA-Z0-9_-]+)$/);
|
|
17118
17139
|
if (!classMatch) return null;
|
|
17119
17140
|
const found = scanHtmlOpeningTags(html2).filter((tag) => {
|
|
17120
|
-
const
|
|
17121
|
-
return tag.closed &&
|
|
17141
|
+
const attr2 = tag.attributes.find((attr3) => attr3.name === "class");
|
|
17142
|
+
return tag.closed && attr2?.kind === "value" && decodeAuthoredAttribute(attr2.value).split(/\s+/).includes(classMatch[1]);
|
|
17122
17143
|
})[target.selectorIndex ?? 0];
|
|
17123
17144
|
return found ? { tag: html2.slice(found.start, found.bodyEnd), start: found.start, end: found.bodyEnd } : null;
|
|
17124
17145
|
}
|
|
@@ -17139,28 +17160,28 @@ function findTagByTarget(html2, target) {
|
|
|
17139
17160
|
}
|
|
17140
17161
|
return findTagByClass(html2, target);
|
|
17141
17162
|
}
|
|
17142
|
-
function readAttributeByTarget(html2, target,
|
|
17163
|
+
function readAttributeByTarget(html2, target, attr2) {
|
|
17143
17164
|
const match = findTagByTarget(html2, target);
|
|
17144
17165
|
if (!match) return void 0;
|
|
17145
|
-
return readTagAttribute(match.tag,
|
|
17166
|
+
return readTagAttribute(match.tag, attr2.startsWith("data-") ? attr2 : `data-${attr2}`);
|
|
17146
17167
|
}
|
|
17147
|
-
function readTagAttribute(tag,
|
|
17148
|
-
const value = tagAttribute(tag,
|
|
17168
|
+
function readTagAttribute(tag, attr2) {
|
|
17169
|
+
const value = tagAttribute(tag, attr2);
|
|
17149
17170
|
return value?.kind === "value" ? decodeAuthoredAttribute(value.value) : void 0;
|
|
17150
17171
|
}
|
|
17151
17172
|
function readTagSnippetByTarget(html2, target) {
|
|
17152
17173
|
const match = findTagByTarget(html2, target);
|
|
17153
17174
|
return match?.tag;
|
|
17154
17175
|
}
|
|
17155
|
-
function patchAttributeByTarget(html2, target,
|
|
17176
|
+
function patchAttributeByTarget(html2, target, attr2, value) {
|
|
17156
17177
|
const match = findTagByTarget(html2, target);
|
|
17157
17178
|
if (!match) return html2;
|
|
17158
|
-
const name =
|
|
17179
|
+
const name = attr2.startsWith("data-") ? attr2 : `data-${attr2}`;
|
|
17159
17180
|
const edit = value === null ? { kind: "remove" } : { kind: "value", value };
|
|
17160
17181
|
return replaceTagAtMatch(html2, match, patchTagAttribute(match.tag, name, edit));
|
|
17161
17182
|
}
|
|
17162
|
-
function patchAttribute(html2, elementId2,
|
|
17163
|
-
return patchAttributeByTarget(html2, { id: elementId2 },
|
|
17183
|
+
function patchAttribute(html2, elementId2, attr2, value) {
|
|
17184
|
+
return patchAttributeByTarget(html2, { id: elementId2 }, attr2, value);
|
|
17164
17185
|
}
|
|
17165
17186
|
function patchTextContent(html2, elementId2, value) {
|
|
17166
17187
|
return patchTextContentByTarget(html2, { id: elementId2 }, value);
|
|
@@ -17198,26 +17219,26 @@ var HTML_BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
17198
17219
|
"reversed",
|
|
17199
17220
|
"selected"
|
|
17200
17221
|
]);
|
|
17201
|
-
function patchHtmlAttributeInTag(tag,
|
|
17222
|
+
function patchHtmlAttributeInTag(tag, attr2, value) {
|
|
17202
17223
|
if (!tag) return tag;
|
|
17203
17224
|
let edit;
|
|
17204
|
-
if (HTML_BOOLEAN_ATTRIBUTES.has(
|
|
17225
|
+
if (HTML_BOOLEAN_ATTRIBUTES.has(attr2)) {
|
|
17205
17226
|
if (value === null || value === "" || value === "false") edit = { kind: "remove" };
|
|
17206
17227
|
else {
|
|
17207
|
-
if (tagAttribute(tag,
|
|
17228
|
+
if (tagAttribute(tag, attr2)) return tag;
|
|
17208
17229
|
edit = { kind: "boolean" };
|
|
17209
17230
|
}
|
|
17210
17231
|
} else edit = value === null ? { kind: "remove" } : { kind: "value", value };
|
|
17211
|
-
const newTag = patchTagAttribute(tag,
|
|
17232
|
+
const newTag = patchTagAttribute(tag, attr2, edit);
|
|
17212
17233
|
return newTag;
|
|
17213
17234
|
}
|
|
17214
|
-
function patchHtmlAttribute(html2, elementId2,
|
|
17215
|
-
return patchHtmlAttributeByTarget(html2, { id: elementId2 },
|
|
17235
|
+
function patchHtmlAttribute(html2, elementId2, attr2, value) {
|
|
17236
|
+
return patchHtmlAttributeByTarget(html2, { id: elementId2 }, attr2, value);
|
|
17216
17237
|
}
|
|
17217
|
-
function patchHtmlAttributeByTarget(html2, target,
|
|
17238
|
+
function patchHtmlAttributeByTarget(html2, target, attr2, value) {
|
|
17218
17239
|
const match = findTagByTarget(html2, target);
|
|
17219
17240
|
if (!match) return html2;
|
|
17220
|
-
const newTag = patchHtmlAttributeInTag(match.tag,
|
|
17241
|
+
const newTag = patchHtmlAttributeInTag(match.tag, attr2, value);
|
|
17221
17242
|
return replaceTagAtMatch(html2, match, newTag);
|
|
17222
17243
|
}
|
|
17223
17244
|
function patchTextContentByTarget(html2, target, value) {
|
|
@@ -17268,20 +17289,20 @@ function applyPatchByTarget(html2, target, op) {
|
|
|
17268
17289
|
// src/utils/studioFileMutationCoordinator.ts
|
|
17269
17290
|
var mutationQueues = /* @__PURE__ */ new WeakMap();
|
|
17270
17291
|
function serializeStudioFileMutation(writer, targetPath, task) {
|
|
17271
|
-
let
|
|
17272
|
-
if (!
|
|
17273
|
-
|
|
17274
|
-
mutationQueues.set(writer,
|
|
17292
|
+
let queues2 = mutationQueues.get(writer);
|
|
17293
|
+
if (!queues2) {
|
|
17294
|
+
queues2 = /* @__PURE__ */ new Map();
|
|
17295
|
+
mutationQueues.set(writer, queues2);
|
|
17275
17296
|
}
|
|
17276
|
-
const prior =
|
|
17297
|
+
const prior = queues2.get(targetPath) ?? Promise.resolve();
|
|
17277
17298
|
const next = prior.then(task, task);
|
|
17278
|
-
|
|
17299
|
+
queues2.set(targetPath, next);
|
|
17279
17300
|
void next.then(
|
|
17280
17301
|
() => {
|
|
17281
|
-
if (
|
|
17302
|
+
if (queues2?.get(targetPath) === next) queues2.delete(targetPath);
|
|
17282
17303
|
},
|
|
17283
17304
|
() => {
|
|
17284
|
-
if (
|
|
17305
|
+
if (queues2?.get(targetPath) === next) queues2.delete(targetPath);
|
|
17285
17306
|
}
|
|
17286
17307
|
);
|
|
17287
17308
|
return next;
|
|
@@ -17312,7 +17333,7 @@ async function readProjectFileContent(pid, path) {
|
|
|
17312
17333
|
buildProjectApiPath(pid, `/files/${encodeURIComponent(path)}`)
|
|
17313
17334
|
);
|
|
17314
17335
|
if (!response.ok) {
|
|
17315
|
-
throw await createStudioSaveHttpError(response, `Failed to read ${path}
|
|
17336
|
+
throw await createStudioSaveHttpError(response, `Failed to read ${path}`, { path });
|
|
17316
17337
|
}
|
|
17317
17338
|
const data = await response.json();
|
|
17318
17339
|
if (typeof data.content !== "string") {
|
|
@@ -17446,7 +17467,7 @@ function toProjectPath(sourceFile, path) {
|
|
|
17446
17467
|
function livePathsOf(live) {
|
|
17447
17468
|
const paths = /* @__PURE__ */ new Set();
|
|
17448
17469
|
for (const el of [live, ...Array.from(live.querySelectorAll("*"))]) {
|
|
17449
|
-
for (const
|
|
17470
|
+
for (const attr2 of PATH_ATTRS) paths.add(el.getAttribute(attr2) ?? "");
|
|
17450
17471
|
for (const match of (el.getAttribute("style") ?? "").matchAll(CSS_URL)) paths.add(match[2]);
|
|
17451
17472
|
}
|
|
17452
17473
|
return paths;
|
|
@@ -17463,9 +17484,9 @@ function authoredMarkup(authored, live, sourceFile) {
|
|
|
17463
17484
|
};
|
|
17464
17485
|
const copy = authored.cloneNode(true);
|
|
17465
17486
|
for (const el of [copy, ...Array.from(copy.querySelectorAll("*"))]) {
|
|
17466
|
-
for (const
|
|
17467
|
-
const value = el.getAttribute(
|
|
17468
|
-
if (value) el.setAttribute(
|
|
17487
|
+
for (const attr2 of PATH_ATTRS) {
|
|
17488
|
+
const value = el.getAttribute(attr2);
|
|
17489
|
+
if (value) el.setAttribute(attr2, rebase(value.trim()));
|
|
17469
17490
|
}
|
|
17470
17491
|
const style = el.getAttribute("style");
|
|
17471
17492
|
if (style) {
|
|
@@ -17485,7 +17506,7 @@ function liveMarkupWithoutPreviewMarks(live) {
|
|
|
17485
17506
|
for (const canvas of copy.querySelectorAll(`[${PREVIEW_VIDEO_CANVAS_ATTR}]`)) canvas.remove();
|
|
17486
17507
|
for (const el of [copy, ...Array.from(copy.querySelectorAll("*"))]) {
|
|
17487
17508
|
if (el.hasAttribute(STUDIO_PREVIEW_LAZY_ATTR)) el.removeAttribute("loading");
|
|
17488
|
-
for (const
|
|
17509
|
+
for (const attr2 of PREVIEW_ONLY_ATTRS) el.removeAttribute(attr2);
|
|
17489
17510
|
}
|
|
17490
17511
|
return copy.outerHTML;
|
|
17491
17512
|
}
|
|
@@ -17764,8 +17785,8 @@ function finalizeSoftReload(win, currentTime) {
|
|
|
17764
17785
|
}
|
|
17765
17786
|
function applySoftReloadFinalization(iframe, currentTime) {
|
|
17766
17787
|
const win = iframe?.contentWindow;
|
|
17767
|
-
if (!win?.__hfForceTimelineRebind) return false;
|
|
17768
17788
|
try {
|
|
17789
|
+
if (!win?.__hfForceTimelineRebind) return false;
|
|
17769
17790
|
if (win.__hfSuppressSceneMutations) {
|
|
17770
17791
|
win.__hfSuppressSceneMutations(() => finalizeSoftReload(win, currentTime));
|
|
17771
17792
|
} else {
|
|
@@ -18222,7 +18243,9 @@ async function readFileContent(projectId, targetPath) {
|
|
|
18222
18243
|
`/api/projects/${encodeURIComponent(projectId)}/files/${encodeURIComponent(targetPath)}`
|
|
18223
18244
|
);
|
|
18224
18245
|
if (!response.ok) {
|
|
18225
|
-
throw
|
|
18246
|
+
throw await createStudioSaveHttpError(response, `Failed to read ${targetPath}`, {
|
|
18247
|
+
path: targetPath
|
|
18248
|
+
});
|
|
18226
18249
|
}
|
|
18227
18250
|
const data = await response.json();
|
|
18228
18251
|
if (typeof data.content !== "string") {
|
|
@@ -18832,24 +18855,24 @@ async function persistTimelineBatchEdit(input) {
|
|
|
18832
18855
|
recordEdit: input.recordEdit
|
|
18833
18856
|
});
|
|
18834
18857
|
}
|
|
18835
|
-
async function readSavedAttribute(projectId, targetPath, patchTarget,
|
|
18858
|
+
async function readSavedAttribute(projectId, targetPath, patchTarget, attr2, writeFile) {
|
|
18836
18859
|
if (!projectId || !patchTarget) return void 0;
|
|
18837
18860
|
const html2 = await serializeStudioFileMutations(
|
|
18838
18861
|
writeFile,
|
|
18839
18862
|
[targetPath],
|
|
18840
18863
|
() => readFileContent(projectId, targetPath)
|
|
18841
18864
|
).catch(() => null);
|
|
18842
|
-
return html2 === null ? void 0 : readTargetAttribute(html2, patchTarget,
|
|
18865
|
+
return html2 === null ? void 0 : readTargetAttribute(html2, patchTarget, attr2);
|
|
18843
18866
|
}
|
|
18844
|
-
function readTargetAttribute(html2, patchTarget,
|
|
18867
|
+
function readTargetAttribute(html2, patchTarget, attr2) {
|
|
18845
18868
|
if (readTagSnippetByTarget(html2, patchTarget) === void 0) return void 0;
|
|
18846
|
-
return readAttributeByTarget(html2, patchTarget,
|
|
18869
|
+
return readAttributeByTarget(html2, patchTarget, attr2) ?? null;
|
|
18847
18870
|
}
|
|
18848
18871
|
async function persistElementAttribute({
|
|
18849
18872
|
projectId,
|
|
18850
18873
|
targetPath,
|
|
18851
18874
|
patchTarget,
|
|
18852
|
-
attr,
|
|
18875
|
+
attr: attr2,
|
|
18853
18876
|
value,
|
|
18854
18877
|
label,
|
|
18855
18878
|
writeProjectFile,
|
|
@@ -18863,10 +18886,10 @@ async function persistElementAttribute({
|
|
|
18863
18886
|
if (readTagSnippetByTarget(before, patchTarget) === void 0) {
|
|
18864
18887
|
throw new Error(`Unable to patch element in ${targetPath}`);
|
|
18865
18888
|
}
|
|
18866
|
-
const previousValue = readAttributeByTarget(before, patchTarget,
|
|
18889
|
+
const previousValue = readAttributeByTarget(before, patchTarget, attr2) ?? null;
|
|
18867
18890
|
onFileRead(previousValue);
|
|
18868
18891
|
patchLive2(value);
|
|
18869
|
-
const operation = { type: "attribute", property:
|
|
18892
|
+
const operation = { type: "attribute", property: attr2, value };
|
|
18870
18893
|
const patched = applyPatchByTarget(before, patchTarget, operation);
|
|
18871
18894
|
pendingTimelineEditPathRef.current.add(targetPath);
|
|
18872
18895
|
try {
|
|
@@ -21654,15 +21677,6 @@ function cssPropertyName(property) {
|
|
|
21654
21677
|
function isManualGeometryStyleProperty(property) {
|
|
21655
21678
|
return property === "left" || property === "top" || property === "width" || property === "height";
|
|
21656
21679
|
}
|
|
21657
|
-
function getEventTargetElement(target) {
|
|
21658
|
-
if (!target || typeof target !== "object") return null;
|
|
21659
|
-
const maybeNode = target;
|
|
21660
|
-
if (maybeNode.nodeType === 1) return target;
|
|
21661
|
-
if (maybeNode.nodeType === 3 && maybeNode.parentElement) {
|
|
21662
|
-
return maybeNode.parentElement;
|
|
21663
|
-
}
|
|
21664
|
-
return null;
|
|
21665
|
-
}
|
|
21666
21680
|
function shouldIgnoreHistoryShortcut(target) {
|
|
21667
21681
|
return isTypingTarget(target);
|
|
21668
21682
|
}
|
|
@@ -21676,12 +21690,21 @@ function historyTooltipLabel(action, lastAction) {
|
|
|
21676
21690
|
const verb = action === "undo" ? "Undo" : "Redo";
|
|
21677
21691
|
return lastAction ? `${verb} ${lastAction} (${shortcut})` : `${verb} (${shortcut})`;
|
|
21678
21692
|
}
|
|
21679
|
-
function
|
|
21693
|
+
function matchesByClipId(selection, element, file, value, clipIdScope) {
|
|
21694
|
+
if (!clipIdScope || !selection.handle) return false;
|
|
21695
|
+
if (element.domId || element.hfId || element.selector) return false;
|
|
21696
|
+
return element.id === value && (element.sourceFile || clipIdScope) === file;
|
|
21697
|
+
}
|
|
21698
|
+
function matchesByDomId(selection, element, selectionSourceFile, clipIdScope) {
|
|
21680
21699
|
if (!selection.id) return false;
|
|
21700
|
+
if (matchesByClipId(selection, element, selectionSourceFile, selection.id, clipIdScope))
|
|
21701
|
+
return true;
|
|
21681
21702
|
return element.domId === selection.id && (element.sourceFile || "index.html") === selectionSourceFile;
|
|
21682
21703
|
}
|
|
21683
|
-
function matchesByHfId(selection, element, selectionSourceFile) {
|
|
21704
|
+
function matchesByHfId(selection, element, selectionSourceFile, clipIdScope) {
|
|
21684
21705
|
if (!selection.hfId) return false;
|
|
21706
|
+
if (matchesByClipId(selection, element, selectionSourceFile, selection.hfId, clipIdScope))
|
|
21707
|
+
return true;
|
|
21685
21708
|
return element.hfId === selection.hfId && (element.sourceFile || "index.html") === selectionSourceFile;
|
|
21686
21709
|
}
|
|
21687
21710
|
function matchesByCompositionHost(selection, element) {
|
|
@@ -21692,11 +21715,11 @@ function matchesBySelector(selection, element) {
|
|
|
21692
21715
|
if (!selection.selector) return false;
|
|
21693
21716
|
return element.selector === selection.selector && (element.selectorIndex ?? 0) === (selection.selectorIndex ?? 0) && (element.sourceFile ?? "index.html") === selection.sourceFile;
|
|
21694
21717
|
}
|
|
21695
|
-
function findMatchingTimelineElementId(selection, elements) {
|
|
21718
|
+
function findMatchingTimelineElementId(selection, elements, clipIdScope) {
|
|
21696
21719
|
const selectionSourceFile = selection.sourceFile || "index.html";
|
|
21697
|
-
const byId = selection.id ? elements.find((el) => matchesByDomId(selection, el, selectionSourceFile)) : void 0;
|
|
21720
|
+
const byId = selection.id ? elements.find((el) => matchesByDomId(selection, el, selectionSourceFile, clipIdScope)) : void 0;
|
|
21698
21721
|
if (byId) return byId.key ?? byId.id;
|
|
21699
|
-
const byHfId = selection.hfId ? elements.find((el) => matchesByHfId(selection, el, selectionSourceFile)) : void 0;
|
|
21722
|
+
const byHfId = selection.hfId ? elements.find((el) => matchesByHfId(selection, el, selectionSourceFile, clipIdScope)) : void 0;
|
|
21700
21723
|
if (byHfId) return byHfId.key ?? byHfId.id;
|
|
21701
21724
|
const bySelector = selection.selector ? elements.find((el) => matchesBySelector(selection, el)) : void 0;
|
|
21702
21725
|
if (bySelector) return bySelector.key ?? bySelector.id;
|
|
@@ -21726,8 +21749,9 @@ function findTimelineIdByAncestor(element, elements, sourceFile) {
|
|
|
21726
21749
|
}
|
|
21727
21750
|
return null;
|
|
21728
21751
|
}
|
|
21729
|
-
function resolveTimelineIdForSelection(selection, elements, activeCompPath) {
|
|
21730
|
-
|
|
21752
|
+
function resolveTimelineIdForSelection(selection, elements, activeCompPath, byClipId = false) {
|
|
21753
|
+
const clipIdScope = byClipId ? activeCompPath || "index.html" : void 0;
|
|
21754
|
+
return findMatchingTimelineElementId(selection, elements, clipIdScope) ?? findTimelineIdByAncestor(
|
|
21731
21755
|
selection.element,
|
|
21732
21756
|
elements,
|
|
21733
21757
|
selection.sourceFile || activeCompPath || "index.html"
|
|
@@ -21801,8 +21825,8 @@ async function resolveAssetHasAudio(projectId, assetPath) {
|
|
|
21801
21825
|
if (!response.ok) return null;
|
|
21802
21826
|
const data = await response.json();
|
|
21803
21827
|
const metadata = isPlainRecord(data) ? data.metadata : void 0;
|
|
21804
|
-
const
|
|
21805
|
-
return typeof
|
|
21828
|
+
const hasAudio2 = isPlainRecord(metadata) ? metadata.hasAudio : void 0;
|
|
21829
|
+
return typeof hasAudio2 === "boolean" ? hasAudio2 : null;
|
|
21806
21830
|
} catch {
|
|
21807
21831
|
return null;
|
|
21808
21832
|
}
|
|
@@ -26102,8 +26126,8 @@ function ClipMenuAttributeItems({ group, element, onClose }) {
|
|
|
26102
26126
|
const state = useClipToolState(element);
|
|
26103
26127
|
const openCropBar = useCropPresetBarStore((s) => s.open);
|
|
26104
26128
|
if (!onSetElementAttributeQuiet) return null;
|
|
26105
|
-
const write = (
|
|
26106
|
-
void onSetElementAttributeQuiet(element,
|
|
26129
|
+
const write = (attr2, value, label) => {
|
|
26130
|
+
void onSetElementAttributeQuiet(element, attr2, value, label);
|
|
26107
26131
|
onClose();
|
|
26108
26132
|
};
|
|
26109
26133
|
if (group === "sound") {
|
|
@@ -26453,9 +26477,9 @@ function ClipMenuAudioItems({
|
|
|
26453
26477
|
doc,
|
|
26454
26478
|
bed,
|
|
26455
26479
|
!ducked,
|
|
26456
|
-
async (
|
|
26480
|
+
async (attr2, value) => {
|
|
26457
26481
|
throwUnlessSaved(
|
|
26458
|
-
await onSetElementAttributeQuiet(element,
|
|
26482
|
+
await onSetElementAttributeQuiet(element, attr2, value, "Duck under voice")
|
|
26459
26483
|
);
|
|
26460
26484
|
},
|
|
26461
26485
|
onGroupClips ? (ids, groupId) => onGroupClips(ids, groupId, "Voice") : void 0
|
|
@@ -26706,8 +26730,8 @@ function probedHasAudioValue(probedHasAudio) {
|
|
|
26706
26730
|
function mutedToggleOps(input) {
|
|
26707
26731
|
const muted = htmlAttr("muted", input.nextMuted ? "true" : null);
|
|
26708
26732
|
if (!input.isVideo) return [muted];
|
|
26709
|
-
const
|
|
26710
|
-
return [muted, dataAttr("has-audio",
|
|
26733
|
+
const hasAudio2 = input.nextMuted ? null : probedHasAudioValue(input.probedHasAudio);
|
|
26734
|
+
return [muted, dataAttr("has-audio", hasAudio2)];
|
|
26711
26735
|
}
|
|
26712
26736
|
function hasAudioToggleOps(next) {
|
|
26713
26737
|
return next ? [dataAttr("has-audio", "true"), htmlAttr("muted", null)] : [dataAttr("has-audio", null), htmlAttr("muted", "true")];
|
|
@@ -30832,9 +30856,9 @@ function collectInlineStyleOps(element, properties, ops) {
|
|
|
30832
30856
|
}
|
|
30833
30857
|
}
|
|
30834
30858
|
function collectAttributeOps(element, attrNames, ops) {
|
|
30835
|
-
for (const
|
|
30836
|
-
const val = element.getAttribute(
|
|
30837
|
-
if (val !== null) ops.push({ type: "attribute", property:
|
|
30859
|
+
for (const attr2 of attrNames) {
|
|
30860
|
+
const val = element.getAttribute(attr2);
|
|
30861
|
+
if (val !== null) ops.push({ type: "attribute", property: attr2, value: val });
|
|
30838
30862
|
}
|
|
30839
30863
|
}
|
|
30840
30864
|
function appendTransformDisplayOps(element, ops) {
|
|
@@ -30899,7 +30923,7 @@ function buildBoxSizePatches(element) {
|
|
|
30899
30923
|
ops.push({ type: "attribute", property: STUDIO_BOX_SIZE_ATTR, value: "true" });
|
|
30900
30924
|
collectAttributeOps(
|
|
30901
30925
|
element,
|
|
30902
|
-
BOX_SIZE_ORIG_ATTRS.map(([
|
|
30926
|
+
BOX_SIZE_ORIG_ATTRS.map(([attr2]) => attr2),
|
|
30903
30927
|
ops
|
|
30904
30928
|
);
|
|
30905
30929
|
return ops;
|
|
@@ -37630,167 +37654,35 @@ function trackPreviewEditResult(feature, method, result) {
|
|
|
37630
37654
|
import { useCallback as useCallback58, useEffect as useEffect50, useRef as useRef67, useState as useState50 } from "react";
|
|
37631
37655
|
|
|
37632
37656
|
// src/utils/studioPreviewHelpers.ts
|
|
37633
|
-
|
|
37634
|
-
|
|
37635
|
-
|
|
37636
|
-
|
|
37637
|
-
|
|
37638
|
-
}
|
|
37639
|
-
function
|
|
37640
|
-
|
|
37641
|
-
return
|
|
37642
|
-
}
|
|
37643
|
-
function
|
|
37644
|
-
const
|
|
37645
|
-
|
|
37646
|
-
|
|
37647
|
-
|
|
37648
|
-
const
|
|
37649
|
-
|
|
37650
|
-
|
|
37651
|
-
|
|
37652
|
-
return {
|
|
37653
|
-
x: (clientX - iframeRect.left) / scaleX,
|
|
37654
|
-
y: (clientY - iframeRect.top) / scaleY,
|
|
37655
|
-
viewport: { width: rootWidth, height: rootHeight }
|
|
37656
|
-
};
|
|
37657
|
-
}
|
|
37658
|
-
var pointerEventsInheritanceFallbackByDocument = /* @__PURE__ */ new WeakMap();
|
|
37659
|
-
function needsPointerEventsInheritanceFallback(doc, win) {
|
|
37660
|
-
const cached5 = pointerEventsInheritanceFallbackByDocument.get(doc);
|
|
37661
|
-
if (cached5 !== void 0) return cached5;
|
|
37662
|
-
const parent = doc.createElement("div");
|
|
37663
|
-
const child = doc.createElement("div");
|
|
37664
|
-
parent.style.pointerEvents = "none";
|
|
37665
|
-
parent.appendChild(child);
|
|
37666
|
-
const host = doc.body ?? doc.documentElement;
|
|
37667
|
-
if (!host) return false;
|
|
37668
|
-
host.appendChild(parent);
|
|
37669
|
-
const needsFallback = win.getComputedStyle(child).pointerEvents !== "none";
|
|
37670
|
-
parent.remove();
|
|
37671
|
-
pointerEventsInheritanceFallbackByDocument.set(doc, needsFallback);
|
|
37672
|
-
return needsFallback;
|
|
37673
|
-
}
|
|
37674
|
-
function hasOwnPointerEventsOverride(el, win) {
|
|
37675
|
-
const value = win.getComputedStyle(el).pointerEvents;
|
|
37676
|
-
return value !== "" && value !== "inherit" && value !== "unset";
|
|
37677
|
-
}
|
|
37678
|
-
function inheritsPointerEventsNoneFromAncestor(el, win) {
|
|
37679
|
-
let current2 = el.parentElement;
|
|
37680
|
-
while (current2) {
|
|
37681
|
-
if (win.getComputedStyle(current2).pointerEvents === "none") {
|
|
37682
|
-
let descendant = el;
|
|
37683
|
-
while (descendant && descendant !== current2) {
|
|
37684
|
-
if (hasOwnPointerEventsOverride(descendant, win)) {
|
|
37685
|
-
return win.getComputedStyle(descendant).pointerEvents === "none";
|
|
37686
|
-
}
|
|
37687
|
-
descendant = descendant.parentElement;
|
|
37688
|
-
}
|
|
37689
|
-
return true;
|
|
37690
|
-
}
|
|
37691
|
-
current2 = current2.parentElement;
|
|
37692
|
-
}
|
|
37693
|
-
return false;
|
|
37694
|
-
}
|
|
37695
|
-
function hasAuthorPointerEventsNone(el) {
|
|
37696
|
-
const win = el.ownerDocument.defaultView;
|
|
37697
|
-
if (!win) return false;
|
|
37698
|
-
if (win.getComputedStyle(el).pointerEvents === "none") return true;
|
|
37699
|
-
if (!needsPointerEventsInheritanceFallback(el.ownerDocument, win)) return false;
|
|
37700
|
-
return inheritsPointerEventsNoneFromAncestor(el, win);
|
|
37701
|
-
}
|
|
37702
|
-
function collectPointerEventsNoneTargets(elements) {
|
|
37703
|
-
const disabled = /* @__PURE__ */ new WeakSet();
|
|
37704
|
-
for (const entry3 of elements) {
|
|
37705
|
-
if (isHtmlElement(entry3) && hasAuthorPointerEventsNone(entry3)) {
|
|
37706
|
-
disabled.add(entry3);
|
|
37707
|
-
}
|
|
37708
|
-
}
|
|
37709
|
-
return disabled;
|
|
37710
|
-
}
|
|
37711
|
-
function filterAuthorInteractiveTargets(elements, activeCompositionPath) {
|
|
37712
|
-
const pointerEventsNoneTargets = collectPointerEventsNoneTargets(elements);
|
|
37713
|
-
return resolveAllVisualDomEditTargets(elements, { activeCompositionPath }).filter(
|
|
37714
|
-
(el) => !pointerEventsNoneTargets.has(el)
|
|
37715
|
-
);
|
|
37716
|
-
}
|
|
37717
|
-
function findGroupAtPoint(doc, x, y) {
|
|
37718
|
-
let best = null;
|
|
37719
|
-
let bestArea = Infinity;
|
|
37720
|
-
for (const group of Array.from(doc.querySelectorAll("[data-hf-group]"))) {
|
|
37721
|
-
let left = Infinity;
|
|
37722
|
-
let top = Infinity;
|
|
37723
|
-
let right = -Infinity;
|
|
37724
|
-
let bottom = -Infinity;
|
|
37725
|
-
for (const member of Array.from(group.children)) {
|
|
37726
|
-
const r = member.getBoundingClientRect();
|
|
37727
|
-
if (r.width === 0 && r.height === 0) continue;
|
|
37728
|
-
left = Math.min(left, r.left);
|
|
37729
|
-
top = Math.min(top, r.top);
|
|
37730
|
-
right = Math.max(right, r.right);
|
|
37731
|
-
bottom = Math.max(bottom, r.bottom);
|
|
37732
|
-
}
|
|
37733
|
-
if (right < left || x < left || x > right || y < top || y > bottom) continue;
|
|
37734
|
-
const area = (right - left) * (bottom - top);
|
|
37735
|
-
if (area < bestArea) {
|
|
37736
|
-
bestArea = area;
|
|
37737
|
-
best = group;
|
|
37738
|
-
}
|
|
37739
|
-
}
|
|
37740
|
-
return best;
|
|
37741
|
-
}
|
|
37742
|
-
function getPreviewTargetFromPointer(iframe, clientX, clientY, activeCompositionPath) {
|
|
37657
|
+
import {
|
|
37658
|
+
compositionPoint,
|
|
37659
|
+
coversComposition,
|
|
37660
|
+
pointerTarget,
|
|
37661
|
+
pointerTargets
|
|
37662
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
37663
|
+
function getPreviewTargetFromPointer(iframe, clientX, clientY) {
|
|
37664
|
+
const local = framePointer(iframe, clientX, clientY);
|
|
37665
|
+
return local && pointerTarget(local.doc, local.point);
|
|
37666
|
+
}
|
|
37667
|
+
function getAllPreviewTargetsFromPointer(iframe, clientX, clientY) {
|
|
37668
|
+
const local = framePointer(iframe, clientX, clientY);
|
|
37669
|
+
return local ? pointerTargets(local.doc, local.point) : [];
|
|
37670
|
+
}
|
|
37671
|
+
function framePointFraction(iframe, clientX, clientY) {
|
|
37672
|
+
const rect = iframe.getBoundingClientRect();
|
|
37673
|
+
return { x: (clientX - rect.left) / rect.width, y: (clientY - rect.top) / rect.height };
|
|
37674
|
+
}
|
|
37675
|
+
function framePointer(iframe, clientX, clientY) {
|
|
37743
37676
|
let doc = null;
|
|
37744
|
-
let win = null;
|
|
37745
37677
|
try {
|
|
37746
37678
|
doc = iframe.contentDocument;
|
|
37747
|
-
win = iframe.contentWindow;
|
|
37748
37679
|
} catch {
|
|
37749
37680
|
return null;
|
|
37750
37681
|
}
|
|
37751
|
-
if (!doc
|
|
37752
|
-
const
|
|
37753
|
-
|
|
37754
|
-
|
|
37755
|
-
const elements = doc.elementsFromPoint(localPointer.x, localPointer.y);
|
|
37756
|
-
const candidates = filterAuthorInteractiveTargets(elements, activeCompositionPath);
|
|
37757
|
-
const visualTarget = candidates.find((el) => !isFullBleedTarget(el, localPointer.viewport)) ?? null;
|
|
37758
|
-
if (visualTarget) return visualTarget;
|
|
37759
|
-
}
|
|
37760
|
-
const groupHit = findGroupAtPoint(doc, localPointer.x, localPointer.y);
|
|
37761
|
-
if (groupHit && !hasAuthorPointerEventsNone(groupHit) && getDomLayerPatchTarget(groupHit, activeCompositionPath))
|
|
37762
|
-
return groupHit;
|
|
37763
|
-
const fallback = getEventTargetElement(doc.elementFromPoint(localPointer.x, localPointer.y));
|
|
37764
|
-
if (!fallback || !getDomLayerPatchTarget(fallback, activeCompositionPath)) return null;
|
|
37765
|
-
if (hasAuthorPointerEventsNone(fallback)) return null;
|
|
37766
|
-
if (!isElementComputedVisible(fallback)) return null;
|
|
37767
|
-
if (isFullBleedTarget(fallback, localPointer.viewport)) return null;
|
|
37768
|
-
return fallback;
|
|
37769
|
-
}
|
|
37770
|
-
function getAllPreviewTargetsFromPointer(iframe, clientX, clientY, activeCompositionPath) {
|
|
37771
|
-
let doc = null;
|
|
37772
|
-
let win = null;
|
|
37773
|
-
try {
|
|
37774
|
-
doc = iframe.contentDocument;
|
|
37775
|
-
win = iframe.contentWindow;
|
|
37776
|
-
} catch {
|
|
37777
|
-
return [];
|
|
37778
|
-
}
|
|
37779
|
-
if (!doc || !win) return [];
|
|
37780
|
-
const localPointer = resolvePreviewLocalPointer(iframe, doc, win, clientX, clientY);
|
|
37781
|
-
if (!localPointer) return [];
|
|
37782
|
-
if (typeof doc.elementsFromPoint === "function") {
|
|
37783
|
-
const elements = doc.elementsFromPoint(localPointer.x, localPointer.y);
|
|
37784
|
-
return filterAuthorInteractiveTargets(elements, activeCompositionPath).filter(
|
|
37785
|
-
(el) => !isFullBleedTarget(el, localPointer.viewport)
|
|
37786
|
-
);
|
|
37787
|
-
}
|
|
37788
|
-
const fallback = getEventTargetElement(doc.elementFromPoint(localPointer.x, localPointer.y));
|
|
37789
|
-
if (!fallback || !getDomLayerPatchTarget(fallback, activeCompositionPath)) return [];
|
|
37790
|
-
if (hasAuthorPointerEventsNone(fallback)) return [];
|
|
37791
|
-
if (!isElementComputedVisible(fallback)) return [];
|
|
37792
|
-
if (isFullBleedTarget(fallback, localPointer.viewport)) return [];
|
|
37793
|
-
return [fallback];
|
|
37682
|
+
if (!doc?.defaultView) return null;
|
|
37683
|
+
const { x, y } = framePointFraction(iframe, clientX, clientY);
|
|
37684
|
+
const point = compositionPoint(doc, x, y);
|
|
37685
|
+
return point && { doc, point };
|
|
37794
37686
|
}
|
|
37795
37687
|
function objectLike(value) {
|
|
37796
37688
|
return value && (typeof value === "object" || typeof value === "function") ? value : null;
|
|
@@ -37862,7 +37754,7 @@ function resolveRootDimensions(root) {
|
|
|
37862
37754
|
function computeOverlayRootScale(overlayEl, iframe, doc) {
|
|
37863
37755
|
const iframeRect = iframe.getBoundingClientRect();
|
|
37864
37756
|
const overlayRect = overlayEl.getBoundingClientRect();
|
|
37865
|
-
const dims = resolveRootDimensions(findOverlayRootElement(doc));
|
|
37757
|
+
const dims = previewFrameOpaque(iframe) ? previewStageSize(iframe) : resolveRootDimensions(findOverlayRootElement(doc));
|
|
37866
37758
|
if (!dims) return null;
|
|
37867
37759
|
return {
|
|
37868
37760
|
iframeRect,
|
|
@@ -37872,52 +37764,10 @@ function computeOverlayRootScale(overlayEl, iframe, doc) {
|
|
|
37872
37764
|
};
|
|
37873
37765
|
}
|
|
37874
37766
|
|
|
37875
|
-
// src/components/editor/
|
|
37876
|
-
|
|
37877
|
-
|
|
37878
|
-
|
|
37879
|
-
const parts = value.trim().split(/\s+/);
|
|
37880
|
-
const angle = parts.at(-1);
|
|
37881
|
-
if (!angle?.endsWith("deg")) return 0;
|
|
37882
|
-
if (parts.length === 4) {
|
|
37883
|
-
const [x, y, z] = parts;
|
|
37884
|
-
if (Number(x) !== 0 || Number(y) !== 0 || Math.abs(Number(z)) !== 1) return 0;
|
|
37885
|
-
const deg2 = Number.parseFloat(angle);
|
|
37886
|
-
return Number.isFinite(deg2) ? deg2 * Math.sign(Number(z)) : 0;
|
|
37887
|
-
}
|
|
37888
|
-
if (parts.length !== 1) return 0;
|
|
37889
|
-
const deg = Number.parseFloat(angle);
|
|
37890
|
-
return Number.isFinite(deg) ? deg : 0;
|
|
37891
|
-
}
|
|
37892
|
-
function ownNodeTransform(node, ops, getStyle) {
|
|
37893
|
-
const style = getStyle(node);
|
|
37894
|
-
if (!style) return null;
|
|
37895
|
-
const transform = style.transform;
|
|
37896
|
-
const own = transform && transform !== "none" ? ops.fromTransform(transform) : ops.identity();
|
|
37897
|
-
if (!own) return null;
|
|
37898
|
-
const spin = individualRotateDegrees(style.rotate);
|
|
37899
|
-
return spin === 0 ? own : ops.compose(ops.fromRotate(spin), own);
|
|
37900
|
-
}
|
|
37901
|
-
function composeElementTransform(element, ops, getStyle, memo64) {
|
|
37902
|
-
const pending2 = [];
|
|
37903
|
-
let above;
|
|
37904
|
-
for (let node = element; node; node = node.parentElement) {
|
|
37905
|
-
above = memo64?.get(node);
|
|
37906
|
-
if (above !== void 0) break;
|
|
37907
|
-
pending2.push(node);
|
|
37908
|
-
if (node.hasAttribute(COMPOSITION_ROOT_ATTR)) break;
|
|
37909
|
-
}
|
|
37910
|
-
let acc = above === void 0 ? ops.identity() : above;
|
|
37911
|
-
for (let i = pending2.length - 1; i >= 0; i -= 1) {
|
|
37912
|
-
const node = pending2[i];
|
|
37913
|
-
if (acc !== null) {
|
|
37914
|
-
const own = ownNodeTransform(node, ops, getStyle);
|
|
37915
|
-
acc = own === null ? null : ops.compose(acc, own);
|
|
37916
|
-
}
|
|
37917
|
-
memo64?.set(node, acc);
|
|
37918
|
-
}
|
|
37919
|
-
return acc;
|
|
37920
|
-
}
|
|
37767
|
+
// src/components/editor/domEditOverlayCrop.ts
|
|
37768
|
+
import {
|
|
37769
|
+
composeElementTransform
|
|
37770
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
37921
37771
|
|
|
37922
37772
|
// src/components/editor/clipPathHelpers.ts
|
|
37923
37773
|
function formatClipNumber(value) {
|
|
@@ -38095,7 +37945,10 @@ function resolveCropInsetFromMoveDrag(input) {
|
|
|
38095
37945
|
return { left, right: totalX - left, top, bottom: totalY - top };
|
|
38096
37946
|
}
|
|
38097
37947
|
function hugRectForElement(rect, element) {
|
|
38098
|
-
|
|
37948
|
+
return isElementCropLifted(element) ? rect : hugRectForClipPath(rect, readElementClipPath(element));
|
|
37949
|
+
}
|
|
37950
|
+
function hugRectForClipPath(rect, clipPath) {
|
|
37951
|
+
const insets = clipPath === null ? null : parseCropClipPath(clipPath);
|
|
38099
37952
|
if (!insets || insets.top <= 0 && insets.right <= 0 && insets.bottom <= 0 && insets.left <= 0)
|
|
38100
37953
|
return rect;
|
|
38101
37954
|
return cropRectFromInsets(rect, insets, rect.editScaleX, rect.editScaleY);
|
|
@@ -38188,6 +38041,14 @@ function rotateDeltaIntoFrame(deltaX, deltaY, angleDeg) {
|
|
|
38188
38041
|
return { deltaX: deltaX * cos - deltaY * sin, deltaY: deltaX * sin + deltaY * cos };
|
|
38189
38042
|
}
|
|
38190
38043
|
|
|
38044
|
+
// src/components/editor/domEditOverlayGeometry.ts
|
|
38045
|
+
import {
|
|
38046
|
+
elementCornerPoints,
|
|
38047
|
+
readElementTransformSnapshot,
|
|
38048
|
+
rotationDegreesFromMatrix,
|
|
38049
|
+
ROTATION_GATE_EPSILON_DEG
|
|
38050
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
38051
|
+
|
|
38191
38052
|
// src/components/editor/domEditOverlayMeasurePass.ts
|
|
38192
38053
|
function createOverlayMeasurePass() {
|
|
38193
38054
|
return {
|
|
@@ -38255,44 +38116,9 @@ function toVisibleOverlayRects(overlayEl, iframe, elements) {
|
|
|
38255
38116
|
return rect ? { ...rect, ...hugRectForElement(rect, element) } : null;
|
|
38256
38117
|
});
|
|
38257
38118
|
}
|
|
38258
|
-
function readElementTransformSnapshot(win, element, pass) {
|
|
38259
|
-
const DOMMatrixCtor = win.DOMMatrix;
|
|
38260
|
-
if (!DOMMatrixCtor) return null;
|
|
38261
|
-
const cs = win.getComputedStyle(element);
|
|
38262
|
-
const ops = {
|
|
38263
|
-
identity: () => new DOMMatrixCtor(),
|
|
38264
|
-
fromTransform: (value) => new DOMMatrixCtor(value),
|
|
38265
|
-
fromRotate: (degrees2) => new DOMMatrixCtor().rotateSelf(degrees2),
|
|
38266
|
-
compose: (outer, inner) => outer.multiply(inner)
|
|
38267
|
-
};
|
|
38268
|
-
try {
|
|
38269
|
-
const matrix = composeElementTransform(
|
|
38270
|
-
element,
|
|
38271
|
-
ops,
|
|
38272
|
-
(node) => node === element ? cs : win.getComputedStyle(node),
|
|
38273
|
-
pass?.transform
|
|
38274
|
-
);
|
|
38275
|
-
return matrix ? { matrix, cs } : null;
|
|
38276
|
-
} catch {
|
|
38277
|
-
return null;
|
|
38278
|
-
}
|
|
38279
|
-
}
|
|
38280
|
-
function rotationDegreesFromMatrix(matrix) {
|
|
38281
|
-
const a = Number.isFinite(matrix.a) ? matrix.a : 1;
|
|
38282
|
-
const b = Number.isFinite(matrix.b) ? matrix.b : 0;
|
|
38283
|
-
const c = Number.isFinite(matrix.c) ? matrix.c : 0;
|
|
38284
|
-
const d = Number.isFinite(matrix.d) ? matrix.d : 1;
|
|
38285
|
-
const fromX = Math.atan2(b, a) * 180 / Math.PI;
|
|
38286
|
-
const determinant = a * d - b * c;
|
|
38287
|
-
const fromY = Math.atan2(-c, d) * 180 / Math.PI;
|
|
38288
|
-
const deg = determinant < 0 && Math.abs(fromY) < Math.abs(fromX) ? fromY : fromX;
|
|
38289
|
-
return Number.isFinite(deg) ? deg : 0;
|
|
38290
|
-
}
|
|
38291
|
-
var ROTATION_GATE_EPSILON_DEG = 1e-4;
|
|
38292
38119
|
function toOverlayRect(overlayEl, iframe, element, precomputedScale, pass) {
|
|
38293
38120
|
const scale = precomputedScale ?? computeOverlayRootScale(overlayEl, iframe, iframe.contentDocument);
|
|
38294
38121
|
if (!scale) return null;
|
|
38295
|
-
const { iframeRect, overlayRect, rootScaleX, rootScaleY } = scale;
|
|
38296
38122
|
const elementRect = element.getBoundingClientRect();
|
|
38297
38123
|
const sourceBoundary = findSourceBoundary(element, pass);
|
|
38298
38124
|
const sourceBoundaryRect = sourceBoundary && pass ? readThroughPass(
|
|
@@ -38300,13 +38126,22 @@ function toOverlayRect(overlayEl, iframe, element, precomputedScale, pass) {
|
|
|
38300
38126
|
sourceBoundary,
|
|
38301
38127
|
() => sourceBoundary.getBoundingClientRect()
|
|
38302
38128
|
) : sourceBoundary?.getBoundingClientRect();
|
|
38129
|
+
return frameRectToOverlay(scale, elementRect, {
|
|
38130
|
+
width: sourceBoundaryRect?.width,
|
|
38131
|
+
height: sourceBoundaryRect?.height,
|
|
38132
|
+
declaredWidth: readPositiveDimension(sourceBoundary?.getAttribute("data-width") ?? null),
|
|
38133
|
+
declaredHeight: readPositiveDimension(sourceBoundary?.getAttribute("data-height") ?? null)
|
|
38134
|
+
});
|
|
38135
|
+
}
|
|
38136
|
+
function frameRectToOverlay(scale, elementRect, source) {
|
|
38137
|
+
const { iframeRect, overlayRect, rootScaleX, rootScaleY } = scale;
|
|
38303
38138
|
const editScale = resolveDomEditCoordinateScale({
|
|
38304
38139
|
rootScaleX,
|
|
38305
38140
|
rootScaleY,
|
|
38306
|
-
sourceRectWidth:
|
|
38307
|
-
sourceRectHeight:
|
|
38308
|
-
sourceWidth:
|
|
38309
|
-
sourceHeight:
|
|
38141
|
+
sourceRectWidth: source?.width,
|
|
38142
|
+
sourceRectHeight: source?.height,
|
|
38143
|
+
sourceWidth: source?.declaredWidth,
|
|
38144
|
+
sourceHeight: source?.declaredHeight
|
|
38310
38145
|
});
|
|
38311
38146
|
return {
|
|
38312
38147
|
left: iframeRect.left - overlayRect.left + elementRect.left * rootScaleX,
|
|
@@ -38317,6 +38152,18 @@ function toOverlayRect(overlayEl, iframe, element, precomputedScale, pass) {
|
|
|
38317
38152
|
editScaleY: editScale.scaleY
|
|
38318
38153
|
};
|
|
38319
38154
|
}
|
|
38155
|
+
function frameCornersToOverlay({ iframeRect, overlayRect, rootScaleX, rootScaleY }, corners) {
|
|
38156
|
+
const toOverlay = (pt) => ({
|
|
38157
|
+
x: iframeRect.left - overlayRect.left + pt.x * rootScaleX,
|
|
38158
|
+
y: iframeRect.top - overlayRect.top + pt.y * rootScaleY
|
|
38159
|
+
});
|
|
38160
|
+
return {
|
|
38161
|
+
nw: toOverlay(corners.nw),
|
|
38162
|
+
ne: toOverlay(corners.ne),
|
|
38163
|
+
se: toOverlay(corners.se),
|
|
38164
|
+
sw: toOverlay(corners.sw)
|
|
38165
|
+
};
|
|
38166
|
+
}
|
|
38320
38167
|
function cornerEdgeLength(a, b) {
|
|
38321
38168
|
return Math.hypot(b.x - a.x, b.y - a.y);
|
|
38322
38169
|
}
|
|
@@ -38330,44 +38177,13 @@ function elementCornerOverlayPoints(overlayEl, iframe, element, precomputedScale
|
|
|
38330
38177
|
const win = iframe.contentWindow;
|
|
38331
38178
|
const doc = iframe.contentDocument;
|
|
38332
38179
|
if (!win || !doc) return null;
|
|
38333
|
-
|
|
38334
|
-
if (!DOMPointCtor) return null;
|
|
38180
|
+
if (!win.DOMPoint) return null;
|
|
38335
38181
|
const scale = precomputedScale ?? computeOverlayRootScale(overlayEl, iframe, doc);
|
|
38336
38182
|
if (!scale) return null;
|
|
38337
|
-
const { iframeRect, overlayRect, rootScaleX, rootScaleY } = scale;
|
|
38338
38183
|
const transform = precomputedTransform ?? readElementTransformSnapshot(win, element);
|
|
38339
38184
|
if (!transform) return null;
|
|
38340
|
-
const
|
|
38341
|
-
|
|
38342
|
-
const h = element.offsetHeight;
|
|
38343
|
-
const originParts = cs.transformOrigin.split(" ").map((p) => Number.parseFloat(p));
|
|
38344
|
-
const ox = Number.isFinite(originParts[0]) ? originParts[0] : w / 2;
|
|
38345
|
-
const oy = Number.isFinite(originParts[1]) ? originParts[1] : h / 2;
|
|
38346
|
-
const rel = (lx, ly) => {
|
|
38347
|
-
const p = matrix.transformPoint(new DOMPointCtor(lx - ox, ly - oy));
|
|
38348
|
-
return { x: p.x, y: p.y };
|
|
38349
|
-
};
|
|
38350
|
-
const relCorners = {
|
|
38351
|
-
nw: rel(0, 0),
|
|
38352
|
-
ne: rel(w, 0),
|
|
38353
|
-
se: rel(w, h),
|
|
38354
|
-
sw: rel(0, h)
|
|
38355
|
-
};
|
|
38356
|
-
const xs = [relCorners.nw.x, relCorners.ne.x, relCorners.se.x, relCorners.sw.x];
|
|
38357
|
-
const ys = [relCorners.nw.y, relCorners.ne.y, relCorners.se.y, relCorners.sw.y];
|
|
38358
|
-
const bcr = element.getBoundingClientRect();
|
|
38359
|
-
const dx = bcr.left - Math.min(...xs);
|
|
38360
|
-
const dy = bcr.top - Math.min(...ys);
|
|
38361
|
-
const toOverlay = (pt) => ({
|
|
38362
|
-
x: iframeRect.left - overlayRect.left + (pt.x + dx) * rootScaleX,
|
|
38363
|
-
y: iframeRect.top - overlayRect.top + (pt.y + dy) * rootScaleY
|
|
38364
|
-
});
|
|
38365
|
-
return {
|
|
38366
|
-
nw: toOverlay(relCorners.nw),
|
|
38367
|
-
ne: toOverlay(relCorners.ne),
|
|
38368
|
-
se: toOverlay(relCorners.se),
|
|
38369
|
-
sw: toOverlay(relCorners.sw)
|
|
38370
|
-
};
|
|
38185
|
+
const corners = elementCornerPoints(win, element, transform);
|
|
38186
|
+
return corners && frameCornersToOverlay(scale, corners);
|
|
38371
38187
|
}
|
|
38372
38188
|
function orientedOverlayRect(overlayEl, iframe, element, precomputedScale, pass) {
|
|
38373
38189
|
const scale = precomputedScale ?? computeOverlayRootScale(overlayEl, iframe, iframe.contentDocument);
|
|
@@ -38375,10 +38191,13 @@ function orientedOverlayRect(overlayEl, iframe, element, precomputedScale, pass)
|
|
|
38375
38191
|
const base2 = toOverlayRect(overlayEl, iframe, element, scale, pass);
|
|
38376
38192
|
if (!base2) return null;
|
|
38377
38193
|
const win = iframe.contentWindow;
|
|
38378
|
-
const transform = win ? readElementTransformSnapshot(win, element, pass) : null;
|
|
38194
|
+
const transform = win ? readElementTransformSnapshot(win, element, pass?.transform) : null;
|
|
38379
38195
|
const angle = transform ? rotationDegreesFromMatrix(transform.matrix) : 0;
|
|
38380
38196
|
if (Math.abs(angle) < ROTATION_GATE_EPSILON_DEG) return base2;
|
|
38381
38197
|
const corners = elementCornerOverlayPoints(overlayEl, iframe, element, scale, transform);
|
|
38198
|
+
return orientOverlayRect(base2, angle, corners);
|
|
38199
|
+
}
|
|
38200
|
+
function orientOverlayRect(base2, angle, corners) {
|
|
38382
38201
|
if (!corners) return base2;
|
|
38383
38202
|
const width = cornerEdgeLength(corners.nw, corners.ne);
|
|
38384
38203
|
const height = cornerEdgeLength(corners.nw, corners.sw);
|
|
@@ -38551,6 +38370,869 @@ function isDomEditGestureTap(g, e) {
|
|
|
38551
38370
|
return !g.travelled && Math.hypot(e.clientX - g.startX, e.clientY - g.startY) < BLOCKED_MOVE_THRESHOLD_PX;
|
|
38552
38371
|
}
|
|
38553
38372
|
|
|
38373
|
+
// src/components/editor/previewLayers.ts
|
|
38374
|
+
import { MAX_DESCRIBE_HANDLES as MAX_DESCRIBE_HANDLES4 } from "@hyperframes/core/runtime/editing-port";
|
|
38375
|
+
|
|
38376
|
+
// src/player/lib/previewElements.ts
|
|
38377
|
+
import {
|
|
38378
|
+
EDITING_ELEMENT_HANDLE,
|
|
38379
|
+
MAX_DESCRIBE_HANDLES,
|
|
38380
|
+
MAX_ELEMENT_ENTRIES,
|
|
38381
|
+
MAX_ELEMENT_VALUE,
|
|
38382
|
+
MAX_GEOMETRY_CHILDREN
|
|
38383
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
38384
|
+
var isFields = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
38385
|
+
var isHandle = (value) => typeof value === "string" && EDITING_ELEMENT_HANDLE.test(value);
|
|
38386
|
+
var isText = (value) => typeof value === "string";
|
|
38387
|
+
var isTextOrNull = (value) => value === null || typeof value === "string";
|
|
38388
|
+
var isCount = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
38389
|
+
var isSource = (value) => isFields(value) && isTextOrNull(value.file) && isTextOrNull(value.compositionId) && isTextOrNull(value.originalCompositionId);
|
|
38390
|
+
var isTextRecord = (value) => isFields(value) && Object.values(value).every(isText);
|
|
38391
|
+
function hasPlainFields(value) {
|
|
38392
|
+
const { matchesBefore, attributes, children } = value;
|
|
38393
|
+
const groupsOk = matchesBefore === null || Array.isArray(matchesBefore) && matchesBefore.every((g) => isFields(g) && isSource(g.source) && isCount(g.count));
|
|
38394
|
+
const attributesOk = Array.isArray(attributes) && attributes.every((a) => Array.isArray(a) && a.length === 2 && a.every(isText));
|
|
38395
|
+
const childrenOk = Array.isArray(children) && children.every((c) => isFields(c) && (isHandle(c.handle) || isText(c.text)));
|
|
38396
|
+
return groupsOk && attributesOk && childrenOk && typeof value.truncated === "boolean";
|
|
38397
|
+
}
|
|
38398
|
+
var isRect = (value) => isFields(value) && [value.x, value.y, value.width, value.height].every(Number.isFinite);
|
|
38399
|
+
function readHit(value) {
|
|
38400
|
+
if (!isFields(value) || !isHandle(value.handle) || !isText(value.tag)) return null;
|
|
38401
|
+
return isRect(value.rect) ? value : null;
|
|
38402
|
+
}
|
|
38403
|
+
function readPreviewElement(value) {
|
|
38404
|
+
if (!readHit(value) || !isFields(value)) return null;
|
|
38405
|
+
if (value.parent !== null && !isHandle(value.parent)) return null;
|
|
38406
|
+
if (!isTextOrNull(value.id) || !isTextOrNull(value.selector)) return null;
|
|
38407
|
+
if (!isSource(value.source) || typeof value.locked !== "boolean") return null;
|
|
38408
|
+
if (!isTextRecord(value.inlineStyles) || !isText(value.text)) return null;
|
|
38409
|
+
return hasPlainFields(value) ? value : null;
|
|
38410
|
+
}
|
|
38411
|
+
async function previewPointerTargets(iframe, rootFractionX, rootFractionY) {
|
|
38412
|
+
const params = { x: rootFractionX, y: rootFractionY };
|
|
38413
|
+
const reply = await previewRequest(iframe, "pointer-targets", params);
|
|
38414
|
+
const stack = reply?.stack;
|
|
38415
|
+
if (!reply || !Array.isArray(stack)) return null;
|
|
38416
|
+
return { target: readHit(reply.target), stack: stack.map(readHit).filter((hit) => hit !== null) };
|
|
38417
|
+
}
|
|
38418
|
+
async function describePreviewElements(iframe, handles) {
|
|
38419
|
+
if (!handles.length || handles.length > MAX_DESCRIBE_HANDLES) return null;
|
|
38420
|
+
const reply = await previewRequest(iframe, "describe", { handles: [...handles] });
|
|
38421
|
+
const elements = reply?.elements;
|
|
38422
|
+
if (!Array.isArray(elements) || elements.length !== handles.length) return null;
|
|
38423
|
+
return elements.map((entry3, index2) => {
|
|
38424
|
+
const element = readPreviewElement(entry3);
|
|
38425
|
+
return element?.handle === handles[index2] ? element : null;
|
|
38426
|
+
});
|
|
38427
|
+
}
|
|
38428
|
+
async function previewAncestors(iframe, handles) {
|
|
38429
|
+
if (!handles.length || handles.length > MAX_DESCRIBE_HANDLES) return null;
|
|
38430
|
+
const reply = await previewRequest(iframe, "ancestors", { handles: [...handles] });
|
|
38431
|
+
const chains = reply?.ancestors;
|
|
38432
|
+
if (!Array.isArray(chains) || chains.length !== handles.length) return null;
|
|
38433
|
+
return chains.map(
|
|
38434
|
+
(chain) => Array.isArray(chain) && chain.every(isHandle) ? chain : null
|
|
38435
|
+
);
|
|
38436
|
+
}
|
|
38437
|
+
async function queryPreviewElements(iframe, selector) {
|
|
38438
|
+
const reply = await previewRequest(iframe, "query", { selector });
|
|
38439
|
+
const matches = reply?.matches;
|
|
38440
|
+
if (!Array.isArray(matches) || typeof reply?.truncated !== "boolean") return null;
|
|
38441
|
+
const ok = matches.every((m) => isFields(m) && isHandle(m.handle) && isSource(m.source));
|
|
38442
|
+
return ok ? { matches, truncated: reply.truncated } : null;
|
|
38443
|
+
}
|
|
38444
|
+
function previewElementSourceFile(element, activeCompositionPath) {
|
|
38445
|
+
return resolveElementSourceFile(element.source, activeCompositionPath);
|
|
38446
|
+
}
|
|
38447
|
+
function previewElementSelectorIndex(element, activeCompositionPath) {
|
|
38448
|
+
if (!element.selector?.startsWith(".") || !element.matchesBefore) return void 0;
|
|
38449
|
+
const file = previewElementSourceFile(element, activeCompositionPath);
|
|
38450
|
+
return element.matchesBefore.filter((group) => resolveElementSourceFile(group.source, activeCompositionPath) === file).reduce((sum, group) => sum + group.count, 0);
|
|
38451
|
+
}
|
|
38452
|
+
var isPoint = (value) => isFields(value) && Number.isFinite(value.x) && Number.isFinite(value.y);
|
|
38453
|
+
var isSizeOrNull = (value) => value === null || Number.isFinite(value) && value > 0;
|
|
38454
|
+
var CORNERS = ["nw", "ne", "se", "sw"];
|
|
38455
|
+
var isCorners = (value) => value === null || isFields(value) && CORNERS.every((corner) => isPoint(value[corner]));
|
|
38456
|
+
var isSourceBox = (value) => value === null || isFields(value) && Number.isFinite(value.width) && Number.isFinite(value.height) && isSizeOrNull(value.declaredWidth) && isSizeOrNull(value.declaredHeight);
|
|
38457
|
+
var isClipPath = (value) => value === null || isText(value) && value.length <= MAX_ELEMENT_VALUE;
|
|
38458
|
+
var isBox = (value) => isFields(value) && isRect(value.rect) && Number.isFinite(value.angle) && isCorners(value.corners) && isSourceBox(value.source) && isClipPath(value.clipPath);
|
|
38459
|
+
var readGeometry = (value) => {
|
|
38460
|
+
if (!isBox(value) || !isFields(value) || typeof value.visible !== "boolean") return null;
|
|
38461
|
+
const { members } = value;
|
|
38462
|
+
const membersOk = members === null || Array.isArray(members) && members.length <= MAX_ELEMENT_ENTRIES && members.every(isRect);
|
|
38463
|
+
return membersOk ? value : null;
|
|
38464
|
+
};
|
|
38465
|
+
async function previewGeometry(iframe, handles, children) {
|
|
38466
|
+
if (!handles.length || handles.length > MAX_DESCRIBE_HANDLES) return null;
|
|
38467
|
+
const params = { handles: [...handles], ...children ? { children } : {} };
|
|
38468
|
+
const reply = await previewRequest(iframe, "geometry", params);
|
|
38469
|
+
const elements = reply?.elements;
|
|
38470
|
+
if (!Array.isArray(elements) || elements.length !== handles.length) return null;
|
|
38471
|
+
const boxes = reply?.children;
|
|
38472
|
+
const childrenOk = Array.isArray(boxes) && boxes.length <= MAX_GEOMETRY_CHILDREN && boxes.every(isBox);
|
|
38473
|
+
return {
|
|
38474
|
+
elements: elements.map(readGeometry),
|
|
38475
|
+
children: children && childrenOk ? boxes : null
|
|
38476
|
+
};
|
|
38477
|
+
}
|
|
38478
|
+
var LAYER_KINDS = /* @__PURE__ */ new Set(["image", "video", "audio", "vector", "group", "text", "shape"]);
|
|
38479
|
+
var isLayer = (value) => isFields(value) && isHandle(value.handle) && isCount(value.depth) && isCount(value.childCount) && Number.isFinite(value.zIndex) && LAYER_KINDS.has(value.kind);
|
|
38480
|
+
async function previewLayers(iframe, group, offset = 0) {
|
|
38481
|
+
const params = { ...group ? { group } : {}, ...offset ? { offset } : {} };
|
|
38482
|
+
const reply = await previewRequest(iframe, "layers", params);
|
|
38483
|
+
const layers = reply?.layers;
|
|
38484
|
+
const { truncated, missingGroup } = reply ?? {};
|
|
38485
|
+
if (!Array.isArray(layers) || typeof truncated !== "boolean") return null;
|
|
38486
|
+
if (typeof missingGroup !== "boolean") return null;
|
|
38487
|
+
return layers.every(isLayer) ? { layers, truncated, missingGroup } : null;
|
|
38488
|
+
}
|
|
38489
|
+
|
|
38490
|
+
// src/components/editor/previewOverlayRects.ts
|
|
38491
|
+
import {
|
|
38492
|
+
MAX_DESCRIBE_HANDLES as MAX_DESCRIBE_HANDLES2,
|
|
38493
|
+
ROTATION_GATE_EPSILON_DEG as ROTATION_GATE_EPSILON_DEG2
|
|
38494
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
38495
|
+
var clientRect = ({ x, y, width, height }) => ({ left: x, top: y, width, height });
|
|
38496
|
+
var baseRect = (scale, box) => frameRectToOverlay(scale, clientRect(box.rect), box.source);
|
|
38497
|
+
function orientedRect(scale, box) {
|
|
38498
|
+
const base2 = baseRect(scale, box);
|
|
38499
|
+
if (Math.abs(box.angle) < ROTATION_GATE_EPSILON_DEG2) return base2;
|
|
38500
|
+
return orientOverlayRect(
|
|
38501
|
+
base2,
|
|
38502
|
+
box.angle,
|
|
38503
|
+
box.corners && frameCornersToOverlay(scale, box.corners)
|
|
38504
|
+
);
|
|
38505
|
+
}
|
|
38506
|
+
function groupAwareRect(scale, geometry, oriented) {
|
|
38507
|
+
if (!geometry.members)
|
|
38508
|
+
return oriented ? orientedRect(scale, geometry) : baseRect(scale, geometry);
|
|
38509
|
+
const rect = baseRect(scale, geometry);
|
|
38510
|
+
const members = geometry.members.map(
|
|
38511
|
+
(member) => frameRectToOverlay(scale, clientRect(member), null)
|
|
38512
|
+
);
|
|
38513
|
+
const union = resolveDomEditGroupOverlayRect(members);
|
|
38514
|
+
return union ? { ...union, editScaleX: rect.editScaleX, editScaleY: rect.editScaleY } : rect;
|
|
38515
|
+
}
|
|
38516
|
+
function visibleRect(scale, box) {
|
|
38517
|
+
const rect = orientedRect(scale, box);
|
|
38518
|
+
return { ...rect, ...hugRectForClipPath(rect, box.clipPath) };
|
|
38519
|
+
}
|
|
38520
|
+
async function measurePreviewOverlay(iframe, overlayEl, targets) {
|
|
38521
|
+
const handles = [.../* @__PURE__ */ new Set([targets.selection, targets.hover, ...targets.group])].filter(
|
|
38522
|
+
(handle) => Boolean(handle)
|
|
38523
|
+
);
|
|
38524
|
+
const reply = handles.length ? await previewGeometry(iframe, handles, targets.selection ?? void 0) : { elements: [], children: null };
|
|
38525
|
+
const scale = reply && computeOverlayRootScale(overlayEl, iframe, null);
|
|
38526
|
+
if (!reply || !scale) return null;
|
|
38527
|
+
const read2 = (handle) => handle ? reply.elements[handles.indexOf(handle)] ?? null : null;
|
|
38528
|
+
const selected = read2(targets.selection);
|
|
38529
|
+
const shown3 = selected?.visible ? selected : null;
|
|
38530
|
+
const hovered = read2(targets.hover);
|
|
38531
|
+
return {
|
|
38532
|
+
selection: shown3 && groupAwareRect(scale, shown3, true),
|
|
38533
|
+
children: shown3 ? (reply.children ?? []).map((box) => visibleRect(scale, box)).filter((rect) => rect.width > 2 && rect.height > 2) : [],
|
|
38534
|
+
group: targets.group.map((handle) => {
|
|
38535
|
+
const member = read2(handle);
|
|
38536
|
+
const rect = member && groupAwareRect(scale, member, false);
|
|
38537
|
+
return rect && { ...rect, ...hugRectForClipPath(rect, member.clipPath) };
|
|
38538
|
+
}),
|
|
38539
|
+
hover: hovered && groupAwareRect(scale, hovered, true)
|
|
38540
|
+
};
|
|
38541
|
+
}
|
|
38542
|
+
async function measurePreviewRects(iframe, overlayEl, handles) {
|
|
38543
|
+
const reply = await previewGeometry(iframe, handles);
|
|
38544
|
+
const scale = reply && computeOverlayRootScale(overlayEl, iframe, null);
|
|
38545
|
+
if (!reply || !scale) return null;
|
|
38546
|
+
return reply.elements.map((geometry) => geometry && groupAwareRect(scale, geometry, true));
|
|
38547
|
+
}
|
|
38548
|
+
async function measurePreviewVisibleRects(iframe, overlayEl, handles) {
|
|
38549
|
+
const measured = [];
|
|
38550
|
+
for (let at = 0; at < handles.length; at += MAX_DESCRIBE_HANDLES2) {
|
|
38551
|
+
const reply = await previewGeometry(iframe, handles.slice(at, at + MAX_DESCRIBE_HANDLES2));
|
|
38552
|
+
const scale = reply && computeOverlayRootScale(overlayEl, iframe, null);
|
|
38553
|
+
if (!reply || !scale) return null;
|
|
38554
|
+
for (const box of reply.elements) {
|
|
38555
|
+
const rect = box && baseRect(scale, box);
|
|
38556
|
+
measured.push(
|
|
38557
|
+
box && rect && {
|
|
38558
|
+
rect: { ...rect, ...hugRectForClipPath(rect, box.clipPath) },
|
|
38559
|
+
frame: box.rect,
|
|
38560
|
+
visible: box.visible
|
|
38561
|
+
}
|
|
38562
|
+
);
|
|
38563
|
+
}
|
|
38564
|
+
}
|
|
38565
|
+
return measured;
|
|
38566
|
+
}
|
|
38567
|
+
|
|
38568
|
+
// src/components/editor/previewSelection.ts
|
|
38569
|
+
import { resolveEditingAffordances } from "@hyperframes/core/editing";
|
|
38570
|
+
import {
|
|
38571
|
+
MAX_ELEMENT_ENTRIES as MAX_ELEMENT_ENTRIES2,
|
|
38572
|
+
MAX_ELEMENT_VALUE as MAX_ELEMENT_VALUE2
|
|
38573
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
38574
|
+
|
|
38575
|
+
// src/components/editor/previewDrafts.ts
|
|
38576
|
+
import { MAX_DESCRIBE_HANDLES as MAX_DESCRIBE_HANDLES3 } from "@hyperframes/core/runtime/editing-port";
|
|
38577
|
+
var standIns = /* @__PURE__ */ new WeakMap();
|
|
38578
|
+
var queues = /* @__PURE__ */ new WeakMap();
|
|
38579
|
+
function registerPreviewStandIn(standIn, iframe, handle) {
|
|
38580
|
+
standIns.set(standIn, { iframe, handle });
|
|
38581
|
+
}
|
|
38582
|
+
function queueFor(iframe) {
|
|
38583
|
+
let queue2 = queues.get(iframe);
|
|
38584
|
+
if (!queue2) {
|
|
38585
|
+
queue2 = { ops: [], drawn: /* @__PURE__ */ new Map(), sending: false };
|
|
38586
|
+
queues.set(iframe, queue2);
|
|
38587
|
+
}
|
|
38588
|
+
return queue2;
|
|
38589
|
+
}
|
|
38590
|
+
function send2(iframe, queue2) {
|
|
38591
|
+
if (queue2.sending || !queue2.ops.length) return;
|
|
38592
|
+
const drafts = queue2.ops.splice(0, MAX_DESCRIBE_HANDLES3);
|
|
38593
|
+
queue2.sending = true;
|
|
38594
|
+
void previewRequest(iframe, "draft", { drafts }).finally(() => {
|
|
38595
|
+
queue2.sending = false;
|
|
38596
|
+
send2(iframe, queue2);
|
|
38597
|
+
});
|
|
38598
|
+
}
|
|
38599
|
+
function drawPreviewDraft(element, part) {
|
|
38600
|
+
const target = standIns.get(element);
|
|
38601
|
+
if (!target) return;
|
|
38602
|
+
const queue2 = queueFor(target.iframe);
|
|
38603
|
+
const drawn = { translate: null, size: null, ...queue2.drawn.get(target.handle), ...part };
|
|
38604
|
+
queue2.drawn.set(target.handle, drawn);
|
|
38605
|
+
const op = { handle: target.handle, ...drawn };
|
|
38606
|
+
const last = queue2.ops.map((queued) => queued.handle).lastIndexOf(target.handle);
|
|
38607
|
+
const waiting = queue2.ops[last];
|
|
38608
|
+
if (waiting && !("end" in waiting)) queue2.ops[last] = op;
|
|
38609
|
+
else queue2.ops.push(op);
|
|
38610
|
+
send2(target.iframe, queue2);
|
|
38611
|
+
}
|
|
38612
|
+
function endPreviewDraft(element, end) {
|
|
38613
|
+
const target = standIns.get(element);
|
|
38614
|
+
if (!target) return;
|
|
38615
|
+
const queue2 = queueFor(target.iframe);
|
|
38616
|
+
if (!queue2.drawn.delete(target.handle)) return;
|
|
38617
|
+
queue2.ops.push({ handle: target.handle, end });
|
|
38618
|
+
send2(target.iframe, queue2);
|
|
38619
|
+
}
|
|
38620
|
+
|
|
38621
|
+
// src/hooks/draggedGsapPosition.ts
|
|
38622
|
+
var cssValue = (style, prop) => {
|
|
38623
|
+
const value = style.getPropertyValue(prop).trim();
|
|
38624
|
+
return value === "none" ? "" : value;
|
|
38625
|
+
};
|
|
38626
|
+
function readCssRotation(element, withRotate = true) {
|
|
38627
|
+
const view = element.ownerDocument.defaultView;
|
|
38628
|
+
if (!view) return 0;
|
|
38629
|
+
const style = view.getComputedStyle(element);
|
|
38630
|
+
const rotate2 = withRotate ? cssValue(style, "rotate") : "";
|
|
38631
|
+
const scale = cssValue(style, "scale");
|
|
38632
|
+
const transform = cssValue(style, "transform");
|
|
38633
|
+
const angle = (list) => {
|
|
38634
|
+
if (!list) return 0;
|
|
38635
|
+
const m = new view.DOMMatrix(list);
|
|
38636
|
+
return Math.atan2(m.b, m.a) * 180 / Math.PI;
|
|
38637
|
+
};
|
|
38638
|
+
const folded = [rotate2 && `rotate(${rotate2})`, scale && `scale(${scale.split(/\s+/).join(",")})`];
|
|
38639
|
+
try {
|
|
38640
|
+
return angle([...folded, transform].join(" ").trim());
|
|
38641
|
+
} catch {
|
|
38642
|
+
return angle(transform);
|
|
38643
|
+
}
|
|
38644
|
+
}
|
|
38645
|
+
function readDragStamp(element) {
|
|
38646
|
+
const read2 = (name) => Number.parseFloat(element.getAttribute(name) ?? "");
|
|
38647
|
+
return {
|
|
38648
|
+
origX: read2("data-hf-drag-initial-offset-x") || 0,
|
|
38649
|
+
origY: read2("data-hf-drag-initial-offset-y") || 0,
|
|
38650
|
+
baseX: read2("data-hf-drag-gsap-base-x"),
|
|
38651
|
+
baseY: read2("data-hf-drag-gsap-base-y"),
|
|
38652
|
+
at: readEditMoment(element)
|
|
38653
|
+
};
|
|
38654
|
+
}
|
|
38655
|
+
function readEditMoment(element) {
|
|
38656
|
+
const raw = element.getAttribute(STUDIO_EDIT_MOMENT_ATTR);
|
|
38657
|
+
return raw ? JSON.parse(raw) : void 0;
|
|
38658
|
+
}
|
|
38659
|
+
var freezeDragStamp = (element) => ({
|
|
38660
|
+
...readDragStamp(element),
|
|
38661
|
+
frozen: true
|
|
38662
|
+
});
|
|
38663
|
+
function computeDraggedGsapPosition(element, studioOffset, fallbackBase, stamp = readDragStamp(element)) {
|
|
38664
|
+
const rotStyle = element.style.getPropertyValue("--hf-studio-rotation");
|
|
38665
|
+
const rotDeg = Number.parseFloat(rotStyle) || 0;
|
|
38666
|
+
const rad = -rotDeg * Math.PI / 180;
|
|
38667
|
+
const cos = Math.cos(rad);
|
|
38668
|
+
const sin = Math.sin(rad);
|
|
38669
|
+
const deltaX = studioOffset.x - stamp.origX;
|
|
38670
|
+
const deltaY = studioOffset.y - stamp.origY;
|
|
38671
|
+
const adjX = deltaX * cos - deltaY * sin;
|
|
38672
|
+
const adjY = deltaX * sin + deltaY * cos;
|
|
38673
|
+
const baseGsapX = Number.isFinite(stamp.baseX) ? stamp.baseX : fallbackBase.x;
|
|
38674
|
+
const baseGsapY = Number.isFinite(stamp.baseY) ? stamp.baseY : fallbackBase.y;
|
|
38675
|
+
return {
|
|
38676
|
+
newX: roundTo3(baseGsapX + adjX),
|
|
38677
|
+
newY: roundTo3(baseGsapY + adjY),
|
|
38678
|
+
baseGsapX,
|
|
38679
|
+
baseGsapY
|
|
38680
|
+
};
|
|
38681
|
+
}
|
|
38682
|
+
function restoreDragOffset(element, stamp = readDragStamp(element)) {
|
|
38683
|
+
if (stamp.frozen) return;
|
|
38684
|
+
element.style.setProperty("--hf-studio-offset-x", `${stamp.origX}px`);
|
|
38685
|
+
element.style.setProperty("--hf-studio-offset-y", `${stamp.origY}px`);
|
|
38686
|
+
element.removeAttribute("data-hf-drag-initial-offset-x");
|
|
38687
|
+
element.removeAttribute("data-hf-drag-initial-offset-y");
|
|
38688
|
+
}
|
|
38689
|
+
|
|
38690
|
+
// src/components/editor/plainTranslate.ts
|
|
38691
|
+
var TOKEN = /\s*(?:(\d*\.?\d+(?:e[-+]?\d+)?)(px|%)?|([a-z]+)\(|([-+*/(),]))/giy;
|
|
38692
|
+
var FUNCTIONS = {
|
|
38693
|
+
"(": ([a = Number.NaN]) => a,
|
|
38694
|
+
"calc(": ([a = Number.NaN]) => a,
|
|
38695
|
+
"min(": (args) => Math.min(...args),
|
|
38696
|
+
"max(": (args) => Math.max(...args),
|
|
38697
|
+
"clamp(": ([lo = Number.NaN, v = Number.NaN, hi = Number.NaN]) => Math.max(lo, Math.min(v, hi))
|
|
38698
|
+
};
|
|
38699
|
+
function tokenize(value, side) {
|
|
38700
|
+
const tokens = [];
|
|
38701
|
+
const end = value.trimEnd().length;
|
|
38702
|
+
TOKEN.lastIndex = 0;
|
|
38703
|
+
for (let m = TOKEN.exec(value); m; m = TOKEN.lastIndex < end ? TOKEN.exec(value) : null) {
|
|
38704
|
+
if (m[1]) tokens.push(Number(m[1]) * (m[2] === "%" ? side / 100 : 1));
|
|
38705
|
+
else tokens.push(m[3] ? `${m[3].toLowerCase()}(` : m[4] ?? "");
|
|
38706
|
+
}
|
|
38707
|
+
return TOKEN.lastIndex < end ? [] : tokens;
|
|
38708
|
+
}
|
|
38709
|
+
function evaluateLength(value, side) {
|
|
38710
|
+
const tokens = tokenize(value, side);
|
|
38711
|
+
let i = 0;
|
|
38712
|
+
const next = () => tokens[i++];
|
|
38713
|
+
const take = (...ops) => ops.includes(tokens[i]) && next();
|
|
38714
|
+
function sum() {
|
|
38715
|
+
let total2 = product();
|
|
38716
|
+
for (let op = take("+", "-"); op; op = take("+", "-"))
|
|
38717
|
+
total2 += (op === "+" ? 1 : -1) * product();
|
|
38718
|
+
return total2;
|
|
38719
|
+
}
|
|
38720
|
+
function product() {
|
|
38721
|
+
let total2 = unary();
|
|
38722
|
+
for (let op = take("*", "/"); op; op = take("*", "/"))
|
|
38723
|
+
total2 = op === "*" ? total2 * unary() : total2 / unary();
|
|
38724
|
+
return total2;
|
|
38725
|
+
}
|
|
38726
|
+
function unary() {
|
|
38727
|
+
return take("-") ? -unary() : atom();
|
|
38728
|
+
}
|
|
38729
|
+
function atom() {
|
|
38730
|
+
const token = next();
|
|
38731
|
+
if (typeof token === "number") return token;
|
|
38732
|
+
const fn = FUNCTIONS[token ?? ""];
|
|
38733
|
+
if (!fn) return Number.NaN;
|
|
38734
|
+
const args = [sum()];
|
|
38735
|
+
while (take(",")) args.push(sum());
|
|
38736
|
+
return take(")") ? fn(args) : Number.NaN;
|
|
38737
|
+
}
|
|
38738
|
+
const total = tokens.length ? sum() : Number.NaN;
|
|
38739
|
+
return i === tokens.length ? total : Number.NaN;
|
|
38740
|
+
}
|
|
38741
|
+
var CONTENT_BOXES = /* @__PURE__ */ new Set(["content-box", "fill-box"]);
|
|
38742
|
+
var TRANSLATE_PX_PROPERTIES = [
|
|
38743
|
+
"translate",
|
|
38744
|
+
"width",
|
|
38745
|
+
"height",
|
|
38746
|
+
"box-sizing",
|
|
38747
|
+
"transform-box",
|
|
38748
|
+
...["left", "right", "top", "bottom"].flatMap((s) => [`padding-${s}`, `border-${s}-width`])
|
|
38749
|
+
];
|
|
38750
|
+
function referenceBox(read2, size, a, b) {
|
|
38751
|
+
const n = (prop) => Number.parseFloat(read2(prop)) || 0;
|
|
38752
|
+
const pad2 = n(`padding-${a}`) + n(`padding-${b}`) + n(`border-${a}-width`) + n(`border-${b}-width`);
|
|
38753
|
+
const content = n(size) - (read2("box-sizing") === "border-box" ? pad2 : 0);
|
|
38754
|
+
return CONTENT_BOXES.has(read2("transform-box")) ? content : content + pad2;
|
|
38755
|
+
}
|
|
38756
|
+
function translatePx(value, read2) {
|
|
38757
|
+
if (value === "none") return { x: 0, y: 0 };
|
|
38758
|
+
const [x = "0px", y = "0px"] = splitTopLevelWhitespace(value);
|
|
38759
|
+
const side = (size, a, b) => read2 ? referenceBox(read2, size, a, b) : Number.NaN;
|
|
38760
|
+
return {
|
|
38761
|
+
x: evaluateLength(x, side("width", "left", "right")),
|
|
38762
|
+
y: evaluateLength(y, side("height", "top", "bottom"))
|
|
38763
|
+
};
|
|
38764
|
+
}
|
|
38765
|
+
var frameTranslates = /* @__PURE__ */ new WeakMap();
|
|
38766
|
+
function rememberFrameTranslate(el, px) {
|
|
38767
|
+
frameTranslates.set(el, { inline: el.style.getPropertyValue("translate"), px });
|
|
38768
|
+
}
|
|
38769
|
+
function readTranslatePx(el) {
|
|
38770
|
+
const cs = el.ownerDocument.defaultView?.getComputedStyle(el);
|
|
38771
|
+
const inline = el.style.getPropertyValue("translate");
|
|
38772
|
+
const frame3 = cs ? void 0 : frameTranslates.get(el);
|
|
38773
|
+
if (frame3?.inline === inline) return frame3.px;
|
|
38774
|
+
return translatePx(cs?.translate || inline || "none", cs && ((p) => cs.getPropertyValue(p)));
|
|
38775
|
+
}
|
|
38776
|
+
function readTranslatePxLeavingPercent(el) {
|
|
38777
|
+
const value = el.ownerDocument.defaultView?.getComputedStyle(el).translate || "none";
|
|
38778
|
+
const [x = "0px", y = "0px"] = value === "none" ? [] : splitTopLevelWhitespace(value);
|
|
38779
|
+
const px = (part) => roundTo3(evaluateLength(part, 0)) || 0;
|
|
38780
|
+
return { x: px(x), y: px(y) };
|
|
38781
|
+
}
|
|
38782
|
+
var UNREADABLE_TRANSLATE = "Studio can't read this layer's translate. Move it in the Code tab.";
|
|
38783
|
+
function formatTranslatePx(p) {
|
|
38784
|
+
return `${roundTo3(p.x)}px ${roundTo3(p.y)}px`;
|
|
38785
|
+
}
|
|
38786
|
+
var LEGACY_OFFSET_VARS = [STUDIO_OFFSET_X_PROP, STUDIO_OFFSET_Y_PROP];
|
|
38787
|
+
function writePlainMove(el, p) {
|
|
38788
|
+
writeTranslatePx(el, p);
|
|
38789
|
+
const patches = [
|
|
38790
|
+
{ type: "inline-style", property: "translate", value: formatTranslatePx(p) },
|
|
38791
|
+
{
|
|
38792
|
+
type: "attribute",
|
|
38793
|
+
property: STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR,
|
|
38794
|
+
value: el.getAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR)
|
|
38795
|
+
}
|
|
38796
|
+
];
|
|
38797
|
+
for (const prop of LEGACY_OFFSET_VARS.filter((v) => el.style.getPropertyValue(v))) {
|
|
38798
|
+
el.style.removeProperty(prop);
|
|
38799
|
+
patches.push({ type: "inline-style", property: prop, value: null });
|
|
38800
|
+
}
|
|
38801
|
+
if (el.hasAttribute(STUDIO_PATH_OFFSET_ATTR)) {
|
|
38802
|
+
el.removeAttribute(STUDIO_PATH_OFFSET_ATTR);
|
|
38803
|
+
patches.push({ type: "attribute", property: STUDIO_PATH_OFFSET_ATTR, value: null });
|
|
38804
|
+
}
|
|
38805
|
+
return patches;
|
|
38806
|
+
}
|
|
38807
|
+
function writeTranslatePx(el, p) {
|
|
38808
|
+
if (!el.hasAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR)) {
|
|
38809
|
+
const own = el.style.getPropertyValue("translate");
|
|
38810
|
+
el.setAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR, styleUsesStudioOffset(own) ? "" : own);
|
|
38811
|
+
}
|
|
38812
|
+
el.style.setProperty("translate", formatTranslatePx(p));
|
|
38813
|
+
}
|
|
38814
|
+
function readMoveOffset(el, plainTranslate = editsPlainCss(el, "move")) {
|
|
38815
|
+
return plainTranslate ? readTranslatePx(el) : readStudioPathOffset(el);
|
|
38816
|
+
}
|
|
38817
|
+
function readShownRotation(el) {
|
|
38818
|
+
return editsPlainCss(el, "rotate") ? { angle: roundTo3(readCssRotation(el)) } : readStudioRotation(el);
|
|
38819
|
+
}
|
|
38820
|
+
|
|
38821
|
+
// src/components/editor/previewSelection.ts
|
|
38822
|
+
var inertDocument;
|
|
38823
|
+
var inert = () => inertDocument ??= document.implementation.createHTMLDocument("");
|
|
38824
|
+
function inertElement(tag) {
|
|
38825
|
+
try {
|
|
38826
|
+
return inert().createElement(tag);
|
|
38827
|
+
} catch {
|
|
38828
|
+
return inert().createElement("div");
|
|
38829
|
+
}
|
|
38830
|
+
}
|
|
38831
|
+
var GESTURE_START_STYLES = [
|
|
38832
|
+
"translate",
|
|
38833
|
+
STUDIO_OFFSET_X_PROP,
|
|
38834
|
+
STUDIO_OFFSET_Y_PROP,
|
|
38835
|
+
STUDIO_WIDTH_PROP,
|
|
38836
|
+
STUDIO_HEIGHT_PROP
|
|
38837
|
+
];
|
|
38838
|
+
var GESTURE_START_ATTRS = [
|
|
38839
|
+
STUDIO_PATH_OFFSET_ATTR,
|
|
38840
|
+
STUDIO_ORIGINAL_TRANSLATE_ATTR,
|
|
38841
|
+
STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR
|
|
38842
|
+
];
|
|
38843
|
+
var standIns2 = /* @__PURE__ */ new WeakMap();
|
|
38844
|
+
var standInHandles = /* @__PURE__ */ new WeakMap();
|
|
38845
|
+
var standInAncestors = /* @__PURE__ */ new WeakMap();
|
|
38846
|
+
function standInFor(iframe, element) {
|
|
38847
|
+
const client = previewEditingClient(iframe);
|
|
38848
|
+
const byHandle = standIns2.get(client) ?? /* @__PURE__ */ new Map();
|
|
38849
|
+
standIns2.set(client, byHandle);
|
|
38850
|
+
let standIn = byHandle.get(element.handle);
|
|
38851
|
+
if (!standIn) {
|
|
38852
|
+
standIn = inertElement(element.tag);
|
|
38853
|
+
for (const name of GESTURE_START_STYLES) {
|
|
38854
|
+
const value = element.inlineStyles[name];
|
|
38855
|
+
if (value && !mayBeCut(value)) standIn.style.setProperty(name, value);
|
|
38856
|
+
}
|
|
38857
|
+
for (const name of GESTURE_START_ATTRS) {
|
|
38858
|
+
const value = attr(element, name);
|
|
38859
|
+
if (value !== null && !mayBeCut(value)) standIn.setAttribute(name, value);
|
|
38860
|
+
}
|
|
38861
|
+
byHandle.set(element.handle, standIn);
|
|
38862
|
+
standInHandles.set(standIn, element.handle);
|
|
38863
|
+
registerPreviewStandIn(standIn, iframe, element.handle);
|
|
38864
|
+
}
|
|
38865
|
+
return standIn;
|
|
38866
|
+
}
|
|
38867
|
+
function readable(element) {
|
|
38868
|
+
const probe2 = inertElement(element.tag);
|
|
38869
|
+
for (const [name, value] of element.attributes) {
|
|
38870
|
+
if (name !== "id" && name !== "class" && !name.startsWith("data-")) continue;
|
|
38871
|
+
try {
|
|
38872
|
+
probe2.setAttribute(name, value);
|
|
38873
|
+
} catch {
|
|
38874
|
+
}
|
|
38875
|
+
}
|
|
38876
|
+
for (const [name, value] of Object.entries(element.inlineStyles)) {
|
|
38877
|
+
probe2.style.setProperty(name, value);
|
|
38878
|
+
}
|
|
38879
|
+
probe2.textContent = element.text;
|
|
38880
|
+
return probe2;
|
|
38881
|
+
}
|
|
38882
|
+
var attr = (element, name) => element.attributes.find(([key2]) => key2 === name)?.[1] ?? null;
|
|
38883
|
+
var mayBeCut = (value) => value.length >= MAX_ELEMENT_VALUE2 || value.startsWith("data:") && value.endsWith(",");
|
|
38884
|
+
function valuesWhole(element) {
|
|
38885
|
+
if (!element.truncated) return true;
|
|
38886
|
+
const styles = Object.values(element.inlineStyles);
|
|
38887
|
+
if (element.attributes.length >= MAX_ELEMENT_ENTRIES2 || styles.length >= MAX_ELEMENT_ENTRIES2)
|
|
38888
|
+
return false;
|
|
38889
|
+
return ![...element.attributes.map(([, value]) => value), ...styles].some(mayBeCut);
|
|
38890
|
+
}
|
|
38891
|
+
var hasAudio = (element) => element.tag === "video" && attr(element, "muted") === null && isVideoAudible({ tag: "video", hasAudioAttr: attr(element, "data-has-audio"), muted: false });
|
|
38892
|
+
var validSelector = (selector) => {
|
|
38893
|
+
try {
|
|
38894
|
+
inert().querySelector(selector);
|
|
38895
|
+
return true;
|
|
38896
|
+
} catch {
|
|
38897
|
+
return false;
|
|
38898
|
+
}
|
|
38899
|
+
};
|
|
38900
|
+
async function findPreviewElementForSelection(iframe, selection, activeCompositionPath) {
|
|
38901
|
+
for (const { selector, index: index2 } of selectionLookups(selection)) {
|
|
38902
|
+
if (!validSelector(selector)) continue;
|
|
38903
|
+
const reply = await queryPreviewElements(iframe, selector);
|
|
38904
|
+
if (!reply) return void 0;
|
|
38905
|
+
const fromFile = reply.matches.filter(
|
|
38906
|
+
({ source }) => !selection.sourceFile || resolveElementSourceFile(source, activeCompositionPath) === selection.sourceFile
|
|
38907
|
+
);
|
|
38908
|
+
const match = fromFile[index2];
|
|
38909
|
+
if (!match) {
|
|
38910
|
+
if (reply.truncated) return void 0;
|
|
38911
|
+
continue;
|
|
38912
|
+
}
|
|
38913
|
+
const [element] = await describePreviewElements(iframe, [match.handle]) ?? [];
|
|
38914
|
+
return element ?? void 0;
|
|
38915
|
+
}
|
|
38916
|
+
return null;
|
|
38917
|
+
}
|
|
38918
|
+
async function findByClipId(iframe, element, sourceFile, path) {
|
|
38919
|
+
if (!element.id || element.domId || element.selector || element.compositionSrc) return null;
|
|
38920
|
+
const byId = await findPreviewElementForSelection(iframe, { id: element.id, sourceFile }, path);
|
|
38921
|
+
if (byId !== null) return byId;
|
|
38922
|
+
return findPreviewElementForSelection(iframe, { hfId: element.id, sourceFile }, path);
|
|
38923
|
+
}
|
|
38924
|
+
async function findPreviewElementForTimelineElement(iframe, element, options) {
|
|
38925
|
+
const { target, sourceFile, rootFallback } = timelineElementLookup(element, options);
|
|
38926
|
+
const path = options.activeCompositionPath;
|
|
38927
|
+
const found = target && await findPreviewElementForSelection(iframe, target, path);
|
|
38928
|
+
if (found !== null) return found;
|
|
38929
|
+
const byClipId = await findByClipId(iframe, element, sourceFile, path);
|
|
38930
|
+
if (byClipId !== null) return byClipId;
|
|
38931
|
+
if (!rootFallback) return null;
|
|
38932
|
+
const reply = await queryPreviewElements(iframe, "[data-composition-id]");
|
|
38933
|
+
if (!reply) return void 0;
|
|
38934
|
+
const root = reply.matches[0];
|
|
38935
|
+
if (!root || resolveElementSourceFile(root.source, path) !== sourceFile) return null;
|
|
38936
|
+
const [described] = await describePreviewElements(iframe, [root.handle]) ?? [];
|
|
38937
|
+
return described ?? void 0;
|
|
38938
|
+
}
|
|
38939
|
+
async function previewChain(iframe, target) {
|
|
38940
|
+
const [lineage] = await previewAncestors(iframe, [target.handle]) ?? [];
|
|
38941
|
+
if (!lineage) return null;
|
|
38942
|
+
const ancestors = lineage.length ? await describePreviewElements(iframe, lineage) : [];
|
|
38943
|
+
if (!ancestors || ancestors.some((entry3) => entry3 === null)) return null;
|
|
38944
|
+
const chain = [target, ...ancestors];
|
|
38945
|
+
const linked = chain.every((node, i) => node.parent === (chain[i + 1]?.handle ?? null));
|
|
38946
|
+
return linked ? chain : null;
|
|
38947
|
+
}
|
|
38948
|
+
function chainReader(chain) {
|
|
38949
|
+
const root = chain.at(-1);
|
|
38950
|
+
const body = chain.at(-2);
|
|
38951
|
+
return {
|
|
38952
|
+
attr,
|
|
38953
|
+
selector: (node) => node.selector ?? void 0,
|
|
38954
|
+
isDocumentRoot: (node) => node === root || node === body && node.tag === "body"
|
|
38955
|
+
};
|
|
38956
|
+
}
|
|
38957
|
+
async function compositionRoot2(iframe, documentElement) {
|
|
38958
|
+
const reply = await queryPreviewElements(iframe, "[data-composition-id]");
|
|
38959
|
+
if (!reply) return null;
|
|
38960
|
+
const first = reply.matches[0];
|
|
38961
|
+
const [root] = first ? await describePreviewElements(iframe, [first.handle]) ?? [null] : [];
|
|
38962
|
+
if (root === null) return null;
|
|
38963
|
+
const element = root ?? documentElement;
|
|
38964
|
+
const { x, y, width, height } = element.rect;
|
|
38965
|
+
return {
|
|
38966
|
+
rect: { left: x, top: y, width, height },
|
|
38967
|
+
width: attr(element, "data-width"),
|
|
38968
|
+
height: attr(element, "data-height")
|
|
38969
|
+
};
|
|
38970
|
+
}
|
|
38971
|
+
function chainIndex(chain, read2, options) {
|
|
38972
|
+
const active = options.activeGroupElement;
|
|
38973
|
+
const activeHandle = active ? standInHandles.get(active) : void 0;
|
|
38974
|
+
return selectionTargetIndex(chain, read2, {
|
|
38975
|
+
exactTarget: options.exactTarget,
|
|
38976
|
+
preferClipAncestor: options.preferClipAncestor,
|
|
38977
|
+
activeGroupIndex: active ? chain.findIndex((node) => node.handle === activeHandle) : null
|
|
38978
|
+
});
|
|
38979
|
+
}
|
|
38980
|
+
function previewIdentity(current2, path) {
|
|
38981
|
+
const selector = current2.selector ?? void 0;
|
|
38982
|
+
return {
|
|
38983
|
+
id: current2.id || void 0,
|
|
38984
|
+
hfId: attr(current2, "data-hf-id")?.trim() || void 0,
|
|
38985
|
+
selector,
|
|
38986
|
+
selectorIndex: selector ? previewElementSelectorIndex(current2, path) : void 0,
|
|
38987
|
+
sourceFile: previewElementSourceFile(current2, path)
|
|
38988
|
+
};
|
|
38989
|
+
}
|
|
38990
|
+
async function isPreviewCompositionRoot(iframe, chain, index2, computedStyles) {
|
|
38991
|
+
const current2 = chain[index2];
|
|
38992
|
+
if (attr(current2, "data-composition-id") !== null && !compositionSourceOf(current2)) return true;
|
|
38993
|
+
const parent = chain[index2 + 1];
|
|
38994
|
+
const underBody = parent?.tag === "body" && chainReader(chain).isDocumentRoot(parent);
|
|
38995
|
+
if (!underBody || attr(current2, "data-hf-allow-root-edit") !== null) return false;
|
|
38996
|
+
const { x, y, width, height } = current2.rect;
|
|
38997
|
+
const rect = { left: x, top: y, width, height };
|
|
38998
|
+
const root = await compositionRoot2(iframe, chain.at(-1));
|
|
38999
|
+
return root && coversCompositionRoot({ rect, computedStyles }, root);
|
|
39000
|
+
}
|
|
39001
|
+
var compositionSourceOf = (element) => attr(element, "data-composition-src") ?? attr(element, "data-composition-file") ?? void 0;
|
|
39002
|
+
async function resolvePreviewSelection(iframe, target, options) {
|
|
39003
|
+
const chain = await previewChain(iframe, target);
|
|
39004
|
+
const index2 = chain && chainIndex(chain, chainReader(chain), options);
|
|
39005
|
+
if (!chain || index2 === null) return null;
|
|
39006
|
+
const current2 = chain[index2];
|
|
39007
|
+
if (!valuesWhole(current2)) return null;
|
|
39008
|
+
const element = standInFor(iframe, current2);
|
|
39009
|
+
standInAncestors.set(
|
|
39010
|
+
element,
|
|
39011
|
+
chain.slice(index2 + 1).map((node) => node.handle)
|
|
39012
|
+
);
|
|
39013
|
+
const identity = previewIdentity(current2, options.activeCompositionPath);
|
|
39014
|
+
const compositionSrc = compositionSourceOf(current2);
|
|
39015
|
+
const probe2 = readable(current2);
|
|
39016
|
+
const inlineStyles = getInlineStyles(probe2);
|
|
39017
|
+
const styles = await previewComputedStyles(iframe, current2, [
|
|
39018
|
+
.../* @__PURE__ */ new Set([...CURATED_STYLE_PROPERTIES, ...TRANSLATE_PX_PROPERTIES])
|
|
39019
|
+
]);
|
|
39020
|
+
if (!styles) return null;
|
|
39021
|
+
rememberFrameTranslate(
|
|
39022
|
+
element,
|
|
39023
|
+
translatePx(styles.translate ?? "none", (p) => styles[p] ?? "")
|
|
39024
|
+
);
|
|
39025
|
+
const computedStyles = Object.fromEntries(
|
|
39026
|
+
CURATED_STYLE_PROPERTIES.flatMap((p) => p in styles ? [[p, styles[p]]] : [])
|
|
39027
|
+
);
|
|
39028
|
+
const isCompositionRoot = await isPreviewCompositionRoot(iframe, chain, index2, computedStyles);
|
|
39029
|
+
if (isCompositionRoot === null) return null;
|
|
39030
|
+
const isInsideLocked = chainLocked(chain, chainReader(chain), index2);
|
|
39031
|
+
const { sourceFile } = identity;
|
|
39032
|
+
const existsInSource = await existsInSourceFile(
|
|
39033
|
+
options.previous,
|
|
39034
|
+
element,
|
|
39035
|
+
sourceFile,
|
|
39036
|
+
identity,
|
|
39037
|
+
options
|
|
39038
|
+
);
|
|
39039
|
+
const capabilities = resolveEditingAffordances(
|
|
39040
|
+
capabilityFacts({
|
|
39041
|
+
hasStableTarget: Boolean(identity.selector || identity.hfId),
|
|
39042
|
+
tag: current2.tag,
|
|
39043
|
+
inlineStyles,
|
|
39044
|
+
computedStyles,
|
|
39045
|
+
isCompositionHost: Boolean(compositionSrc),
|
|
39046
|
+
isCompositionRoot,
|
|
39047
|
+
isInsideLockedComposition: isInsideLocked,
|
|
39048
|
+
isMasterView: options.isMasterView,
|
|
39049
|
+
existsInSource: existsInSource ?? true
|
|
39050
|
+
})
|
|
39051
|
+
).capabilities;
|
|
39052
|
+
const { x, y, width, height } = current2.rect;
|
|
39053
|
+
return {
|
|
39054
|
+
element,
|
|
39055
|
+
handle: current2.handle,
|
|
39056
|
+
hasAudio: hasAudio(current2),
|
|
39057
|
+
src: attr(current2, "src"),
|
|
39058
|
+
...identity,
|
|
39059
|
+
compositionPath: sourceFile,
|
|
39060
|
+
compositionSrc,
|
|
39061
|
+
isCompositionHost: Boolean(compositionSrc),
|
|
39062
|
+
isInsideLockedComposition: isInsideLocked,
|
|
39063
|
+
label: buildElementLabel(probe2),
|
|
39064
|
+
tagName: current2.tag,
|
|
39065
|
+
boundingBox: { x, y, width, height },
|
|
39066
|
+
textContent: current2.text.trim() || null,
|
|
39067
|
+
dataAttributes: getDataAttributes(probe2),
|
|
39068
|
+
inlineStyles,
|
|
39069
|
+
computedStyles,
|
|
39070
|
+
textFields: [],
|
|
39071
|
+
capabilities,
|
|
39072
|
+
existsInSource
|
|
39073
|
+
};
|
|
39074
|
+
}
|
|
39075
|
+
function liveElementForSelection(iframe, selection, activeCompositionPath) {
|
|
39076
|
+
let doc = null;
|
|
39077
|
+
try {
|
|
39078
|
+
doc = iframe?.contentDocument ?? null;
|
|
39079
|
+
} catch {
|
|
39080
|
+
return void 0;
|
|
39081
|
+
}
|
|
39082
|
+
return doc ? findElementForSelection(doc, selection, activeCompositionPath) : void 0;
|
|
39083
|
+
}
|
|
39084
|
+
async function findSelectionElement(iframe, selection, activeCompositionPath) {
|
|
39085
|
+
return iframe && previewFrameOpaque(iframe) ? findPreviewElementForSelection(iframe, selection, activeCompositionPath) : liveElementForSelection(iframe, selection, activeCompositionPath);
|
|
39086
|
+
}
|
|
39087
|
+
async function resolveFoundSelection(iframe, found, options) {
|
|
39088
|
+
if (isHtmlElement(found)) return resolveDomEditSelection(found, options);
|
|
39089
|
+
return iframe ? resolvePreviewSelection(iframe, found, options) : null;
|
|
39090
|
+
}
|
|
39091
|
+
async function findOpaqueTimelineElement(iframe, element, lookup2) {
|
|
39092
|
+
if (!iframe || !previewFrameOpaque(iframe)) return null;
|
|
39093
|
+
return await findPreviewElementForTimelineElement(iframe, element, lookup2) ?? null;
|
|
39094
|
+
}
|
|
39095
|
+
var standInHandle = (element) => standInHandles.get(element);
|
|
39096
|
+
function elementWithin(container, element) {
|
|
39097
|
+
const handle = standInHandles.get(container);
|
|
39098
|
+
if (handle === void 0) return container.contains(element);
|
|
39099
|
+
return element === container || (standInAncestors.get(element)?.includes(handle) ?? false);
|
|
39100
|
+
}
|
|
39101
|
+
function selectionDataAttribute(selection, name) {
|
|
39102
|
+
if (!selection.handle) return selection.element.getAttribute(name);
|
|
39103
|
+
return selection.dataAttributes[name.slice("data-".length)] ?? null;
|
|
39104
|
+
}
|
|
39105
|
+
var pointerAnswers = /* @__PURE__ */ new WeakMap();
|
|
39106
|
+
async function previewPointerTarget(iframe, clientX, clientY) {
|
|
39107
|
+
const { x, y } = framePointFraction(iframe, clientX, clientY);
|
|
39108
|
+
const reply = await previewPointerTargets(iframe, x, y);
|
|
39109
|
+
if (reply) pointerAnswers.set(iframe, { x: clientX, y: clientY, found: reply.target !== null });
|
|
39110
|
+
return reply;
|
|
39111
|
+
}
|
|
39112
|
+
function pointerMayHitElement(iframe, clientX, clientY) {
|
|
39113
|
+
if (!previewFrameOpaque(iframe))
|
|
39114
|
+
return Boolean(getPreviewTargetFromPointer(iframe, clientX, clientY));
|
|
39115
|
+
const answer = pointerAnswers.get(iframe);
|
|
39116
|
+
const near4 = answer && Math.hypot(answer.x - clientX, answer.y - clientY) <= 2;
|
|
39117
|
+
return near4 ? answer.found : true;
|
|
39118
|
+
}
|
|
39119
|
+
async function findPointerTarget(iframe, clientX, clientY) {
|
|
39120
|
+
if (!previewFrameOpaque(iframe)) return getPreviewTargetFromPointer(iframe, clientX, clientY);
|
|
39121
|
+
const reply = await previewPointerTarget(iframe, clientX, clientY);
|
|
39122
|
+
if (!reply?.target) return reply ? null : void 0;
|
|
39123
|
+
const [described] = await describePreviewElements(iframe, [reply.target.handle]) ?? [];
|
|
39124
|
+
return described ?? void 0;
|
|
39125
|
+
}
|
|
39126
|
+
async function findPointerTargets(iframe, clientX, clientY) {
|
|
39127
|
+
if (!previewFrameOpaque(iframe)) return getAllPreviewTargetsFromPointer(iframe, clientX, clientY);
|
|
39128
|
+
const reply = await previewPointerTarget(iframe, clientX, clientY);
|
|
39129
|
+
const handles = reply?.stack.map((hit) => hit.handle) ?? [];
|
|
39130
|
+
const described = handles.length ? await describePreviewElements(iframe, handles) : [];
|
|
39131
|
+
return (described ?? []).filter((element) => element !== null);
|
|
39132
|
+
}
|
|
39133
|
+
var selectionElementLive = (selection) => selection.handle !== void 0 || selection.element.isConnected;
|
|
39134
|
+
|
|
39135
|
+
// src/components/editor/previewLayers.ts
|
|
39136
|
+
async function describeAll(iframe, handles) {
|
|
39137
|
+
const described = [];
|
|
39138
|
+
for (let at = 0; at < handles.length; at += MAX_DESCRIBE_HANDLES4) {
|
|
39139
|
+
const part = await describePreviewElements(
|
|
39140
|
+
iframe,
|
|
39141
|
+
handles.slice(at, at + MAX_DESCRIBE_HANDLES4)
|
|
39142
|
+
);
|
|
39143
|
+
if (!part) return null;
|
|
39144
|
+
described.push(...part);
|
|
39145
|
+
}
|
|
39146
|
+
return described;
|
|
39147
|
+
}
|
|
39148
|
+
function layerItem(iframe, layer, element, path) {
|
|
39149
|
+
const probe2 = readable(element);
|
|
39150
|
+
const identity = previewIdentity(element, path);
|
|
39151
|
+
return {
|
|
39152
|
+
...identity,
|
|
39153
|
+
key: getDomEditLayerKey(identity),
|
|
39154
|
+
element: standInFor(iframe, element),
|
|
39155
|
+
label: buildElementLabel(probe2),
|
|
39156
|
+
tagName: element.tag,
|
|
39157
|
+
depth: layer.depth,
|
|
39158
|
+
childCount: layer.childCount,
|
|
39159
|
+
preview: {
|
|
39160
|
+
handle: layer.handle,
|
|
39161
|
+
zIndex: layer.zIndex,
|
|
39162
|
+
kind: layer.kind,
|
|
39163
|
+
dataAttributes: getDataAttributes(probe2)
|
|
39164
|
+
}
|
|
39165
|
+
};
|
|
39166
|
+
}
|
|
39167
|
+
async function collectPreviewLayerItems(iframe, options, maxItems = Number.POSITIVE_INFINITY) {
|
|
39168
|
+
const group = options.activeGroupElement && standInHandle(options.activeGroupElement);
|
|
39169
|
+
const reply = await previewLayers(iframe, group ?? void 0);
|
|
39170
|
+
const layers = reply?.layers.slice(0, maxItems) ?? [];
|
|
39171
|
+
const described = reply && await describeAll(
|
|
39172
|
+
iframe,
|
|
39173
|
+
layers.map((layer) => layer.handle)
|
|
39174
|
+
);
|
|
39175
|
+
if (!reply || !described) return null;
|
|
39176
|
+
const items = layers.flatMap((layer, index2) => {
|
|
39177
|
+
const element = described[index2];
|
|
39178
|
+
return element ? [layerItem(iframe, layer, element, options.activeCompositionPath)] : [];
|
|
39179
|
+
});
|
|
39180
|
+
return { items, missingGroup: reply.missingGroup };
|
|
39181
|
+
}
|
|
39182
|
+
var MAX_LAYER_PAGES = 64;
|
|
39183
|
+
async function allPreviewLayers(iframe) {
|
|
39184
|
+
const layers = [];
|
|
39185
|
+
for (let page = 0; page < MAX_LAYER_PAGES; page += 1) {
|
|
39186
|
+
const reply = await previewLayers(iframe, void 0, layers.length);
|
|
39187
|
+
if (!reply) return null;
|
|
39188
|
+
layers.push(...reply.layers);
|
|
39189
|
+
if (!reply.truncated || !reply.layers.length) break;
|
|
39190
|
+
}
|
|
39191
|
+
return layers;
|
|
39192
|
+
}
|
|
39193
|
+
function layerDataAttribute(layer, name) {
|
|
39194
|
+
if (!layer.preview) return layer.element.getAttribute(name);
|
|
39195
|
+
return layer.preview.dataAttributes[name.slice("data-".length)] ?? null;
|
|
39196
|
+
}
|
|
39197
|
+
async function compositionViewport(iframe) {
|
|
39198
|
+
const roots = await queryPreviewElements(iframe, "[data-composition-id]");
|
|
39199
|
+
const root = roots?.matches[0] ?? (await queryPreviewElements(iframe, "html"))?.matches[0];
|
|
39200
|
+
const [described] = root && await describePreviewElements(iframe, [root.handle]) || [];
|
|
39201
|
+
if (!described) return null;
|
|
39202
|
+
const declared = (name) => Number.parseFloat(described.attributes.find(([key2]) => key2 === name)?.[1] ?? "");
|
|
39203
|
+
const [width, height] = [declared("data-width"), declared("data-height")];
|
|
39204
|
+
return {
|
|
39205
|
+
width: width > 0 ? width : described.rect.width || 1,
|
|
39206
|
+
height: height > 0 ? height : described.rect.height || 1
|
|
39207
|
+
};
|
|
39208
|
+
}
|
|
39209
|
+
async function collectPreviewMarqueeCandidates(iframe, overlayEl) {
|
|
39210
|
+
const layers = await allPreviewLayers(iframe);
|
|
39211
|
+
const handles = layers?.map((layer) => layer.handle) ?? [];
|
|
39212
|
+
const viewport2 = handles.length ? await compositionViewport(iframe) : null;
|
|
39213
|
+
const described = viewport2 && await describeAll(iframe, handles);
|
|
39214
|
+
const measured = described && await measurePreviewVisibleRects(iframe, overlayEl, handles);
|
|
39215
|
+
if (!described || !measured || !viewport2) return [];
|
|
39216
|
+
return handles.flatMap((_, index2) => {
|
|
39217
|
+
const description = described[index2];
|
|
39218
|
+
const box = measured[index2];
|
|
39219
|
+
if (!description || !box?.visible || coversComposition(box.frame, viewport2)) return [];
|
|
39220
|
+
const { left, top, width, height } = box.rect;
|
|
39221
|
+
const element = standInFor(iframe, description);
|
|
39222
|
+
return [{ element, rect: { left, top, width, height }, description }];
|
|
39223
|
+
});
|
|
39224
|
+
}
|
|
39225
|
+
async function resolvePreviewMarqueeHits(iframe, hits, activeCompositionPath) {
|
|
39226
|
+
const isMasterView = !activeCompositionPath || activeCompositionPath === "index.html";
|
|
39227
|
+
const options = { activeCompositionPath, isMasterView, skipSourceProbe: true };
|
|
39228
|
+
const picks = [];
|
|
39229
|
+
for (const hit of hits) {
|
|
39230
|
+
const selection = await resolvePreviewSelection(iframe, hit.description, options);
|
|
39231
|
+
if (selection) picks.push(selection);
|
|
39232
|
+
}
|
|
39233
|
+
return picks;
|
|
39234
|
+
}
|
|
39235
|
+
|
|
38554
39236
|
// src/components/editor/marqueeCommit.ts
|
|
38555
39237
|
function currentMarqueeCandidates(cached5, iframe, overlay, path) {
|
|
38556
39238
|
if (cached5?.every((hit) => hit.element.ownerDocument === iframe.contentDocument)) return cached5;
|
|
@@ -38605,6 +39287,16 @@ async function resolveDomEditSelections(elements, activeCompositionPath) {
|
|
|
38605
39287
|
}
|
|
38606
39288
|
return hits;
|
|
38607
39289
|
}
|
|
39290
|
+
function bandCandidates(iframe, overlay, acp, measured) {
|
|
39291
|
+
if (!previewFrameOpaque(iframe))
|
|
39292
|
+
return currentMarqueeCandidates(measured.cached, iframe, overlay, acp);
|
|
39293
|
+
return measured.measuring ?? collectPreviewMarqueeCandidates(iframe, overlay);
|
|
39294
|
+
}
|
|
39295
|
+
function resolveMarqueeHits(iframe, hits, acp) {
|
|
39296
|
+
const elements = hits.map((hit) => hit.element);
|
|
39297
|
+
if (!previewFrameOpaque(iframe)) return resolveDomEditSelections(elements, acp);
|
|
39298
|
+
return resolvePreviewMarqueeHits(iframe, hits, acp);
|
|
39299
|
+
}
|
|
38608
39300
|
function trackMarqueeSelection(result) {
|
|
38609
39301
|
if (result?.changed && result.count > 1) trackPreviewFeatureUsed("multi_select", "drag");
|
|
38610
39302
|
}
|
|
@@ -38619,16 +39311,18 @@ function useMarqueeGestures(deps) {
|
|
|
38619
39311
|
const [marqueeRect, setMarqueeRect] = useState50(null);
|
|
38620
39312
|
const [candidateRects, setCandidateRects] = useState50([]);
|
|
38621
39313
|
const candidatesRef = useRef67(null);
|
|
39314
|
+
const opaqueCandidatesRef = useRef67(null);
|
|
39315
|
+
const bandRef = useRef67(null);
|
|
38622
39316
|
const commitMarquee = useCallback58(
|
|
38623
39317
|
async (rect, mode) => {
|
|
38624
39318
|
const iframe = deps.iframeRef.current;
|
|
38625
39319
|
const overlay = deps.overlayRef.current;
|
|
38626
39320
|
if (!iframe || !overlay || !deps.onMarqueeSelectRef.current) return;
|
|
38627
39321
|
const acp = deps.activeCompositionPathRef.current ?? "index.html";
|
|
38628
|
-
const
|
|
38629
|
-
const
|
|
39322
|
+
const measured = { cached: candidatesRef.current, measuring: opaqueCandidatesRef.current };
|
|
39323
|
+
const hits = hitsWithin(rect, await bandCandidates(iframe, overlay, acp, measured));
|
|
38630
39324
|
const resolveHits = deps.resolveHits;
|
|
38631
|
-
const picks = resolveHits ? await resolveHits(
|
|
39325
|
+
const picks = resolveHits ? await resolveHits(hits.map((hit) => hit.element)) : await resolveMarqueeHits(iframe, hits, acp);
|
|
38632
39326
|
const applySelection = deps.onMarqueeSelectRef.current;
|
|
38633
39327
|
if (!applySelection) return;
|
|
38634
39328
|
const result = applySelection(picks, mode);
|
|
@@ -38647,6 +39341,8 @@ function useMarqueeGestures(deps) {
|
|
|
38647
39341
|
setMarqueeRect(null);
|
|
38648
39342
|
setCandidateRects([]);
|
|
38649
39343
|
candidatesRef.current = null;
|
|
39344
|
+
opaqueCandidatesRef.current = null;
|
|
39345
|
+
bandRef.current = null;
|
|
38650
39346
|
}, []);
|
|
38651
39347
|
const begin = useCallback58(
|
|
38652
39348
|
(event) => {
|
|
@@ -38692,6 +39388,18 @@ function useMarqueeGestures(deps) {
|
|
|
38692
39388
|
const overlay = deps.overlayRef.current;
|
|
38693
39389
|
if (!iframe || !overlay) return;
|
|
38694
39390
|
const acp = deps.activeCompositionPathRef.current ?? "index.html";
|
|
39391
|
+
bandRef.current = { rect, mode };
|
|
39392
|
+
if (!candidatesRef.current && previewFrameOpaque(iframe)) {
|
|
39393
|
+
if (opaqueCandidatesRef.current) return;
|
|
39394
|
+
const measuring = collectPreviewMarqueeCandidates(iframe, overlay);
|
|
39395
|
+
opaqueCandidatesRef.current = measuring;
|
|
39396
|
+
void measuring.then((hits2) => {
|
|
39397
|
+
if (opaqueCandidatesRef.current !== measuring || !bandRef.current) return;
|
|
39398
|
+
candidatesRef.current = hits2;
|
|
39399
|
+
showCandidates(bandRef.current.rect, bandRef.current.mode);
|
|
39400
|
+
});
|
|
39401
|
+
return;
|
|
39402
|
+
}
|
|
38695
39403
|
candidatesRef.current ??= collectMarqueeCandidates(iframe, overlay, acp);
|
|
38696
39404
|
let hits = hitsWithin(rect, candidatesRef.current);
|
|
38697
39405
|
if (mode === "subtract") hits = hits.filter((h) => isSelectedElement(h.element));
|
|
@@ -38714,6 +39422,7 @@ function useMarqueeGestures(deps) {
|
|
|
38714
39422
|
if (Math.hypot(dx, dy) < MARQUEE_THRESHOLD_PX) return;
|
|
38715
39423
|
m.pastThreshold = true;
|
|
38716
39424
|
candidatesRef.current = null;
|
|
39425
|
+
opaqueCandidatesRef.current = null;
|
|
38717
39426
|
}
|
|
38718
39427
|
const rect = {
|
|
38719
39428
|
left: Math.min(m.startX, m.currentX),
|
|
@@ -38919,6 +39628,7 @@ function useDomEditOverlayRects({
|
|
|
38919
39628
|
const resolvedHoverElementRef = useRef69(null);
|
|
38920
39629
|
const resolvedGroupElementRef = useRef69(/* @__PURE__ */ new Map());
|
|
38921
39630
|
const childRectsRef = useRef69([]);
|
|
39631
|
+
const channelReadRef = useRef69(false);
|
|
38922
39632
|
const setOverlayRect = (next) => {
|
|
38923
39633
|
if (rectsEqual(overlayRectRef.current, next)) return;
|
|
38924
39634
|
overlayRectRef.current = next;
|
|
@@ -38946,6 +39656,61 @@ function useDomEditOverlayRects({
|
|
|
38946
39656
|
}
|
|
38947
39657
|
return next;
|
|
38948
39658
|
};
|
|
39659
|
+
const setChildRects = (next) => {
|
|
39660
|
+
if (childRectsEqual(childRectsRef.current, next)) return;
|
|
39661
|
+
childRectsRef.current = next;
|
|
39662
|
+
setChildRectsState(next);
|
|
39663
|
+
};
|
|
39664
|
+
const distinctGroup = (group) => {
|
|
39665
|
+
const keys = /* @__PURE__ */ new Set();
|
|
39666
|
+
return group.flatMap((selection) => {
|
|
39667
|
+
const key2 = selectionCacheKey(selection);
|
|
39668
|
+
if (keys.has(key2)) return [];
|
|
39669
|
+
keys.add(key2);
|
|
39670
|
+
return [{ key: key2, selection }];
|
|
39671
|
+
});
|
|
39672
|
+
};
|
|
39673
|
+
const hoverShown = (sel, group) => {
|
|
39674
|
+
const hoverSel = hoverSelectionRef.current;
|
|
39675
|
+
const key2 = hoverSel && selectionCacheKey(hoverSel);
|
|
39676
|
+
const covered = sel && selectionCacheKey(sel) === key2 || group.some((entry3) => selectionCacheKey(entry3) === key2);
|
|
39677
|
+
return covered ? null : hoverSel;
|
|
39678
|
+
};
|
|
39679
|
+
const updateOverChannel = (iframe, overlayEl) => {
|
|
39680
|
+
if (channelReadRef.current) return;
|
|
39681
|
+
const sel = selectionRef.current;
|
|
39682
|
+
const group = groupSelectionsRef.current;
|
|
39683
|
+
const members = distinctGroup(group);
|
|
39684
|
+
const hover = hoverShown(sel, group);
|
|
39685
|
+
const targets = {
|
|
39686
|
+
selection: sel?.handle ?? null,
|
|
39687
|
+
group: members.map(({ selection }) => selection.handle ?? null),
|
|
39688
|
+
hover: hover?.handle ?? null
|
|
39689
|
+
};
|
|
39690
|
+
if (!sel && !members.length && !hover) {
|
|
39691
|
+
setOverlayRect(null);
|
|
39692
|
+
setChildRects([]);
|
|
39693
|
+
setGroupOverlayItems([]);
|
|
39694
|
+
setHoverRect(null);
|
|
39695
|
+
return;
|
|
39696
|
+
}
|
|
39697
|
+
channelReadRef.current = true;
|
|
39698
|
+
void measurePreviewOverlay(iframe, overlayEl, targets).then((rects) => {
|
|
39699
|
+
const current2 = selectionRef.current === sel && groupSelectionsRef.current === group && hoverShown(sel, group) === hover;
|
|
39700
|
+
if (!rects || !current2 || rafPausedRef.current || iframeRef.current !== iframe) return;
|
|
39701
|
+
setOverlayRect(rects.selection);
|
|
39702
|
+
setChildRects(rects.children);
|
|
39703
|
+
setGroupOverlayItems(
|
|
39704
|
+
members.flatMap(({ key: key2, selection }, index2) => {
|
|
39705
|
+
const rect = rects.group[index2];
|
|
39706
|
+
return rect ? [{ key: key2, selection, element: selection.element, rect }] : [];
|
|
39707
|
+
})
|
|
39708
|
+
);
|
|
39709
|
+
setHoverRect(rects.hover);
|
|
39710
|
+
}).finally(() => {
|
|
39711
|
+
channelReadRef.current = false;
|
|
39712
|
+
});
|
|
39713
|
+
};
|
|
38949
39714
|
useMountEffect(() => {
|
|
38950
39715
|
const clearAll = () => {
|
|
38951
39716
|
setOverlayRect(null);
|
|
@@ -39067,7 +39832,14 @@ function useDomEditOverlayRects({
|
|
|
39067
39832
|
}
|
|
39068
39833
|
setHoverRect(orientedGroupAwareOverlayRect(overlayEl, iframe, hoverEl, scale));
|
|
39069
39834
|
};
|
|
39070
|
-
|
|
39835
|
+
const frame3 = () => {
|
|
39836
|
+
const iframe = iframeRef.current;
|
|
39837
|
+
const overlayEl = overlayRef.current;
|
|
39838
|
+
const channel = !rafPausedRef.current && iframe && overlayEl && !iframe.contentDocument;
|
|
39839
|
+
if (channel && previewFrameOpaque(iframe)) updateOverChannel(iframe, overlayEl);
|
|
39840
|
+
else update();
|
|
39841
|
+
};
|
|
39842
|
+
return subscribeOverlayFrame(frame3);
|
|
39071
39843
|
});
|
|
39072
39844
|
return {
|
|
39073
39845
|
overlayRect,
|
|
@@ -39145,7 +39917,7 @@ function OffCanvasIndicators({
|
|
|
39145
39917
|
const selectOffCanvas = async () => {
|
|
39146
39918
|
const el = elements.current.get(r.key);
|
|
39147
39919
|
if (!el) return;
|
|
39148
|
-
const { resolveDomEditSelection: resolveDomEditSelection2 } = await import("./domEditingLayers-
|
|
39920
|
+
const { resolveDomEditSelection: resolveDomEditSelection2 } = await import("./domEditingLayers-SA5KLSSS.js");
|
|
39149
39921
|
const acp = activeCompositionPathRef.current ?? "index.html";
|
|
39150
39922
|
const sel = await resolveDomEditSelection2(el, {
|
|
39151
39923
|
activeCompositionPath: acp,
|
|
@@ -39352,12 +40124,12 @@ function mergeFileChangePayloads(waiting, incoming) {
|
|
|
39352
40124
|
|
|
39353
40125
|
// src/components/editor/manualEditsSeekReapply.ts
|
|
39354
40126
|
import { isHtmlElement as isHtmlElement5 } from "@hyperframes/core/runtime/dom-realm";
|
|
39355
|
-
function queryStudioElements(doc,
|
|
39356
|
-
const elements = Array.from(doc.querySelectorAll(`[${
|
|
39357
|
-
const legacyAttr = `data-${
|
|
40127
|
+
function queryStudioElements(doc, attr2) {
|
|
40128
|
+
const elements = Array.from(doc.querySelectorAll(`[${attr2}="true"]`)).filter(isHtmlElement5);
|
|
40129
|
+
const legacyAttr = `data-${attr2}`;
|
|
39358
40130
|
for (const el of doc.querySelectorAll(`[${legacyAttr}="true"]`)) {
|
|
39359
|
-
if (isHtmlElement5(el) && !el.hasAttribute(
|
|
39360
|
-
el.setAttribute(
|
|
40131
|
+
if (isHtmlElement5(el) && !el.hasAttribute(attr2)) {
|
|
40132
|
+
el.setAttribute(attr2, "true");
|
|
39361
40133
|
el.removeAttribute(legacyAttr);
|
|
39362
40134
|
elements.push(el);
|
|
39363
40135
|
}
|
|
@@ -39395,9 +40167,9 @@ var STUDIO_EDIT_ATTRS = [
|
|
|
39395
40167
|
STUDIO_PATH_OFFSET_ATTR,
|
|
39396
40168
|
STUDIO_BOX_SIZE_ATTR,
|
|
39397
40169
|
STUDIO_ROTATION_ATTR
|
|
39398
|
-
].flatMap((
|
|
40170
|
+
].flatMap((attr2) => [attr2, `data-${attr2}`]).concat(STUDIO_MOTION_ATTR);
|
|
39399
40171
|
var STUDIO_EDIT_SELECTORS = STUDIO_EDIT_ATTRS.map(
|
|
39400
|
-
(
|
|
40172
|
+
(attr2) => attr2 === STUDIO_MOTION_ATTR ? `[${attr2}]` : `[${attr2}="true"]`
|
|
39401
40173
|
);
|
|
39402
40174
|
var editMarkCaches = /* @__PURE__ */ new WeakMap();
|
|
39403
40175
|
function scanForEditMarks(doc) {
|
|
@@ -39513,6 +40285,7 @@ function restoreStyleProperty(element, property, value) {
|
|
|
39513
40285
|
else element.style.removeProperty(property);
|
|
39514
40286
|
}
|
|
39515
40287
|
function restoreStudioBoxSize(element, previous) {
|
|
40288
|
+
endPreviewDraft(element, "restore");
|
|
39516
40289
|
forgetStudioBoxSizeDraftBase(element);
|
|
39517
40290
|
restoreStyleProperty(element, "width", previous.width);
|
|
39518
40291
|
restoreStyleProperty(element, "height", previous.height);
|
|
@@ -39565,6 +40338,10 @@ function restoreStudioRotation(element, previous) {
|
|
|
39565
40338
|
);
|
|
39566
40339
|
}
|
|
39567
40340
|
function restoreStudioPathOffset(element, previous) {
|
|
40341
|
+
endPreviewDraft(element, "restore");
|
|
40342
|
+
restoreStudioPathOffsetStyles(element, previous);
|
|
40343
|
+
}
|
|
40344
|
+
function restoreStudioPathOffsetStyles(element, previous) {
|
|
39568
40345
|
if (previous.translate) element.style.setProperty("translate", previous.translate);
|
|
39569
40346
|
else element.style.removeProperty("translate");
|
|
39570
40347
|
if (previous.x) element.style.setProperty(STUDIO_OFFSET_X_PROP, previous.x);
|
|
@@ -39879,189 +40656,6 @@ function installStudioManualEditSeekReapply(win, apply) {
|
|
|
39879
40656
|
return wrappedHfSeek || wrappedPlayerSeek || wrappedPlayerRenderSeek || wrappedTimelineSeek || wrappedPlayerPlay || wrappedTimelinePlay || wrappedPlayerPause || wrappedTimelinePause || wrappedNamedTimelineSeek || wrappedNamedTimelinePlay || wrappedNamedTimelinePause;
|
|
39880
40657
|
}
|
|
39881
40658
|
|
|
39882
|
-
// src/hooks/draggedGsapPosition.ts
|
|
39883
|
-
var cssValue = (style, prop) => {
|
|
39884
|
-
const value = style.getPropertyValue(prop).trim();
|
|
39885
|
-
return value === "none" ? "" : value;
|
|
39886
|
-
};
|
|
39887
|
-
function readCssRotation(element, withRotate = true) {
|
|
39888
|
-
const view = element.ownerDocument.defaultView;
|
|
39889
|
-
if (!view) return 0;
|
|
39890
|
-
const style = view.getComputedStyle(element);
|
|
39891
|
-
const rotate2 = withRotate ? cssValue(style, "rotate") : "";
|
|
39892
|
-
const scale = cssValue(style, "scale");
|
|
39893
|
-
const transform = cssValue(style, "transform");
|
|
39894
|
-
const angle = (list) => {
|
|
39895
|
-
if (!list) return 0;
|
|
39896
|
-
const m = new view.DOMMatrix(list);
|
|
39897
|
-
return Math.atan2(m.b, m.a) * 180 / Math.PI;
|
|
39898
|
-
};
|
|
39899
|
-
const folded = [rotate2 && `rotate(${rotate2})`, scale && `scale(${scale.split(/\s+/).join(",")})`];
|
|
39900
|
-
try {
|
|
39901
|
-
return angle([...folded, transform].join(" ").trim());
|
|
39902
|
-
} catch {
|
|
39903
|
-
return angle(transform);
|
|
39904
|
-
}
|
|
39905
|
-
}
|
|
39906
|
-
function readDragStamp(element) {
|
|
39907
|
-
const read2 = (name) => Number.parseFloat(element.getAttribute(name) ?? "");
|
|
39908
|
-
return {
|
|
39909
|
-
origX: read2("data-hf-drag-initial-offset-x") || 0,
|
|
39910
|
-
origY: read2("data-hf-drag-initial-offset-y") || 0,
|
|
39911
|
-
baseX: read2("data-hf-drag-gsap-base-x"),
|
|
39912
|
-
baseY: read2("data-hf-drag-gsap-base-y"),
|
|
39913
|
-
at: readEditMoment(element)
|
|
39914
|
-
};
|
|
39915
|
-
}
|
|
39916
|
-
function readEditMoment(element) {
|
|
39917
|
-
const raw = element.getAttribute(STUDIO_EDIT_MOMENT_ATTR);
|
|
39918
|
-
return raw ? JSON.parse(raw) : void 0;
|
|
39919
|
-
}
|
|
39920
|
-
var freezeDragStamp = (element) => ({
|
|
39921
|
-
...readDragStamp(element),
|
|
39922
|
-
frozen: true
|
|
39923
|
-
});
|
|
39924
|
-
function computeDraggedGsapPosition(element, studioOffset, fallbackBase, stamp = readDragStamp(element)) {
|
|
39925
|
-
const rotStyle = element.style.getPropertyValue("--hf-studio-rotation");
|
|
39926
|
-
const rotDeg = Number.parseFloat(rotStyle) || 0;
|
|
39927
|
-
const rad = -rotDeg * Math.PI / 180;
|
|
39928
|
-
const cos = Math.cos(rad);
|
|
39929
|
-
const sin = Math.sin(rad);
|
|
39930
|
-
const deltaX = studioOffset.x - stamp.origX;
|
|
39931
|
-
const deltaY = studioOffset.y - stamp.origY;
|
|
39932
|
-
const adjX = deltaX * cos - deltaY * sin;
|
|
39933
|
-
const adjY = deltaX * sin + deltaY * cos;
|
|
39934
|
-
const baseGsapX = Number.isFinite(stamp.baseX) ? stamp.baseX : fallbackBase.x;
|
|
39935
|
-
const baseGsapY = Number.isFinite(stamp.baseY) ? stamp.baseY : fallbackBase.y;
|
|
39936
|
-
return {
|
|
39937
|
-
newX: roundTo3(baseGsapX + adjX),
|
|
39938
|
-
newY: roundTo3(baseGsapY + adjY),
|
|
39939
|
-
baseGsapX,
|
|
39940
|
-
baseGsapY
|
|
39941
|
-
};
|
|
39942
|
-
}
|
|
39943
|
-
function restoreDragOffset(element, stamp = readDragStamp(element)) {
|
|
39944
|
-
if (stamp.frozen) return;
|
|
39945
|
-
element.style.setProperty("--hf-studio-offset-x", `${stamp.origX}px`);
|
|
39946
|
-
element.style.setProperty("--hf-studio-offset-y", `${stamp.origY}px`);
|
|
39947
|
-
element.removeAttribute("data-hf-drag-initial-offset-x");
|
|
39948
|
-
element.removeAttribute("data-hf-drag-initial-offset-y");
|
|
39949
|
-
}
|
|
39950
|
-
|
|
39951
|
-
// src/components/editor/plainTranslate.ts
|
|
39952
|
-
var TOKEN = /\s*(?:(\d*\.?\d+(?:e[-+]?\d+)?)(px|%)?|([a-z]+)\(|([-+*/(),]))/giy;
|
|
39953
|
-
var FUNCTIONS = {
|
|
39954
|
-
"(": ([a = Number.NaN]) => a,
|
|
39955
|
-
"calc(": ([a = Number.NaN]) => a,
|
|
39956
|
-
"min(": (args) => Math.min(...args),
|
|
39957
|
-
"max(": (args) => Math.max(...args),
|
|
39958
|
-
"clamp(": ([lo = Number.NaN, v = Number.NaN, hi = Number.NaN]) => Math.max(lo, Math.min(v, hi))
|
|
39959
|
-
};
|
|
39960
|
-
function tokenize(value, side) {
|
|
39961
|
-
const tokens = [];
|
|
39962
|
-
const end = value.trimEnd().length;
|
|
39963
|
-
TOKEN.lastIndex = 0;
|
|
39964
|
-
for (let m = TOKEN.exec(value); m; m = TOKEN.lastIndex < end ? TOKEN.exec(value) : null) {
|
|
39965
|
-
if (m[1]) tokens.push(Number(m[1]) * (m[2] === "%" ? side / 100 : 1));
|
|
39966
|
-
else tokens.push(m[3] ? `${m[3].toLowerCase()}(` : m[4] ?? "");
|
|
39967
|
-
}
|
|
39968
|
-
return TOKEN.lastIndex < end ? [] : tokens;
|
|
39969
|
-
}
|
|
39970
|
-
function evaluateLength(value, side) {
|
|
39971
|
-
const tokens = tokenize(value, side);
|
|
39972
|
-
let i = 0;
|
|
39973
|
-
const next = () => tokens[i++];
|
|
39974
|
-
const take = (...ops) => ops.includes(tokens[i]) && next();
|
|
39975
|
-
function sum() {
|
|
39976
|
-
let total2 = product();
|
|
39977
|
-
for (let op = take("+", "-"); op; op = take("+", "-"))
|
|
39978
|
-
total2 += (op === "+" ? 1 : -1) * product();
|
|
39979
|
-
return total2;
|
|
39980
|
-
}
|
|
39981
|
-
function product() {
|
|
39982
|
-
let total2 = unary();
|
|
39983
|
-
for (let op = take("*", "/"); op; op = take("*", "/"))
|
|
39984
|
-
total2 = op === "*" ? total2 * unary() : total2 / unary();
|
|
39985
|
-
return total2;
|
|
39986
|
-
}
|
|
39987
|
-
function unary() {
|
|
39988
|
-
return take("-") ? -unary() : atom();
|
|
39989
|
-
}
|
|
39990
|
-
function atom() {
|
|
39991
|
-
const token = next();
|
|
39992
|
-
if (typeof token === "number") return token;
|
|
39993
|
-
const fn = FUNCTIONS[token ?? ""];
|
|
39994
|
-
if (!fn) return Number.NaN;
|
|
39995
|
-
const args = [sum()];
|
|
39996
|
-
while (take(",")) args.push(sum());
|
|
39997
|
-
return take(")") ? fn(args) : Number.NaN;
|
|
39998
|
-
}
|
|
39999
|
-
const total = tokens.length ? sum() : Number.NaN;
|
|
40000
|
-
return i === tokens.length ? total : Number.NaN;
|
|
40001
|
-
}
|
|
40002
|
-
var CONTENT_BOXES = /* @__PURE__ */ new Set(["content-box", "fill-box"]);
|
|
40003
|
-
function referenceBox(cs, size, a, b) {
|
|
40004
|
-
const n = (prop) => Number.parseFloat(cs.getPropertyValue(prop)) || 0;
|
|
40005
|
-
const pad2 = n(`padding-${a}`) + n(`padding-${b}`) + n(`border-${a}-width`) + n(`border-${b}-width`);
|
|
40006
|
-
const content = n(size) - (cs.boxSizing === "border-box" ? pad2 : 0);
|
|
40007
|
-
return CONTENT_BOXES.has(cs.getPropertyValue("transform-box")) ? content : content + pad2;
|
|
40008
|
-
}
|
|
40009
|
-
function readTranslatePx(el) {
|
|
40010
|
-
const cs = el.ownerDocument.defaultView?.getComputedStyle(el);
|
|
40011
|
-
const value = cs?.translate || el.style.getPropertyValue("translate") || "none";
|
|
40012
|
-
if (value === "none") return { x: 0, y: 0 };
|
|
40013
|
-
const [x = "0px", y = "0px"] = splitTopLevelWhitespace(value);
|
|
40014
|
-
const side = (size, a, b) => cs ? referenceBox(cs, size, a, b) : 0;
|
|
40015
|
-
return {
|
|
40016
|
-
x: evaluateLength(x, side("width", "left", "right")),
|
|
40017
|
-
y: evaluateLength(y, side("height", "top", "bottom"))
|
|
40018
|
-
};
|
|
40019
|
-
}
|
|
40020
|
-
function readTranslatePxLeavingPercent(el) {
|
|
40021
|
-
const value = el.ownerDocument.defaultView?.getComputedStyle(el).translate || "none";
|
|
40022
|
-
const [x = "0px", y = "0px"] = value === "none" ? [] : splitTopLevelWhitespace(value);
|
|
40023
|
-
const px = (part) => roundTo3(evaluateLength(part, 0)) || 0;
|
|
40024
|
-
return { x: px(x), y: px(y) };
|
|
40025
|
-
}
|
|
40026
|
-
var UNREADABLE_TRANSLATE = "Studio can't read this layer's translate. Move it in the Code tab.";
|
|
40027
|
-
function formatTranslatePx(p) {
|
|
40028
|
-
return `${roundTo3(p.x)}px ${roundTo3(p.y)}px`;
|
|
40029
|
-
}
|
|
40030
|
-
var LEGACY_OFFSET_VARS = [STUDIO_OFFSET_X_PROP, STUDIO_OFFSET_Y_PROP];
|
|
40031
|
-
function writePlainMove(el, p) {
|
|
40032
|
-
writeTranslatePx(el, p);
|
|
40033
|
-
const patches = [
|
|
40034
|
-
{ type: "inline-style", property: "translate", value: formatTranslatePx(p) },
|
|
40035
|
-
{
|
|
40036
|
-
type: "attribute",
|
|
40037
|
-
property: STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR,
|
|
40038
|
-
value: el.getAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR)
|
|
40039
|
-
}
|
|
40040
|
-
];
|
|
40041
|
-
for (const prop of LEGACY_OFFSET_VARS.filter((v) => el.style.getPropertyValue(v))) {
|
|
40042
|
-
el.style.removeProperty(prop);
|
|
40043
|
-
patches.push({ type: "inline-style", property: prop, value: null });
|
|
40044
|
-
}
|
|
40045
|
-
if (el.hasAttribute(STUDIO_PATH_OFFSET_ATTR)) {
|
|
40046
|
-
el.removeAttribute(STUDIO_PATH_OFFSET_ATTR);
|
|
40047
|
-
patches.push({ type: "attribute", property: STUDIO_PATH_OFFSET_ATTR, value: null });
|
|
40048
|
-
}
|
|
40049
|
-
return patches;
|
|
40050
|
-
}
|
|
40051
|
-
function writeTranslatePx(el, p) {
|
|
40052
|
-
if (!el.hasAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR)) {
|
|
40053
|
-
const own = el.style.getPropertyValue("translate");
|
|
40054
|
-
el.setAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR, styleUsesStudioOffset(own) ? "" : own);
|
|
40055
|
-
}
|
|
40056
|
-
el.style.setProperty("translate", formatTranslatePx(p));
|
|
40057
|
-
}
|
|
40058
|
-
function readMoveOffset(el, plainTranslate = editsPlainCss(el, "move")) {
|
|
40059
|
-
return plainTranslate ? readTranslatePx(el) : readStudioPathOffset(el);
|
|
40060
|
-
}
|
|
40061
|
-
function readShownRotation(el) {
|
|
40062
|
-
return editsPlainCss(el, "rotate") ? { angle: roundTo3(readCssRotation(el)) } : readStudioRotation(el);
|
|
40063
|
-
}
|
|
40064
|
-
|
|
40065
40659
|
// src/components/editor/manualOffsetDrag.ts
|
|
40066
40660
|
function getOffsetDragGsap(element) {
|
|
40067
40661
|
const win = element.ownerDocument.defaultView;
|
|
@@ -40207,7 +40801,7 @@ function measureManualOffsetDragScreenToOffsetMatrix(element, initialOffset, opt
|
|
|
40207
40801
|
}
|
|
40208
40802
|
return { ok: true, matrix: screenToOffset };
|
|
40209
40803
|
} finally {
|
|
40210
|
-
|
|
40804
|
+
restoreStudioPathOffsetStyles(element, snapshot3);
|
|
40211
40805
|
}
|
|
40212
40806
|
}
|
|
40213
40807
|
function resolveManualOffsetForPointerDelta(input) {
|
|
@@ -40256,6 +40850,7 @@ function createManualOffsetDragMember(input) {
|
|
|
40256
40850
|
scaleY: input.rect.editScaleY,
|
|
40257
40851
|
plainTranslate
|
|
40258
40852
|
});
|
|
40853
|
+
endPreviewDraft(input.element, "keep");
|
|
40259
40854
|
if (!measured.ok) {
|
|
40260
40855
|
const scaleX = input.rect.editScaleX || 1;
|
|
40261
40856
|
const scaleY = input.rect.editScaleY || 1;
|
|
@@ -40301,6 +40896,8 @@ function resolveManualOffsetDragMemberOffset(member, dx, dy) {
|
|
|
40301
40896
|
});
|
|
40302
40897
|
}
|
|
40303
40898
|
function drawMemberOffset(member, offset, commit2) {
|
|
40899
|
+
const { x, y } = member.initialOffset;
|
|
40900
|
+
drawPreviewDraft(member.element, { translate: { x: offset.x - x, y: offset.y - y } });
|
|
40304
40901
|
if (member.plainTranslate) writeTranslatePx(member.element, offset);
|
|
40305
40902
|
else if (applyOffsetDragDraftViaGsap(member.element, offset, member.baseGsap)) return;
|
|
40306
40903
|
else if (commit2) applyStudioPathOffset(member.element, offset);
|
|
@@ -40366,6 +40963,7 @@ function endManualOffsetDragMembers(members) {
|
|
|
40366
40963
|
for (const member of members) {
|
|
40367
40964
|
if (!isStudioManualEditGestureCurrent(member.element, member.gestureToken)) continue;
|
|
40368
40965
|
endStudioManualEditGesture(member.element, member.gestureToken);
|
|
40966
|
+
endPreviewDraft(member.element, "keep");
|
|
40369
40967
|
member.element.removeAttribute("data-hf-drag-initial-offset-x");
|
|
40370
40968
|
member.element.removeAttribute("data-hf-drag-initial-offset-y");
|
|
40371
40969
|
member.element.removeAttribute("data-hf-drag-gsap-base-x");
|
|
@@ -40419,6 +41017,13 @@ function showMemberPosition(member, position) {
|
|
|
40419
41017
|
if (!member.plainTranslate)
|
|
40420
41018
|
stampGestureBase(member.element, member.initialOffset, member.baseGsap);
|
|
40421
41019
|
}
|
|
41020
|
+
function redrawMemberOnFrame(member) {
|
|
41021
|
+
const { element, initialOffset } = member;
|
|
41022
|
+
const offset = member.plainTranslate ? readTranslatePx(element) : readAppliedStudioPathOffset(element);
|
|
41023
|
+
const translate = { x: offset.x - initialOffset.x, y: offset.y - initialOffset.y };
|
|
41024
|
+
if (Number.isFinite(translate.x) && Number.isFinite(translate.y) && (translate.x || translate.y))
|
|
41025
|
+
drawPreviewDraft(element, { translate });
|
|
41026
|
+
}
|
|
40422
41027
|
function manualOffsetMoveRevert(members) {
|
|
40423
41028
|
const startPlacement = members.map((member) => placementOf(member.element));
|
|
40424
41029
|
return () => {
|
|
@@ -40430,7 +41035,10 @@ function manualOffsetMoveRevert(members) {
|
|
|
40430
41035
|
placement: startPlacement[i]
|
|
40431
41036
|
})
|
|
40432
41037
|
);
|
|
40433
|
-
return () => members.forEach((member, i) =>
|
|
41038
|
+
return () => members.forEach((member, i) => {
|
|
41039
|
+
showMemberPosition(member, shown3[i]);
|
|
41040
|
+
redrawMemberOnFrame(member);
|
|
41041
|
+
});
|
|
40434
41042
|
};
|
|
40435
41043
|
}
|
|
40436
41044
|
var GSAP_LOOK_PROPS = ["x", "y", "rotation", "scaleX", "scaleY"];
|
|
@@ -41345,7 +41953,22 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41345
41953
|
});
|
|
41346
41954
|
};
|
|
41347
41955
|
};
|
|
41348
|
-
const
|
|
41956
|
+
const shownOverChannel = async (iframe, selections) => {
|
|
41957
|
+
const overlay = opts.overlayRef.current;
|
|
41958
|
+
const path = opts.activeCompositionPathRef.current;
|
|
41959
|
+
const found = await Promise.all(
|
|
41960
|
+
selections.map((selection) => findPreviewElementForSelection(iframe, selection, path))
|
|
41961
|
+
);
|
|
41962
|
+
const handles = found.map((element) => element?.handle);
|
|
41963
|
+
if (!overlay || !handles.length || !handles.every(Boolean)) return null;
|
|
41964
|
+
const rects = await measurePreviewRects(iframe, overlay, handles);
|
|
41965
|
+
const shown3 = selections.flatMap((selection, i) => {
|
|
41966
|
+
const rect = rects?.[i];
|
|
41967
|
+
return rect ? [{ selection: { ...selection, handle: handles[i] }, rect }] : [];
|
|
41968
|
+
});
|
|
41969
|
+
return shown3.length === selections.length ? shown3 : null;
|
|
41970
|
+
};
|
|
41971
|
+
const startOnShownPreview = (e, pressed, start, draw = null, targets = () => []) => {
|
|
41349
41972
|
const at = playheadMoment();
|
|
41350
41973
|
if (!isPreviewChanging() && !opts.waitingPressRef.current) return start(e, at, false);
|
|
41351
41974
|
e.preventDefault();
|
|
@@ -41382,8 +42005,24 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41382
42005
|
settledFrames = settled ? settledFrames + 1 : 0;
|
|
41383
42006
|
return elements.length;
|
|
41384
42007
|
};
|
|
42008
|
+
const iframe = opts.iframeRef.current;
|
|
42009
|
+
const channel = iframe && previewFrameOpaque(iframe) ? iframe : null;
|
|
42010
|
+
let overChannel;
|
|
42011
|
+
let asked = false;
|
|
42012
|
+
const channelStep = (frame3) => {
|
|
42013
|
+
const overdue = performance.now() - since > PRESS_WAIT_MAX_MS;
|
|
42014
|
+
if (overdue) giveUpOnPreviewChange();
|
|
42015
|
+
if (isPreviewChanging() && !overdue) return "wait";
|
|
42016
|
+
if (!asked) {
|
|
42017
|
+
asked = true;
|
|
42018
|
+
void shownOverChannel(frame3, targets()).then((shown3) => overChannel = shown3);
|
|
42019
|
+
}
|
|
42020
|
+
if (overChannel === void 0) return "wait";
|
|
42021
|
+
return overChannel ? "run" : "lost";
|
|
42022
|
+
};
|
|
41385
42023
|
const waitStep = () => {
|
|
41386
42024
|
if (press.after && !press.after.ended) return "wait";
|
|
42025
|
+
if (channel) return channelStep(channel);
|
|
41387
42026
|
const found = countFrame();
|
|
41388
42027
|
const overdue = performance.now() - since > PRESS_WAIT_MAX_MS;
|
|
41389
42028
|
if (overdue) giveUpOnPreviewChange();
|
|
@@ -41398,8 +42037,8 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41398
42037
|
return;
|
|
41399
42038
|
}
|
|
41400
42039
|
endWaitingPress(press);
|
|
41401
|
-
|
|
41402
|
-
|
|
42040
|
+
const pointerDown = down;
|
|
42041
|
+
if (step === "lost" || !start(pointerDown, at, true, overChannel ?? void 0)) return;
|
|
41403
42042
|
if (press.moved) moveActiveGesture(press.moved);
|
|
41404
42043
|
if (press.released) releaseActiveGesture(press.released);
|
|
41405
42044
|
};
|
|
@@ -41417,6 +42056,11 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41417
42056
|
const iframe = opts.iframeRef.current;
|
|
41418
42057
|
return overlay && iframe && orientedGroupAwareOverlayRect(overlay, iframe, element);
|
|
41419
42058
|
};
|
|
42059
|
+
const shownOnPage = (target) => {
|
|
42060
|
+
const selection = target && shownSelection(target);
|
|
42061
|
+
const rect = selection && shownRect(selection.element);
|
|
42062
|
+
return selection && rect ? { selection, rect } : null;
|
|
42063
|
+
};
|
|
41420
42064
|
const startGroupDrag2 = (e) => {
|
|
41421
42065
|
const items = opts.groupOverlayItemsRef.current;
|
|
41422
42066
|
return startOnShownPreview(
|
|
@@ -41425,8 +42069,16 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41425
42069
|
const selection = shownSelection(item.selection);
|
|
41426
42070
|
return selection ? [selection.element] : [];
|
|
41427
42071
|
}),
|
|
41428
|
-
(pressed, at, waited) => {
|
|
42072
|
+
(pressed, at, waited, overChannel) => {
|
|
41429
42073
|
if (!waited) return startGroupDrag(pressed, opts, at);
|
|
42074
|
+
if (overChannel) {
|
|
42075
|
+
const measured2 = items.map((item, i) => ({ ...item, ...overChannel[i] }));
|
|
42076
|
+
return startGroupDrag(
|
|
42077
|
+
pressed,
|
|
42078
|
+
{ ...opts, groupOverlayItemsRef: { current: measured2 } },
|
|
42079
|
+
at
|
|
42080
|
+
);
|
|
42081
|
+
}
|
|
41430
42082
|
const overlay = opts.overlayRef.current;
|
|
41431
42083
|
const iframe = opts.iframeRef.current;
|
|
41432
42084
|
if (!overlay || !iframe) return false;
|
|
@@ -41445,7 +42097,8 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41445
42097
|
},
|
|
41446
42098
|
(dx, dy) => opts.setGroupOverlayItems(
|
|
41447
42099
|
items.map((item) => ({ ...item, rect: shiftedOverlayRect(item.rect, dx, dy) }))
|
|
41448
|
-
)
|
|
42100
|
+
),
|
|
42101
|
+
() => items.map((item) => item.selection)
|
|
41449
42102
|
);
|
|
41450
42103
|
};
|
|
41451
42104
|
const startGesture2 = (kind, e, options) => {
|
|
@@ -41463,19 +42116,19 @@ function createPreviewGestureStarts(opts, moveActiveGesture, releaseActiveGestur
|
|
|
41463
42116
|
const shown3 = target && shownSelection(target);
|
|
41464
42117
|
return shown3 ? [shown3.element] : [];
|
|
41465
42118
|
},
|
|
41466
|
-
(pressed, at, waited) => {
|
|
42119
|
+
(pressed, at, waited, overChannel) => {
|
|
41467
42120
|
if (!waited) return startGesture(kind, pressed, opts, { ...options, at });
|
|
41468
|
-
const
|
|
41469
|
-
|
|
41470
|
-
|
|
41471
|
-
|
|
41472
|
-
rect,
|
|
42121
|
+
const shown3 = overChannel ? overChannel[0] : shownOnPage(target);
|
|
42122
|
+
return !!shown3 && startGesture(kind, pressed, opts, {
|
|
42123
|
+
selection: shown3.selection,
|
|
42124
|
+
rect: shown3.rect,
|
|
41473
42125
|
resizeHandle: options?.resizeHandle,
|
|
41474
42126
|
resizeCorner: options?.resizeCorner,
|
|
41475
42127
|
at
|
|
41476
42128
|
});
|
|
41477
42129
|
},
|
|
41478
|
-
draw
|
|
42130
|
+
draw,
|
|
42131
|
+
() => target ? [target] : []
|
|
41479
42132
|
);
|
|
41480
42133
|
};
|
|
41481
42134
|
return { startGesture: startGesture2, startGroupDrag: startGroupDrag2, endWaitingPress, endHeldPress, releaseWaitingPress };
|
|
@@ -41514,7 +42167,34 @@ function resolveAnchoredResizeDraft(g, member, element, overlayEl, iframe, measu
|
|
|
41514
42167
|
angle: g.actualRotation
|
|
41515
42168
|
};
|
|
41516
42169
|
}
|
|
42170
|
+
function resolveUnmeasuredResizeDraft(g, element, { written }) {
|
|
42171
|
+
const width = g.originWidth * written.width / g.actualWidth;
|
|
42172
|
+
const height = g.originHeight * written.height / g.actualHeight;
|
|
42173
|
+
if (g.pathOffsetMember) {
|
|
42174
|
+
const anchor2 = {
|
|
42175
|
+
dx: (g.actualWidth - written.width) / 2 * g.editScaleX,
|
|
42176
|
+
dy: (g.actualHeight - written.height) / 2 * g.editScaleY
|
|
42177
|
+
};
|
|
42178
|
+
g.lastResizeAnchor = anchor2;
|
|
42179
|
+
applyManualOffsetDragDraft(g.pathOffsetMember, anchor2.dx, anchor2.dy);
|
|
42180
|
+
}
|
|
42181
|
+
drawPreviewDraft(element, { size: written });
|
|
42182
|
+
return {
|
|
42183
|
+
left: g.originLeft + (g.originWidth - width) / 2,
|
|
42184
|
+
top: g.originTop + (g.originHeight - height) / 2,
|
|
42185
|
+
width,
|
|
42186
|
+
height,
|
|
42187
|
+
editScaleX: g.editScaleX,
|
|
42188
|
+
editScaleY: g.editScaleY,
|
|
42189
|
+
angle: g.actualRotation
|
|
42190
|
+
};
|
|
42191
|
+
}
|
|
42192
|
+
function endResizeWithoutMember(element, token) {
|
|
42193
|
+
if (!token || isStudioManualEditGestureCurrent(element, token)) endPreviewDraft(element, "keep");
|
|
42194
|
+
endStudioManualEditGesture(element, token);
|
|
42195
|
+
}
|
|
41517
42196
|
function resolveResizeDraftRect(g, element, overlayEl, iframe, measureOrientedRect, sizes) {
|
|
42197
|
+
if (iframe && previewFrameOpaque(iframe)) return resolveUnmeasuredResizeDraft(g, element, sizes);
|
|
41518
42198
|
if (g.pathOffsetMember) {
|
|
41519
42199
|
return resolveAnchoredResizeDraft(
|
|
41520
42200
|
g,
|
|
@@ -42085,7 +42765,7 @@ function createDomEditOverlayGestureHandlers(opts) {
|
|
|
42085
42765
|
logGestureCommitFailure("resize commit failed", error);
|
|
42086
42766
|
}).finally(() => {
|
|
42087
42767
|
if (member) endManualOffsetDragMembers([member]);
|
|
42088
|
-
else
|
|
42768
|
+
else endResizeWithoutMember(sel.element, g.manualEditDragToken);
|
|
42089
42769
|
});
|
|
42090
42770
|
edit.settle(saved2);
|
|
42091
42771
|
logResizeSettle(sel.element, "post-release");
|
|
@@ -44243,7 +44923,7 @@ function placeCaretAtEnd(element) {
|
|
|
44243
44923
|
}
|
|
44244
44924
|
|
|
44245
44925
|
// src/components/editor/domEditInlineText.ts
|
|
44246
|
-
import {
|
|
44926
|
+
import { hasOnlyFormattingChildren } from "@hyperframes/core/runtime/editing-port";
|
|
44247
44927
|
function canEditTextInline(selection) {
|
|
44248
44928
|
if (!selection) return false;
|
|
44249
44929
|
if (!isTextEditableSelection(selection)) return false;
|
|
@@ -44260,17 +44940,6 @@ function canEditElementTextInline(element) {
|
|
|
44260
44940
|
if (element.isContentEditable) return false;
|
|
44261
44941
|
return (element.textContent ?? "").trim().length > 0;
|
|
44262
44942
|
}
|
|
44263
|
-
function hasOnlyFormattingChildren(element) {
|
|
44264
|
-
for (const child of Array.from(element.children)) {
|
|
44265
|
-
if (!isRichTextFormattingTag2(child.tagName)) return false;
|
|
44266
|
-
if (!isHtmlFromAnyWindow(child)) return false;
|
|
44267
|
-
if (!hasOnlyFormattingChildren(child)) return false;
|
|
44268
|
-
}
|
|
44269
|
-
return true;
|
|
44270
|
-
}
|
|
44271
|
-
function isHtmlFromAnyWindow(node) {
|
|
44272
|
-
return node.namespaceURI === "http://www.w3.org/1999/xhtml";
|
|
44273
|
-
}
|
|
44274
44943
|
var DOUBLE_PRESS_MS = 450;
|
|
44275
44944
|
var DOUBLE_PRESS_SLOP_PX = 6;
|
|
44276
44945
|
function isDoublePress(previous, next) {
|
|
@@ -44290,14 +44959,9 @@ function useInlineTextEditing(selectionRef, { enterFromWindow = false } = {}) {
|
|
|
44290
44959
|
const elementUnderPress = (event) => {
|
|
44291
44960
|
const iframe = actions?.previewIframeRef?.current;
|
|
44292
44961
|
if (!iframe) return null;
|
|
44293
|
-
return getPreviewTargetFromPointer(
|
|
44294
|
-
iframe,
|
|
44295
|
-
event.clientX,
|
|
44296
|
-
event.clientY,
|
|
44297
|
-
selectionRef.current?.compositionPath ?? null
|
|
44298
|
-
);
|
|
44962
|
+
return getPreviewTargetFromPointer(iframe, event.clientX, event.clientY);
|
|
44299
44963
|
};
|
|
44300
|
-
const
|
|
44964
|
+
const compositionPoint2 = (event) => {
|
|
44301
44965
|
const iframe = actions?.previewIframeRef?.current;
|
|
44302
44966
|
const view = iframe?.contentWindow;
|
|
44303
44967
|
if (!iframe || !view?.innerWidth) return void 0;
|
|
@@ -44352,7 +45016,7 @@ function useInlineTextEditing(selectionRef, { enterFromWindow = false } = {}) {
|
|
|
44352
45016
|
lastPressRef.current = press;
|
|
44353
45017
|
if (!paired) return false;
|
|
44354
45018
|
if (!element || !canEditElementTextInline(element)) return false;
|
|
44355
|
-
return inlineText.start(element,
|
|
45019
|
+
return inlineText.start(element, compositionPoint2(event));
|
|
44356
45020
|
}
|
|
44357
45021
|
};
|
|
44358
45022
|
}
|
|
@@ -44916,12 +45580,7 @@ var DomEditOverlay = memo30(function DomEditOverlay2({
|
|
|
44916
45580
|
const shiftIframe = iframeRef.current;
|
|
44917
45581
|
const candidate = resolveShiftClickCandidate({
|
|
44918
45582
|
cached: hoverSelectionRef.current,
|
|
44919
|
-
elementAtPoint: shiftIframe ? getPreviewTargetFromPointer(
|
|
44920
|
-
shiftIframe,
|
|
44921
|
-
event.clientX,
|
|
44922
|
-
event.clientY,
|
|
44923
|
-
activeCompositionPathRef.current
|
|
44924
|
-
) : null
|
|
45583
|
+
elementAtPoint: shiftIframe ? getPreviewTargetFromPointer(shiftIframe, event.clientX, event.clientY) : null
|
|
44925
45584
|
});
|
|
44926
45585
|
if (!candidate) return;
|
|
44927
45586
|
event.preventDefault();
|
|
@@ -44939,13 +45598,7 @@ var DomEditOverlay = memo30(function DomEditOverlay2({
|
|
|
44939
45598
|
if (target?.closest('[data-dom-edit-selection-box="true"]')) return;
|
|
44940
45599
|
if (!hoverSelectionRef.current && onMarqueeSelectRef.current && compRect.width > 0) {
|
|
44941
45600
|
const iframe = iframeRef.current;
|
|
44942
|
-
|
|
44943
|
-
iframe,
|
|
44944
|
-
event.clientX,
|
|
44945
|
-
event.clientY,
|
|
44946
|
-
activeCompositionPathRef.current
|
|
44947
|
-
) : null;
|
|
44948
|
-
if (freshTarget) return;
|
|
45601
|
+
if (iframe && pointerMayHitElement(iframe, event.clientX, event.clientY)) return;
|
|
44949
45602
|
if (overlayRef.current) {
|
|
44950
45603
|
event.preventDefault();
|
|
44951
45604
|
event.stopPropagation();
|
|
@@ -51938,9 +52591,14 @@ function useTimelineSelectionPreviewSync({
|
|
|
51938
52591
|
const currentDomEditGroupSelections = domEditGroupSelectionsRef.current;
|
|
51939
52592
|
const currentSelections = currentDomEditGroupSelections.length > 1 ? currentDomEditGroupSelections : currentDomEditSelection ? [currentDomEditSelection] : [];
|
|
51940
52593
|
const currentIds = currentSelections.map(
|
|
51941
|
-
(selection) => resolveTimelineIdForSelection(selection, timelineElements, activeCompPath)
|
|
52594
|
+
(selection) => resolveTimelineIdForSelection(selection, timelineElements, activeCompPath, true)
|
|
51942
52595
|
).filter((id) => Boolean(id));
|
|
51943
|
-
const currentAnchor = currentDomEditSelection ? resolveTimelineIdForSelection(
|
|
52596
|
+
const currentAnchor = currentDomEditSelection ? resolveTimelineIdForSelection(
|
|
52597
|
+
currentDomEditSelection,
|
|
52598
|
+
timelineElements,
|
|
52599
|
+
activeCompPath,
|
|
52600
|
+
true
|
|
52601
|
+
) : null;
|
|
51944
52602
|
if (selectedIds.length === 0) {
|
|
51945
52603
|
missingSelectionKeyRef.current = "";
|
|
51946
52604
|
unresolvedAttemptsRef.current = { id: "", count: 0 };
|
|
@@ -56403,7 +57061,7 @@ import {
|
|
|
56403
57061
|
|
|
56404
57062
|
// src/components/editor/linkedSpeedEdits.ts
|
|
56405
57063
|
var keyOf14 = (el) => el.key ?? el.id;
|
|
56406
|
-
var dataProperty = (
|
|
57064
|
+
var dataProperty = (attr2) => attr2.startsWith("data-") ? attr2.slice(5) : attr2;
|
|
56407
57065
|
function isSelected(el, selection) {
|
|
56408
57066
|
if (selection.hfId && el.hfId) return el.hfId === selection.hfId;
|
|
56409
57067
|
return selection.id != null && (el.domId ?? el.id) === selection.id;
|
|
@@ -56415,13 +57073,13 @@ function linkedPartnerTargets(selection, elements) {
|
|
|
56415
57073
|
members.delete(keyOf14(self));
|
|
56416
57074
|
return elements.filter((el) => members.has(keyOf14(el))).map(buildPatchTarget).filter((target) => target !== null);
|
|
56417
57075
|
}
|
|
56418
|
-
function fanOutAttributeInSource(source, targets,
|
|
56419
|
-
const property = dataProperty(
|
|
57076
|
+
function fanOutAttributeInSource(source, targets, attr2, valueFor) {
|
|
57077
|
+
const property = dataProperty(attr2);
|
|
56420
57078
|
return targets.reduce(
|
|
56421
57079
|
(html2, target) => applyPatchByTarget(html2, target, {
|
|
56422
57080
|
type: "attribute",
|
|
56423
57081
|
property,
|
|
56424
|
-
value: valueFor(readAttributeByTarget(html2, target,
|
|
57082
|
+
value: valueFor(readAttributeByTarget(html2, target, attr2))
|
|
56425
57083
|
}),
|
|
56426
57084
|
source
|
|
56427
57085
|
);
|
|
@@ -56432,14 +57090,14 @@ function useLinkedSpeedCommit(selection, commit2) {
|
|
|
56432
57090
|
const partners = linkedPartnerTargets(selection, elements);
|
|
56433
57091
|
if (partners.length === 0) return null;
|
|
56434
57092
|
return {
|
|
56435
|
-
commitAttribute: (
|
|
56436
|
-
const property = dataProperty(
|
|
57093
|
+
commitAttribute: (attr2, valueFor, label) => {
|
|
57094
|
+
const property = dataProperty(attr2);
|
|
56437
57095
|
return commit2(
|
|
56438
57096
|
selection,
|
|
56439
57097
|
[{ type: "attribute", property, value: valueFor(selection.dataAttributes[property]) }],
|
|
56440
57098
|
{
|
|
56441
57099
|
label,
|
|
56442
|
-
prepareContent: (html2) => fanOutAttributeInSource(html2, partners,
|
|
57100
|
+
prepareContent: (html2) => fanOutAttributeInSource(html2, partners, attr2, valueFor)
|
|
56443
57101
|
}
|
|
56444
57102
|
);
|
|
56445
57103
|
}
|
|
@@ -56447,8 +57105,8 @@ function useLinkedSpeedCommit(selection, commit2) {
|
|
|
56447
57105
|
}
|
|
56448
57106
|
function withLinkedPlaybackRate(onSetAttribute, linked) {
|
|
56449
57107
|
if (!linked) return onSetAttribute;
|
|
56450
|
-
return async (
|
|
56451
|
-
if (
|
|
57108
|
+
return async (attr2, value) => {
|
|
57109
|
+
if (attr2 !== "playback-rate") return onSetAttribute(attr2, value);
|
|
56452
57110
|
await linked.commitAttribute("data-playback-rate", () => value, "Edit speed");
|
|
56453
57111
|
};
|
|
56454
57112
|
}
|
|
@@ -56481,7 +57139,7 @@ function MediaSection({
|
|
|
56481
57139
|
const { mediaStart, mediaStartAttr } = readClipInPoint(element.dataAttributes);
|
|
56482
57140
|
const hasLoop = el.hasAttribute("loop");
|
|
56483
57141
|
const hasMuted = el.hasAttribute("muted");
|
|
56484
|
-
const
|
|
57142
|
+
const hasAudio2 = isVideoAudible({
|
|
56485
57143
|
tag: el.tagName,
|
|
56486
57144
|
hasAudioAttr: element.dataAttributes["has-audio"],
|
|
56487
57145
|
muted: el.hasAttribute("muted")
|
|
@@ -56517,7 +57175,7 @@ function MediaSection({
|
|
|
56517
57175
|
quality,
|
|
56518
57176
|
onProgress: setRemoveProgress
|
|
56519
57177
|
});
|
|
56520
|
-
const stage = await commitCutout(mediaEdit, result.outputPath,
|
|
57178
|
+
const stage = await commitCutout(mediaEdit, result.outputPath, hasAudio2);
|
|
56521
57179
|
setRemoveProgress({ status: "complete", progress: 100, stage, ...result });
|
|
56522
57180
|
} catch (error) {
|
|
56523
57181
|
setRemoveProgress({
|
|
@@ -56738,7 +57396,7 @@ function MediaSection({
|
|
|
56738
57396
|
SegmentedControl,
|
|
56739
57397
|
{
|
|
56740
57398
|
trackName: "Has audio track",
|
|
56741
|
-
value:
|
|
57399
|
+
value: hasAudio2 ? "yes" : "no",
|
|
56742
57400
|
onChange: (next) => void commitHasAudioToggle(mediaEdit, next === "yes"),
|
|
56743
57401
|
options: [
|
|
56744
57402
|
{ label: "Yes", value: "yes" },
|
|
@@ -60351,7 +61009,7 @@ function ImageFillField({
|
|
|
60351
61009
|
const track2 = useTrackDesignInput();
|
|
60352
61010
|
const sourceFile = element.sourceFile;
|
|
60353
61011
|
const isImage = element.tagName === "img";
|
|
60354
|
-
const imageUrl = isImage ? element
|
|
61012
|
+
const imageUrl = isImage ? selectionSrc(element) ?? "" : value;
|
|
60355
61013
|
const commitImage = (next, projectAsset = false) => {
|
|
60356
61014
|
if (isImage) {
|
|
60357
61015
|
if (next)
|
|
@@ -60751,6 +61409,9 @@ function GradientField({
|
|
|
60751
61409
|
] })
|
|
60752
61410
|
] });
|
|
60753
61411
|
}
|
|
61412
|
+
function selectionSrc(selection) {
|
|
61413
|
+
return selection.src === void 0 ? selection.element.getAttribute("src") : selection.src;
|
|
61414
|
+
}
|
|
60754
61415
|
|
|
60755
61416
|
// src/components/editor/BorderRadiusEditor.tsx
|
|
60756
61417
|
import { useCallback as useCallback88, useState as useState81 } from "react";
|
|
@@ -62993,7 +63654,7 @@ function rotate(v, rx, ry, rz) {
|
|
|
62993
63654
|
[x, y] = [x * cz - y * sz, x * sz + y * cz];
|
|
62994
63655
|
return { x, y, z };
|
|
62995
63656
|
}
|
|
62996
|
-
var
|
|
63657
|
+
var CORNERS2 = [
|
|
62997
63658
|
{ x: -1, y: -1, z: -1 },
|
|
62998
63659
|
{ x: 1, y: -1, z: -1 },
|
|
62999
63660
|
{ x: 1, y: 1, z: -1 },
|
|
@@ -63024,7 +63685,7 @@ function projectCubeFaces(rx, ry, rz, opts) {
|
|
|
63024
63685
|
const { cx, cy, r } = opts;
|
|
63025
63686
|
const persp = opts.persp ?? 4;
|
|
63026
63687
|
const view = (v) => rotate(v, rx, ry, rz);
|
|
63027
|
-
const rotated =
|
|
63688
|
+
const rotated = CORNERS2.map(view);
|
|
63028
63689
|
const faces = [];
|
|
63029
63690
|
for (const f of FACES) {
|
|
63030
63691
|
const n = view(f.normal);
|
|
@@ -68161,9 +68822,9 @@ import { classifyAudioName as classifyAudioName3 } from "@hyperframes/core/audio
|
|
|
68161
68822
|
function useFxChainObserved(element, chain, carve, automation, onSetAttributeQuietRaw) {
|
|
68162
68823
|
const lastShape = useRef107(null);
|
|
68163
68824
|
const panelEdits = useRef107(0);
|
|
68164
|
-
const onSetAttributeQuiet = (
|
|
68825
|
+
const onSetAttributeQuiet = (attr2, value) => {
|
|
68165
68826
|
panelEdits.current += 1;
|
|
68166
|
-
return onSetAttributeQuietRaw(
|
|
68827
|
+
return onSetAttributeQuietRaw(attr2, value);
|
|
68167
68828
|
};
|
|
68168
68829
|
useEffect97(() => {
|
|
68169
68830
|
const shape = JSON.stringify([
|
|
@@ -68873,7 +69534,7 @@ function FlatMediaSection({
|
|
|
68873
69534
|
const fadeMax = clipDuration2 > 0 ? clipDuration2 : 10;
|
|
68874
69535
|
const hasLoop = el.hasAttribute("loop");
|
|
68875
69536
|
const hasMuted = el.hasAttribute("muted");
|
|
68876
|
-
const
|
|
69537
|
+
const hasAudio2 = isVideoAudible({
|
|
68877
69538
|
tag: el.tagName,
|
|
68878
69539
|
hasAudioAttr: element.dataAttributes["has-audio"],
|
|
68879
69540
|
muted: el.hasAttribute("muted")
|
|
@@ -68905,7 +69566,7 @@ function FlatMediaSection({
|
|
|
68905
69566
|
quality,
|
|
68906
69567
|
onProgress: setRemoveProgress
|
|
68907
69568
|
});
|
|
68908
|
-
const stage = await commitCutout(mediaEdit, result.outputPath,
|
|
69569
|
+
const stage = await commitCutout(mediaEdit, result.outputPath, hasAudio2);
|
|
68909
69570
|
setRemoveProgress({ status: "complete", progress: 100, stage, ...result });
|
|
68910
69571
|
} catch (error) {
|
|
68911
69572
|
setRemoveProgress({
|
|
@@ -69099,7 +69760,7 @@ function FlatMediaSection({
|
|
|
69099
69760
|
}
|
|
69100
69761
|
}
|
|
69101
69762
|
),
|
|
69102
|
-
(isAudio ||
|
|
69763
|
+
(isAudio || hasAudio2) && /* @__PURE__ */ jsx184(
|
|
69103
69764
|
MediaFadeSliders,
|
|
69104
69765
|
{
|
|
69105
69766
|
fadeIn,
|
|
@@ -69128,7 +69789,7 @@ function FlatMediaSection({
|
|
|
69128
69789
|
FlatToggle,
|
|
69129
69790
|
{
|
|
69130
69791
|
label: "Has audio track",
|
|
69131
|
-
checked:
|
|
69792
|
+
checked: hasAudio2,
|
|
69132
69793
|
onChange: (next) => void commitHasAudioToggle(mediaEdit, next)
|
|
69133
69794
|
}
|
|
69134
69795
|
)
|
|
@@ -73174,7 +73835,7 @@ function FlatMultiSelectState({
|
|
|
73174
73835
|
onHideAllSelected,
|
|
73175
73836
|
onClearSelection
|
|
73176
73837
|
}) {
|
|
73177
|
-
const
|
|
73838
|
+
const hasAudio2 = !canHideSelections(multiSelectedElements);
|
|
73178
73839
|
const trackInput = useTrackDesignInput();
|
|
73179
73840
|
return /* @__PURE__ */ jsxs152("div", { className: "flex flex-col gap-3 px-4 py-3", children: [
|
|
73180
73841
|
/* @__PURE__ */ jsxs152("div", { className: "flex items-center gap-3 rounded-xl border border-panel-border bg-panel-surface p-3", children: [
|
|
@@ -73230,7 +73891,7 @@ function FlatMultiSelectState({
|
|
|
73230
73891
|
`${element.id ?? element.selector ?? ""}:${element.selectorIndex ?? 0}`
|
|
73231
73892
|
);
|
|
73232
73893
|
}) }),
|
|
73233
|
-
!
|
|
73894
|
+
!hasAudio2 && /* @__PURE__ */ jsxs152("div", { className: "flex gap-2", children: [
|
|
73234
73895
|
/* @__PURE__ */ jsxs152(
|
|
73235
73896
|
"button",
|
|
73236
73897
|
{
|
|
@@ -77072,7 +77733,7 @@ function useEditorSave({
|
|
|
77072
77733
|
if (lastFailureToastAtRef.current === null || now2 - lastFailureToastAtRef.current >= FAILURE_BURST_MS) {
|
|
77073
77734
|
lastFailureToastAtRef.current = now2;
|
|
77074
77735
|
showToast(
|
|
77075
|
-
`Couldn't save ${path}. Your latest edits are NOT persisted. Check the preview server; editing again retries the save.`,
|
|
77736
|
+
heldFileWords(error) ?? `Couldn't save ${path}. Your latest edits are NOT persisted. Check the preview server; editing again retries the save.`,
|
|
77076
77737
|
"error"
|
|
77077
77738
|
);
|
|
77078
77739
|
}
|
|
@@ -77161,7 +77822,8 @@ async function fetchProjectFile(projectId, path, query) {
|
|
|
77161
77822
|
const response = await studioApiFetch(
|
|
77162
77823
|
`/api/projects/${encodeURIComponent(projectId)}/files/${encodeURIComponent(path)}${query}`
|
|
77163
77824
|
);
|
|
77164
|
-
if (!response.ok)
|
|
77825
|
+
if (!response.ok)
|
|
77826
|
+
throw await createStudioSaveHttpError(response, `Failed to read ${path}`, { path });
|
|
77165
77827
|
const data = await response.json();
|
|
77166
77828
|
return { content: data.content, version: data.version ?? response.headers.get("etag") };
|
|
77167
77829
|
}
|
|
@@ -77214,7 +77876,9 @@ function useProjectFileWriter({ projectId }) {
|
|
|
77214
77876
|
} else if (preflight.status === 404) {
|
|
77215
77877
|
expectedVersion = null;
|
|
77216
77878
|
} else {
|
|
77217
|
-
throw await createStudioSaveHttpError(preflight, `Failed to read ${path} before save
|
|
77879
|
+
throw await createStudioSaveHttpError(preflight, `Failed to read ${path} before save`, {
|
|
77880
|
+
path
|
|
77881
|
+
});
|
|
77218
77882
|
}
|
|
77219
77883
|
}
|
|
77220
77884
|
await retryStudioSave(async () => {
|
|
@@ -77251,7 +77915,8 @@ function useProjectFileWriter({ projectId }) {
|
|
|
77251
77915
|
attemptedContent: content
|
|
77252
77916
|
});
|
|
77253
77917
|
}
|
|
77254
|
-
if (!response.ok)
|
|
77918
|
+
if (!response.ok)
|
|
77919
|
+
throw await createStudioSaveHttpError(response, `Failed to save ${path}`, { path });
|
|
77255
77920
|
const result = await response.json();
|
|
77256
77921
|
const version = result.version ?? response.headers.get("etag");
|
|
77257
77922
|
if (!version)
|
|
@@ -77751,7 +78416,7 @@ function keepDrawnStyle(live, base2, merged, draws) {
|
|
|
77751
78416
|
}
|
|
77752
78417
|
function syncStaleEditMarks(doc, file) {
|
|
77753
78418
|
const [restoredDoc, previousDoc] = [file.restored, file.previous].map(parseSavedSource);
|
|
77754
|
-
for (const live of doc.querySelectorAll(STUDIO_EDIT_ATTRS.map((
|
|
78419
|
+
for (const live of doc.querySelectorAll(STUDIO_EDIT_ATTRS.map((attr2) => `[${attr2}]`).join())) {
|
|
77755
78420
|
const source = findAuthoredElement(restoredDoc, live);
|
|
77756
78421
|
if (source && STUDIO_EDIT_ATTRS.some((a) => live.getAttribute(a) !== source.getAttribute(a))) {
|
|
77757
78422
|
syncElementAttributes(live, source, findAuthoredElement(previousDoc, live) ?? void 0);
|
|
@@ -77952,8 +78617,8 @@ var STORED_FIELD = {
|
|
|
77952
78617
|
// A quick volume save writes no other field the store keeps: without this, a clip read its last load's volume.
|
|
77953
78618
|
"data-volume": (value) => ({ volume: parseStoredVolume(value) })
|
|
77954
78619
|
};
|
|
77955
|
-
function syncStoredElementAttribute(target,
|
|
77956
|
-
const fields = STORED_FIELD[
|
|
78620
|
+
function syncStoredElementAttribute(target, attr2, value) {
|
|
78621
|
+
const fields = STORED_FIELD[attr2]?.(value);
|
|
77957
78622
|
if (!fields) return;
|
|
77958
78623
|
const key2 = getTimelineElementIdentity(target);
|
|
77959
78624
|
const same2 = (element) => Object.keys(fields).every((k) => element[k] === fields[k]);
|
|
@@ -78603,7 +79268,9 @@ async function insertTimelineComposition(input) {
|
|
|
78603
79268
|
buildProjectApiPath(input.projectId, `/files/${encodeURIComponent(input.targetPath)}`)
|
|
78604
79269
|
);
|
|
78605
79270
|
if (!current2.ok) {
|
|
78606
|
-
throw await createStudioSaveHttpError(current2, `Failed to read ${input.targetPath}
|
|
79271
|
+
throw await createStudioSaveHttpError(current2, `Failed to read ${input.targetPath}`, {
|
|
79272
|
+
path: input.targetPath
|
|
79273
|
+
});
|
|
78607
79274
|
}
|
|
78608
79275
|
const snapshot3 = await current2.json();
|
|
78609
79276
|
if (typeof snapshot3.version !== "string") throw new Error("Missing composition file version");
|
|
@@ -78713,7 +79380,7 @@ function useTimelineAssetDropOps({
|
|
|
78713
79380
|
const normalizedStart = Number(formatTimelineAttributeNumber(placement.start));
|
|
78714
79381
|
const duration = Number.isFinite(durationOverride) && durationOverride != null && durationOverride > 0 ? durationOverride : await resolveDroppedAssetDuration(pid, assetPath, kind);
|
|
78715
79382
|
const normalizedDuration = Number(formatTimelineAttributeNumber(duration));
|
|
78716
|
-
const
|
|
79383
|
+
const hasAudio2 = await resolveDroppedAssetHasAudio(pid, assetPath, kind);
|
|
78717
79384
|
const resolvedAssetSrc = resolveTimelineAssetSrc(targetPath, assetPath);
|
|
78718
79385
|
const resolvedTargetPath = targetPath || "index.html";
|
|
78719
79386
|
const fileElements = timelineElements.filter((te) => (te.sourceFile || activeCompPath || "index.html") === resolvedTargetPath).map((te) => ({ ...te, sourceFile: resolvedTargetPath }));
|
|
@@ -78751,7 +79418,7 @@ function useTimelineAssetDropOps({
|
|
|
78751
79418
|
duration: normalizedDuration,
|
|
78752
79419
|
track: track2,
|
|
78753
79420
|
zIndex: newElementZIndex,
|
|
78754
|
-
hasAudio,
|
|
79421
|
+
hasAudio: hasAudio2,
|
|
78755
79422
|
geometry: fitTimelineAssetGeometry(
|
|
78756
79423
|
null,
|
|
78757
79424
|
resolveTimelineAssetCompositionSize(originalContent)
|
|
@@ -79052,9 +79719,9 @@ ${laneKey}`;
|
|
|
79052
79719
|
}
|
|
79053
79720
|
};
|
|
79054
79721
|
}
|
|
79055
|
-
function restoredValue({ path, target, attr }, files) {
|
|
79722
|
+
function restoredValue({ path, target, attr: attr2 }, files) {
|
|
79056
79723
|
const html2 = files?.[path]?.restored;
|
|
79057
|
-
return html2 === void 0 || !target ? void 0 : readTargetAttribute(html2, target,
|
|
79724
|
+
return html2 === void 0 || !target ? void 0 : readTargetAttribute(html2, target, attr2);
|
|
79058
79725
|
}
|
|
79059
79726
|
function useLiveLanes(projectIdRef, activeCompPath) {
|
|
79060
79727
|
const compositionRef = useRef141(activeCompPath);
|
|
@@ -79069,15 +79736,15 @@ function useLiveLanes(projectIdRef, activeCompPath) {
|
|
|
79069
79736
|
}
|
|
79070
79737
|
|
|
79071
79738
|
// src/hooks/timelineAudioGroupVolume.ts
|
|
79072
|
-
function patchLiveGroupAttribute(iframe, groupId,
|
|
79739
|
+
function patchLiveGroupAttribute(iframe, groupId, attr2, value) {
|
|
79073
79740
|
const target = iframe?.contentDocument?.getElementById(groupId);
|
|
79074
79741
|
if (!target) return;
|
|
79075
|
-
if (value === null) target.removeAttribute(
|
|
79076
|
-
else target.setAttribute(
|
|
79742
|
+
if (value === null) target.removeAttribute(attr2);
|
|
79743
|
+
else target.setAttribute(attr2, value);
|
|
79077
79744
|
invalidateGroupInfoCache(iframe?.contentDocument);
|
|
79078
79745
|
}
|
|
79079
|
-
function audioGroupAttributeLiveKey(groupId,
|
|
79080
|
-
return `${groupId}\0${
|
|
79746
|
+
function audioGroupAttributeLiveKey(groupId, attr2) {
|
|
79747
|
+
return `${groupId}\0${attr2}`;
|
|
79081
79748
|
}
|
|
79082
79749
|
function mirroredGroupVolume(value) {
|
|
79083
79750
|
if (!value) return 1;
|
|
@@ -79091,8 +79758,8 @@ var GROUP_ATTR_TO_MIRROR = {
|
|
|
79091
79758
|
[HF_AUDIO_FX_ATTR13]: (value) => ({ audioGroupFxChain: value ?? void 0 }),
|
|
79092
79759
|
[HF_AUDIO_AUTOMATION_ATTR8]: (value) => ({ audioGroupAutomation: value ?? void 0 })
|
|
79093
79760
|
};
|
|
79094
|
-
function syncStoredGroupAttribute(groupId,
|
|
79095
|
-
const toPatch = GROUP_ATTR_TO_MIRROR[
|
|
79761
|
+
function syncStoredGroupAttribute(groupId, attr2, value) {
|
|
79762
|
+
const toPatch = GROUP_ATTR_TO_MIRROR[attr2];
|
|
79096
79763
|
if (!toPatch) return;
|
|
79097
79764
|
const patch = toPatch(value, groupId);
|
|
79098
79765
|
usePlayerStore.setState((state) => {
|
|
@@ -79125,15 +79792,15 @@ function groupSaveTarget(previewIframe, groupId, activeCompPath) {
|
|
|
79125
79792
|
patchTarget: buildPatchTarget({ domId: groupId })
|
|
79126
79793
|
};
|
|
79127
79794
|
}
|
|
79128
|
-
function groupLiveSource(previewIframe, groupId, activeCompPath,
|
|
79795
|
+
function groupLiveSource(previewIframe, groupId, activeCompPath, attr2) {
|
|
79129
79796
|
const { targetPath, patchTarget } = groupSaveTarget(previewIframe, groupId, activeCompPath);
|
|
79130
|
-
return { path: targetPath, target: patchTarget, attr };
|
|
79797
|
+
return { path: targetPath, target: patchTarget, attr: attr2 };
|
|
79131
79798
|
}
|
|
79132
79799
|
async function setAudioGroupAttribute({
|
|
79133
79800
|
projectId,
|
|
79134
79801
|
activeCompPath,
|
|
79135
79802
|
groupId,
|
|
79136
|
-
attr,
|
|
79803
|
+
attr: attr2,
|
|
79137
79804
|
value,
|
|
79138
79805
|
label,
|
|
79139
79806
|
previewIframe,
|
|
@@ -79149,7 +79816,7 @@ async function setAudioGroupAttribute({
|
|
|
79149
79816
|
projectId,
|
|
79150
79817
|
targetPath,
|
|
79151
79818
|
patchTarget,
|
|
79152
|
-
attr,
|
|
79819
|
+
attr: attr2,
|
|
79153
79820
|
value,
|
|
79154
79821
|
label,
|
|
79155
79822
|
writeProjectFile,
|
|
@@ -79171,43 +79838,43 @@ function useSetAudioGroupAttribute({
|
|
|
79171
79838
|
}) {
|
|
79172
79839
|
const liveLanes = useLiveLanes(projectIdRef, activeCompPath);
|
|
79173
79840
|
const setLive = useCallback115(
|
|
79174
|
-
(groupId,
|
|
79175
|
-
const key2 = audioGroupAttributeLiveKey(groupId,
|
|
79841
|
+
(groupId, attr2, value) => {
|
|
79842
|
+
const key2 = audioGroupAttributeLiveKey(groupId, attr2);
|
|
79176
79843
|
const target = previewIframeRef.current?.contentDocument?.getElementById(groupId);
|
|
79177
79844
|
liveLanes.preview(
|
|
79178
79845
|
key2,
|
|
79179
|
-
() => target?.getAttribute(
|
|
79180
|
-
groupLiveSource(previewIframeRef.current, groupId, activeCompPath,
|
|
79846
|
+
() => target?.getAttribute(attr2) ?? null,
|
|
79847
|
+
groupLiveSource(previewIframeRef.current, groupId, activeCompPath, attr2)
|
|
79181
79848
|
);
|
|
79182
|
-
patchLiveGroupAttribute(previewIframeRef.current, groupId,
|
|
79183
|
-
syncStoredGroupAttribute(groupId,
|
|
79849
|
+
patchLiveGroupAttribute(previewIframeRef.current, groupId, attr2, value);
|
|
79850
|
+
syncStoredGroupAttribute(groupId, attr2, value);
|
|
79184
79851
|
},
|
|
79185
79852
|
[liveLanes, previewIframeRef, activeCompPath]
|
|
79186
79853
|
);
|
|
79187
79854
|
const laneApply = useCallback115(
|
|
79188
|
-
(groupId,
|
|
79189
|
-
preview: (value) => patchLiveGroupAttribute(previewIframeRef.current, groupId,
|
|
79190
|
-
store: (value) => syncStoredGroupAttribute(groupId,
|
|
79855
|
+
(groupId, attr2) => ({
|
|
79856
|
+
preview: (value) => patchLiveGroupAttribute(previewIframeRef.current, groupId, attr2, value),
|
|
79857
|
+
store: (value) => syncStoredGroupAttribute(groupId, attr2, value)
|
|
79191
79858
|
}),
|
|
79192
79859
|
[previewIframeRef]
|
|
79193
79860
|
);
|
|
79194
79861
|
const claimLive = useCallback115(
|
|
79195
|
-
(groupId,
|
|
79862
|
+
(groupId, attr2, source) => liveLanes.claim(audioGroupAttributeLiveKey(groupId, attr2), laneApply(groupId, attr2), source),
|
|
79196
79863
|
[liveLanes, laneApply]
|
|
79197
79864
|
);
|
|
79198
79865
|
const revertLive = useCallback115(
|
|
79199
|
-
(groupId,
|
|
79866
|
+
(groupId, attr2) => liveLanes.revert(audioGroupAttributeLiveKey(groupId, attr2), laneApply(groupId, attr2)),
|
|
79200
79867
|
[liveLanes, laneApply]
|
|
79201
79868
|
);
|
|
79202
79869
|
const setQuiet = useCallback115(
|
|
79203
|
-
async (groupId,
|
|
79870
|
+
async (groupId, attr2, value, label) => {
|
|
79204
79871
|
const project = projectIdRef.current;
|
|
79205
79872
|
const pid = projectForTimelineSave(isRecordingRef?.current, project, showToast);
|
|
79206
|
-
const source = groupLiveSource(previewIframeRef.current, groupId, activeCompPath,
|
|
79207
|
-
const live = claimLive(groupId,
|
|
79873
|
+
const source = groupLiveSource(previewIframeRef.current, groupId, activeCompPath, attr2);
|
|
79874
|
+
const live = claimLive(groupId, attr2, source);
|
|
79208
79875
|
const unsaved = async (outcome) => {
|
|
79209
79876
|
live.settle(
|
|
79210
|
-
await readSavedAttribute(project, source.path, source.target,
|
|
79877
|
+
await readSavedAttribute(project, source.path, source.target, attr2, writeProjectFile)
|
|
79211
79878
|
);
|
|
79212
79879
|
return outcome;
|
|
79213
79880
|
};
|
|
@@ -79217,7 +79884,7 @@ function useSetAudioGroupAttribute({
|
|
|
79217
79884
|
projectId: pid,
|
|
79218
79885
|
activeCompPath,
|
|
79219
79886
|
groupId,
|
|
79220
|
-
attr,
|
|
79887
|
+
attr: attr2,
|
|
79221
79888
|
value,
|
|
79222
79889
|
label,
|
|
79223
79890
|
previewIframe: previewIframeRef.current,
|
|
@@ -79254,14 +79921,14 @@ function useSetAudioGroupAttribute({
|
|
|
79254
79921
|
|
|
79255
79922
|
// src/hooks/timelineElementFxAttribute.ts
|
|
79256
79923
|
import { useCallback as useCallback116 } from "react";
|
|
79257
|
-
function patchLiveElementAttribute(iframe, element,
|
|
79924
|
+
function patchLiveElementAttribute(iframe, element, attr2, value, activeCompPath) {
|
|
79258
79925
|
const target = findTimelineElementInIframe(iframe, element, activeCompPath);
|
|
79259
79926
|
if (!target) return;
|
|
79260
|
-
if (value === null) target.removeAttribute(
|
|
79261
|
-
else target.setAttribute(
|
|
79927
|
+
if (value === null) target.removeAttribute(attr2);
|
|
79928
|
+
else target.setAttribute(attr2, value);
|
|
79262
79929
|
}
|
|
79263
|
-
function elementAttributeLiveKey(element, activeCompPath,
|
|
79264
|
-
return `${element.sourceFile || activeCompPath || "index.html"}\0${element.key ?? element.domId ?? element.id}\0${
|
|
79930
|
+
function elementAttributeLiveKey(element, activeCompPath, attr2) {
|
|
79931
|
+
return `${element.sourceFile || activeCompPath || "index.html"}\0${element.key ?? element.domId ?? element.id}\0${attr2}`;
|
|
79265
79932
|
}
|
|
79266
79933
|
function elementSaveTarget(element, activeCompPath) {
|
|
79267
79934
|
return {
|
|
@@ -79269,15 +79936,15 @@ function elementSaveTarget(element, activeCompPath) {
|
|
|
79269
79936
|
patchTarget: buildPatchTarget(element)
|
|
79270
79937
|
};
|
|
79271
79938
|
}
|
|
79272
|
-
function elementLiveSource(element, activeCompPath,
|
|
79939
|
+
function elementLiveSource(element, activeCompPath, attr2) {
|
|
79273
79940
|
const { targetPath, patchTarget } = elementSaveTarget(element, activeCompPath);
|
|
79274
|
-
return { path: targetPath, target: patchTarget, attr };
|
|
79941
|
+
return { path: targetPath, target: patchTarget, attr: attr2 };
|
|
79275
79942
|
}
|
|
79276
79943
|
async function setElementAttribute({
|
|
79277
79944
|
projectId,
|
|
79278
79945
|
activeCompPath,
|
|
79279
79946
|
element,
|
|
79280
|
-
attr,
|
|
79947
|
+
attr: attr2,
|
|
79281
79948
|
value,
|
|
79282
79949
|
label,
|
|
79283
79950
|
patchLive: patchLive2,
|
|
@@ -79292,7 +79959,7 @@ async function setElementAttribute({
|
|
|
79292
79959
|
projectId,
|
|
79293
79960
|
targetPath,
|
|
79294
79961
|
patchTarget,
|
|
79295
|
-
attr,
|
|
79962
|
+
attr: attr2,
|
|
79296
79963
|
value,
|
|
79297
79964
|
label,
|
|
79298
79965
|
writeProjectFile,
|
|
@@ -79314,49 +79981,49 @@ function useSetElementAttribute({
|
|
|
79314
79981
|
}) {
|
|
79315
79982
|
const liveLanes = useLiveLanes(projectIdRef, activeCompPath);
|
|
79316
79983
|
const setLive = useCallback116(
|
|
79317
|
-
(element,
|
|
79318
|
-
const key2 = elementAttributeLiveKey(element, activeCompPath,
|
|
79984
|
+
(element, attr2, value) => {
|
|
79985
|
+
const key2 = elementAttributeLiveKey(element, activeCompPath, attr2);
|
|
79319
79986
|
const target = findTimelineElementInIframe(previewIframeRef.current, element, activeCompPath);
|
|
79320
79987
|
liveLanes.preview(
|
|
79321
79988
|
key2,
|
|
79322
|
-
() => target?.getAttribute(
|
|
79323
|
-
elementLiveSource(element, activeCompPath,
|
|
79989
|
+
() => target?.getAttribute(attr2) ?? null,
|
|
79990
|
+
elementLiveSource(element, activeCompPath, attr2)
|
|
79324
79991
|
);
|
|
79325
|
-
patchLiveElementAttribute(previewIframeRef.current, element,
|
|
79992
|
+
patchLiveElementAttribute(previewIframeRef.current, element, attr2, value, activeCompPath);
|
|
79326
79993
|
},
|
|
79327
79994
|
[liveLanes, previewIframeRef, activeCompPath]
|
|
79328
79995
|
);
|
|
79329
79996
|
const laneApply = useCallback116(
|
|
79330
|
-
(element,
|
|
79331
|
-
preview: (value) => patchLiveElementAttribute(previewIframeRef.current, element,
|
|
79332
|
-
store: (value) => syncStoredElementAttribute(element,
|
|
79997
|
+
(element, attr2) => ({
|
|
79998
|
+
preview: (value) => patchLiveElementAttribute(previewIframeRef.current, element, attr2, value, activeCompPath),
|
|
79999
|
+
store: (value) => syncStoredElementAttribute(element, attr2, value)
|
|
79333
80000
|
}),
|
|
79334
80001
|
[previewIframeRef, activeCompPath]
|
|
79335
80002
|
);
|
|
79336
80003
|
const claimLive = useCallback116(
|
|
79337
|
-
(element,
|
|
79338
|
-
elementAttributeLiveKey(element, activeCompPath,
|
|
79339
|
-
laneApply(element,
|
|
79340
|
-
elementLiveSource(element, activeCompPath,
|
|
80004
|
+
(element, attr2) => liveLanes.claim(
|
|
80005
|
+
elementAttributeLiveKey(element, activeCompPath, attr2),
|
|
80006
|
+
laneApply(element, attr2),
|
|
80007
|
+
elementLiveSource(element, activeCompPath, attr2)
|
|
79341
80008
|
),
|
|
79342
80009
|
[liveLanes, laneApply, activeCompPath]
|
|
79343
80010
|
);
|
|
79344
80011
|
const revertLive = useCallback116(
|
|
79345
|
-
(element,
|
|
79346
|
-
elementAttributeLiveKey(element, activeCompPath,
|
|
79347
|
-
laneApply(element,
|
|
80012
|
+
(element, attr2) => liveLanes.revert(
|
|
80013
|
+
elementAttributeLiveKey(element, activeCompPath, attr2),
|
|
80014
|
+
laneApply(element, attr2)
|
|
79348
80015
|
),
|
|
79349
80016
|
[liveLanes, laneApply, activeCompPath]
|
|
79350
80017
|
);
|
|
79351
80018
|
const setQuiet = useCallback116(
|
|
79352
|
-
async (element,
|
|
80019
|
+
async (element, attr2, value, label) => {
|
|
79353
80020
|
const project = projectIdRef.current;
|
|
79354
80021
|
const pid = projectForTimelineSave(isRecordingRef?.current, project, showToast);
|
|
79355
|
-
const live = claimLive(element,
|
|
80022
|
+
const live = claimLive(element, attr2);
|
|
79356
80023
|
const unsaved = async (outcome) => {
|
|
79357
80024
|
const { targetPath, patchTarget } = elementSaveTarget(element, activeCompPath);
|
|
79358
80025
|
live.settle(
|
|
79359
|
-
await readSavedAttribute(project, targetPath, patchTarget,
|
|
80026
|
+
await readSavedAttribute(project, targetPath, patchTarget, attr2, writeProjectFile)
|
|
79360
80027
|
);
|
|
79361
80028
|
return outcome;
|
|
79362
80029
|
};
|
|
@@ -79366,7 +80033,7 @@ function useSetElementAttribute({
|
|
|
79366
80033
|
projectId: pid,
|
|
79367
80034
|
activeCompPath,
|
|
79368
80035
|
element,
|
|
79369
|
-
attr,
|
|
80036
|
+
attr: attr2,
|
|
79370
80037
|
value,
|
|
79371
80038
|
label,
|
|
79372
80039
|
patchLive: live.preview,
|
|
@@ -79411,12 +80078,12 @@ function editsByFile(edits, activeCompPath) {
|
|
|
79411
80078
|
}
|
|
79412
80079
|
return byFile;
|
|
79413
80080
|
}
|
|
79414
|
-
function patchLive(iframe, edits,
|
|
80081
|
+
function patchLive(iframe, edits, attr2, activeCompPath) {
|
|
79415
80082
|
for (const { element, value } of edits) {
|
|
79416
80083
|
const node = findTimelineElementInIframe(iframe, element, activeCompPath);
|
|
79417
|
-
if (value === null) node?.removeAttribute(
|
|
79418
|
-
else node?.setAttribute(
|
|
79419
|
-
syncStoredElementAttribute(element,
|
|
80084
|
+
if (value === null) node?.removeAttribute(attr2);
|
|
80085
|
+
else node?.setAttribute(attr2, value);
|
|
80086
|
+
syncStoredElementAttribute(element, attr2, value);
|
|
79420
80087
|
}
|
|
79421
80088
|
}
|
|
79422
80089
|
function useSetElementsAttribute({
|
|
@@ -79430,7 +80097,7 @@ function useSetElementsAttribute({
|
|
|
79430
80097
|
isRecordingRef
|
|
79431
80098
|
}) {
|
|
79432
80099
|
return useCallback117(
|
|
79433
|
-
async (edits,
|
|
80100
|
+
async (edits, attr2, label) => {
|
|
79434
80101
|
const projectId = projectForTimelineSave(
|
|
79435
80102
|
isRecordingRef?.current,
|
|
79436
80103
|
projectIdRef.current,
|
|
@@ -79444,7 +80111,7 @@ function useSetElementsAttribute({
|
|
|
79444
80111
|
[...byFile].map(([path, patches]) => [
|
|
79445
80112
|
path,
|
|
79446
80113
|
(before) => patches.reduce(
|
|
79447
|
-
(html2, { target, value }) => applyPatchByTarget(html2, target, { type: "attribute", property:
|
|
80114
|
+
(html2, { target, value }) => applyPatchByTarget(html2, target, { type: "attribute", property: attr2, value }),
|
|
79448
80115
|
before
|
|
79449
80116
|
)
|
|
79450
80117
|
])
|
|
@@ -79458,7 +80125,7 @@ function useSetElementsAttribute({
|
|
|
79458
80125
|
writeFile: writeProjectFile,
|
|
79459
80126
|
recordEdit
|
|
79460
80127
|
});
|
|
79461
|
-
patchLive(previewIframeRef.current, edits,
|
|
80128
|
+
patchLive(previewIframeRef.current, edits, attr2, activeCompPath);
|
|
79462
80129
|
return { status: "saved" };
|
|
79463
80130
|
} catch (error) {
|
|
79464
80131
|
const reason = error instanceof Error ? error.message : "Could not save the clips";
|
|
@@ -81128,8 +81795,8 @@ function useTimelineEditing({
|
|
|
81128
81795
|
// (timelineAudioGroupVolume.ts): a sub-composition's group members have
|
|
81129
81796
|
// no flat twin, only a domClipChildren entry, so both are checked.
|
|
81130
81797
|
setQuiet: track2(
|
|
81131
|
-
guard(audioGroupMembers, setAudioGroupAttribute2.setQuiet, (reason, groupId,
|
|
81132
|
-
setAudioGroupAttribute2.revertLive(groupId,
|
|
81798
|
+
guard(audioGroupMembers, setAudioGroupAttribute2.setQuiet, (reason, groupId, attr2) => {
|
|
81799
|
+
setAudioGroupAttribute2.revertLive(groupId, attr2);
|
|
81133
81800
|
return refused(reason);
|
|
81134
81801
|
})
|
|
81135
81802
|
)
|
|
@@ -81142,8 +81809,8 @@ function useTimelineEditing({
|
|
|
81142
81809
|
guard(
|
|
81143
81810
|
(element) => [element],
|
|
81144
81811
|
setElementFxAttribute.setQuiet,
|
|
81145
|
-
(reason, element,
|
|
81146
|
-
setElementFxAttribute.revertLive(element,
|
|
81812
|
+
(reason, element, attr2) => {
|
|
81813
|
+
setElementFxAttribute.revertLive(element, attr2);
|
|
81147
81814
|
return refused(reason);
|
|
81148
81815
|
}
|
|
81149
81816
|
)
|
|
@@ -81536,6 +82203,7 @@ import { HF_AUDIO_GROUP_TAG as HF_AUDIO_GROUP_TAG7 } from "@hyperframes/core/aud
|
|
|
81536
82203
|
function announceTimelineSelection(deps, group, primary, replaceSet = false) {
|
|
81537
82204
|
const {
|
|
81538
82205
|
timelineElements,
|
|
82206
|
+
activeCompPath,
|
|
81539
82207
|
getTimelineSelectionSet: getTimelineSelectionSet2,
|
|
81540
82208
|
setSelectedTimelineElementId,
|
|
81541
82209
|
setTimelineSelectionSet
|
|
@@ -81545,7 +82213,7 @@ function announceTimelineSelection(deps, group, primary, replaceSet = false) {
|
|
|
81545
82213
|
setSelectedTimelineElementId(null);
|
|
81546
82214
|
return;
|
|
81547
82215
|
}
|
|
81548
|
-
const timelineIdFor = (selection) => findMatchingTimelineElementId(selection, timelineElements) ?? findTimelineIdByAncestor(
|
|
82216
|
+
const timelineIdFor = (selection) => findMatchingTimelineElementId(selection, timelineElements, activeCompPath || "index.html") ?? findTimelineIdByAncestor(
|
|
81549
82217
|
selection.element,
|
|
81550
82218
|
timelineElements,
|
|
81551
82219
|
selection.sourceFile || "index.html"
|
|
@@ -81575,6 +82243,9 @@ function announceTimelineSelection(deps, group, primary, replaceSet = false) {
|
|
|
81575
82243
|
}
|
|
81576
82244
|
|
|
81577
82245
|
// src/hooks/useDomSelection.ts
|
|
82246
|
+
function groupStillLive(live, refreshed, next) {
|
|
82247
|
+
return next.length > 0 && live.current === refreshed;
|
|
82248
|
+
}
|
|
81578
82249
|
function useDomSelection({
|
|
81579
82250
|
projectId,
|
|
81580
82251
|
activeCompPath,
|
|
@@ -81612,6 +82283,7 @@ function useDomSelection({
|
|
|
81612
82283
|
(group, primary, replaceSet) => announceTimelineSelection(
|
|
81613
82284
|
{
|
|
81614
82285
|
timelineElements,
|
|
82286
|
+
activeCompPath,
|
|
81615
82287
|
getTimelineSelectionSet: getTimelineSelectionSet2,
|
|
81616
82288
|
setSelectedTimelineElementId,
|
|
81617
82289
|
setTimelineSelectionSet
|
|
@@ -81621,6 +82293,7 @@ function useDomSelection({
|
|
|
81621
82293
|
replaceSet
|
|
81622
82294
|
),
|
|
81623
82295
|
[
|
|
82296
|
+
activeCompPath,
|
|
81624
82297
|
getTimelineSelectionSet2,
|
|
81625
82298
|
setSelectedTimelineElementId,
|
|
81626
82299
|
setTimelineSelectionSet,
|
|
@@ -81668,7 +82341,7 @@ function useDomSelection({
|
|
|
81668
82341
|
setDomEditSelection(nextSelection);
|
|
81669
82342
|
setDomEditGroupSelections(nextGroup);
|
|
81670
82343
|
const activeGroup = activeGroupElementRef.current;
|
|
81671
|
-
if (activeGroup && nextSelection && !activeGroup
|
|
82344
|
+
if (activeGroup && nextSelection && !elementWithin(activeGroup, nextSelection.element)) {
|
|
81672
82345
|
activeGroupElementRef.current = null;
|
|
81673
82346
|
setActiveGroupElementState(null);
|
|
81674
82347
|
}
|
|
@@ -81699,8 +82372,8 @@ function useDomSelection({
|
|
|
81699
82372
|
[applyDomSelection]
|
|
81700
82373
|
);
|
|
81701
82374
|
const buildDomSelectionFromTarget = useCallback129(
|
|
81702
|
-
(target, options) => {
|
|
81703
|
-
return
|
|
82375
|
+
(target, options, iframe = previewIframeRef.current) => {
|
|
82376
|
+
return resolveFoundSelection(iframe, target, {
|
|
81704
82377
|
activeCompositionPath: activeCompPath,
|
|
81705
82378
|
isMasterView,
|
|
81706
82379
|
preferClipAncestor: options?.preferClipAncestor,
|
|
@@ -81711,7 +82384,7 @@ function useDomSelection({
|
|
|
81711
82384
|
projectId
|
|
81712
82385
|
});
|
|
81713
82386
|
},
|
|
81714
|
-
[activeCompPath, isMasterView, projectId]
|
|
82387
|
+
[activeCompPath, isMasterView, previewIframeRef, projectId]
|
|
81715
82388
|
);
|
|
81716
82389
|
const resolveDomSelectionFromPreviewPoint = useCallback129(
|
|
81717
82390
|
// fallow-ignore-next-line complexity
|
|
@@ -81722,7 +82395,7 @@ function useDomSelection({
|
|
|
81722
82395
|
if (iframe.contentDocument) reapplyPositionEditsAfterSeek(iframe.contentDocument);
|
|
81723
82396
|
} catch {
|
|
81724
82397
|
}
|
|
81725
|
-
const target =
|
|
82398
|
+
const target = await findPointerTarget(iframe, clientX, clientY);
|
|
81726
82399
|
if (!target) return null;
|
|
81727
82400
|
return buildDomSelectionFromTarget(
|
|
81728
82401
|
target,
|
|
@@ -81736,7 +82409,7 @@ function useDomSelection({
|
|
|
81736
82409
|
}
|
|
81737
82410
|
);
|
|
81738
82411
|
},
|
|
81739
|
-
[
|
|
82412
|
+
[buildDomSelectionFromTarget, captionEditMode, previewIframeRef]
|
|
81740
82413
|
);
|
|
81741
82414
|
const resolveAllDomSelectionsFromPreviewPoint = useCallback129(
|
|
81742
82415
|
// fallow-ignore-next-line complexity
|
|
@@ -81747,7 +82420,7 @@ function useDomSelection({
|
|
|
81747
82420
|
if (iframe.contentDocument) reapplyPositionEditsAfterSeek(iframe.contentDocument);
|
|
81748
82421
|
} catch {
|
|
81749
82422
|
}
|
|
81750
|
-
const targets =
|
|
82423
|
+
const targets = await findPointerTargets(iframe, clientX, clientY);
|
|
81751
82424
|
const results = [];
|
|
81752
82425
|
for (const target of targets) {
|
|
81753
82426
|
const sel = await buildDomSelectionFromTarget(target, { skipSourceProbe: true });
|
|
@@ -81755,10 +82428,12 @@ function useDomSelection({
|
|
|
81755
82428
|
}
|
|
81756
82429
|
return results;
|
|
81757
82430
|
},
|
|
81758
|
-
[
|
|
82431
|
+
[buildDomSelectionFromTarget, captionEditMode, previewIframeRef]
|
|
81759
82432
|
);
|
|
81760
82433
|
const updateDomEditHoverSelection = useCallback129((selection) => {
|
|
81761
|
-
|
|
82434
|
+
const current2 = domEditHoverSelectionRef.current;
|
|
82435
|
+
const sameHandle = current2?.handle === selection?.handle;
|
|
82436
|
+
if (domEditSelectionsTargetSame(current2, selection) && sameHandle) return;
|
|
81762
82437
|
domEditHoverSelectionRef.current = selection;
|
|
81763
82438
|
setDomEditHoverSelection(selection);
|
|
81764
82439
|
}, []);
|
|
@@ -81766,21 +82441,21 @@ function useDomSelection({
|
|
|
81766
82441
|
// fallow-ignore-next-line complexity
|
|
81767
82442
|
async (element) => {
|
|
81768
82443
|
const iframe = previewIframeRef.current;
|
|
82444
|
+
const lookup2 = { activeCompositionPath: activeCompPath, compIdToSrc, isMasterView };
|
|
81769
82445
|
let doc = null;
|
|
81770
82446
|
try {
|
|
81771
82447
|
doc = iframe?.contentDocument ?? null;
|
|
81772
82448
|
} catch {
|
|
81773
82449
|
return null;
|
|
81774
82450
|
}
|
|
81775
|
-
if (!doc)
|
|
82451
|
+
if (!doc) {
|
|
82452
|
+
const found = await findOpaqueTimelineElement(iframe, element, lookup2);
|
|
82453
|
+
return found ? buildDomSelectionFromTarget(found, { preferClipAncestor: false }, iframe) : null;
|
|
82454
|
+
}
|
|
81776
82455
|
const held = holdScenesOf(iframe, element);
|
|
81777
82456
|
if (held) await held;
|
|
81778
82457
|
reapplyPositionEditsAfterSeek(doc);
|
|
81779
|
-
const targetElement = findElementForTimelineElement(doc, element,
|
|
81780
|
-
activeCompositionPath: activeCompPath,
|
|
81781
|
-
compIdToSrc,
|
|
81782
|
-
isMasterView
|
|
81783
|
-
});
|
|
82458
|
+
const targetElement = findElementForTimelineElement(doc, element, lookup2);
|
|
81784
82459
|
return targetElement ? buildDomSelectionFromTarget(targetElement, {
|
|
81785
82460
|
preferClipAncestor: false
|
|
81786
82461
|
}) : null;
|
|
@@ -81812,14 +82487,8 @@ function useDomSelection({
|
|
|
81812
82487
|
async (selection, iframe = previewIframeRef.current) => {
|
|
81813
82488
|
const stillSelected = () => domEditSelectionsTargetSame(domEditSelectionRef.current, selection);
|
|
81814
82489
|
if (!stillSelected()) return;
|
|
81815
|
-
|
|
81816
|
-
|
|
81817
|
-
doc = iframe?.contentDocument ?? null;
|
|
81818
|
-
} catch {
|
|
81819
|
-
return;
|
|
81820
|
-
}
|
|
81821
|
-
if (!doc) return;
|
|
81822
|
-
const element = findElementForSelection(doc, selection, activeCompPath);
|
|
82490
|
+
const element = await findSelectionElement(iframe, selection, activeCompPath);
|
|
82491
|
+
if (element === void 0 || !stillSelected()) return;
|
|
81823
82492
|
if (!element) {
|
|
81824
82493
|
const group = domEditGroupSelectionsRef.current;
|
|
81825
82494
|
logSelect("refresh-lost", {
|
|
@@ -81827,13 +82496,17 @@ function useDomSelection({
|
|
|
81827
82496
|
group: group.length
|
|
81828
82497
|
});
|
|
81829
82498
|
if (group.length > 1) {
|
|
81830
|
-
await refreshDomEditGroupSelectionsFromPreviewRef.current(group);
|
|
82499
|
+
await refreshDomEditGroupSelectionsFromPreviewRef.current(group, iframe);
|
|
81831
82500
|
return;
|
|
81832
82501
|
}
|
|
81833
82502
|
applyDomSelection(null, { revealPanel: false });
|
|
81834
82503
|
return;
|
|
81835
82504
|
}
|
|
81836
|
-
const nextSelection = await buildDomSelectionFromTarget(
|
|
82505
|
+
const nextSelection = await buildDomSelectionFromTarget(
|
|
82506
|
+
element,
|
|
82507
|
+
{ previous: selection },
|
|
82508
|
+
iframe
|
|
82509
|
+
);
|
|
81837
82510
|
if (nextSelection && stillSelected()) {
|
|
81838
82511
|
applyDomSelection(nextSelection, {
|
|
81839
82512
|
revealPanel: false,
|
|
@@ -81845,23 +82518,20 @@ function useDomSelection({
|
|
|
81845
82518
|
);
|
|
81846
82519
|
const refreshDomEditGroupSelectionsFromPreview = useCallback129(
|
|
81847
82520
|
// fallow-ignore-next-line complexity
|
|
81848
|
-
async (selections) => {
|
|
81849
|
-
const iframe = previewIframeRef.current;
|
|
81850
|
-
let doc = null;
|
|
81851
|
-
try {
|
|
81852
|
-
doc = iframe?.contentDocument ?? null;
|
|
81853
|
-
} catch {
|
|
81854
|
-
return;
|
|
81855
|
-
}
|
|
81856
|
-
if (!doc) return;
|
|
82521
|
+
async (selections, iframe = previewIframeRef.current) => {
|
|
81857
82522
|
const nextGroup = [];
|
|
81858
82523
|
for (const selection of selections) {
|
|
81859
|
-
const element =
|
|
82524
|
+
const element = await findSelectionElement(iframe, selection, activeCompPath);
|
|
82525
|
+
if (element === void 0) return;
|
|
81860
82526
|
if (!element) continue;
|
|
81861
|
-
const nextSelection2 = await buildDomSelectionFromTarget(
|
|
82527
|
+
const nextSelection2 = await buildDomSelectionFromTarget(
|
|
82528
|
+
element,
|
|
82529
|
+
{ previous: selection },
|
|
82530
|
+
iframe
|
|
82531
|
+
);
|
|
81862
82532
|
if (nextSelection2) nextGroup.push(nextSelection2);
|
|
81863
82533
|
}
|
|
81864
|
-
if (
|
|
82534
|
+
if (!groupStillLive(domEditGroupSelectionsRef, selections, nextGroup)) return;
|
|
81865
82535
|
const currentSelection = domEditSelectionRef.current;
|
|
81866
82536
|
const nextSelection = nextGroup.find((selection) => domEditSelectionsTargetSame(selection, currentSelection)) ?? nextGroup[0] ?? null;
|
|
81867
82537
|
domEditSelectionRef.current = nextSelection;
|
|
@@ -81888,7 +82558,7 @@ function useDomSelection({
|
|
|
81888
82558
|
}, [activeCompPath, projectId, applyDomSelection]);
|
|
81889
82559
|
useEffect123(() => {
|
|
81890
82560
|
if (!domEditHoverSelection) return;
|
|
81891
|
-
const shouldClear = captionEditMode || domEditSelectionsTargetSame(domEditHoverSelection, domEditSelection) || domEditSelectionInGroup(domEditGroupSelections, domEditHoverSelection) || !domEditHoverSelection
|
|
82561
|
+
const shouldClear = captionEditMode || domEditSelectionsTargetSame(domEditHoverSelection, domEditSelection) || domEditSelectionInGroup(domEditGroupSelections, domEditHoverSelection) || !selectionElementLive(domEditHoverSelection);
|
|
81892
82562
|
if (shouldClear) updateDomEditHoverSelection(null);
|
|
81893
82563
|
}, [
|
|
81894
82564
|
captionEditMode,
|
|
@@ -81995,6 +82665,7 @@ function usePreviewInteraction({
|
|
|
81995
82665
|
}) {
|
|
81996
82666
|
const cycleRef = useRef149(null);
|
|
81997
82667
|
const lastDownRef = useRef149(null);
|
|
82668
|
+
const hoverSeqRef = useRef149(0);
|
|
81998
82669
|
const pausePreviewPlayback = useCallback130(() => {
|
|
81999
82670
|
const pausedTime = pauseStudioPreviewPlayback(previewIframeRef.current);
|
|
82000
82671
|
const playerStore = usePlayerStore.getState();
|
|
@@ -82021,7 +82692,7 @@ function usePreviewInteraction({
|
|
|
82021
82692
|
const hit = await resolveDomSelectionFromPreviewPoint(e.clientX, e.clientY);
|
|
82022
82693
|
const cycle = cycleRef.current;
|
|
82023
82694
|
const hasStackCycleAtSpot = cycle !== null && cycle.candidates.length > 1 && Math.hypot(e.clientX - cycle.x, e.clientY - cycle.y) < CYCLE_RADIUS_PX && downTs - cycle.at < CYCLE_WINDOW_MS;
|
|
82024
|
-
if (hit
|
|
82695
|
+
if (hit && selectionDataAttribute(hit, "data-hf-group") !== null) {
|
|
82025
82696
|
e.preventDefault();
|
|
82026
82697
|
e.stopPropagation();
|
|
82027
82698
|
cycleRef.current = null;
|
|
@@ -82033,7 +82704,7 @@ function usePreviewInteraction({
|
|
|
82033
82704
|
applyDomSelection(child ?? hit);
|
|
82034
82705
|
return;
|
|
82035
82706
|
}
|
|
82036
|
-
if (hit && !hasStackCycleAtSpot &&
|
|
82707
|
+
if (hit && !hasStackCycleAtSpot && selectionDataAttribute(hit, "data-composition-src") === null && selectionDataAttribute(hit, "data-composition-file") === null) {
|
|
82037
82708
|
e.preventDefault();
|
|
82038
82709
|
e.stopPropagation();
|
|
82039
82710
|
cycleRef.current = null;
|
|
@@ -82110,6 +82781,7 @@ function usePreviewInteraction({
|
|
|
82110
82781
|
const handlePreviewCanvasPointerMove = useCallback130(
|
|
82111
82782
|
// fallow-ignore-next-line complexity
|
|
82112
82783
|
async (e, options) => {
|
|
82784
|
+
const seq = ++hoverSeqRef.current;
|
|
82113
82785
|
if (captionEditMode || compositionLoading) {
|
|
82114
82786
|
updateDomEditHoverSelection(null);
|
|
82115
82787
|
return null;
|
|
@@ -82118,7 +82790,7 @@ function usePreviewInteraction({
|
|
|
82118
82790
|
preferClipAncestor: options?.preferClipAncestor ?? false,
|
|
82119
82791
|
skipSourceProbe: true
|
|
82120
82792
|
});
|
|
82121
|
-
updateDomEditHoverSelection(nextSelection);
|
|
82793
|
+
if (seq === hoverSeqRef.current) updateDomEditHoverSelection(nextSelection);
|
|
82122
82794
|
return nextSelection;
|
|
82123
82795
|
},
|
|
82124
82796
|
[
|
|
@@ -82129,6 +82801,7 @@ function usePreviewInteraction({
|
|
|
82129
82801
|
]
|
|
82130
82802
|
);
|
|
82131
82803
|
const handlePreviewCanvasPointerLeave = useCallback130(() => {
|
|
82804
|
+
hoverSeqRef.current += 1;
|
|
82132
82805
|
updateDomEditHoverSelection(null);
|
|
82133
82806
|
}, [updateDomEditHoverSelection]);
|
|
82134
82807
|
const handleBlockedDomMove = useCallback130(
|
|
@@ -82764,12 +83437,12 @@ async function commitDomStyles(context, selection, stylesInEitherCase) {
|
|
|
82764
83437
|
// src/hooks/useDomEditAttributeCommits.ts
|
|
82765
83438
|
import { useCallback as useCallback133, useRef as useRef151 } from "react";
|
|
82766
83439
|
import { HF_AUDIO_GROUP_ATTR as HF_AUDIO_GROUP_ATTR6, HF_AUDIO_GROUP_TAG as HF_AUDIO_GROUP_TAG8 } from "@hyperframes/core/audio-groups";
|
|
82767
|
-
function resolveFullAttrName(
|
|
82768
|
-
return prefixData && !
|
|
83440
|
+
function resolveFullAttrName(attr2, prefixData) {
|
|
83441
|
+
return prefixData && !attr2.startsWith("data-") ? `data-${attr2}` : attr2;
|
|
82769
83442
|
}
|
|
82770
|
-
function resolveOptimisticAttributeValue(
|
|
83443
|
+
function resolveOptimisticAttributeValue(attr2, value) {
|
|
82771
83444
|
if (value === null) return null;
|
|
82772
|
-
return value === "false" && HTML_BOOLEAN_ATTRIBUTES.has(
|
|
83445
|
+
return value === "false" && HTML_BOOLEAN_ATTRIBUTES.has(attr2) ? null : value;
|
|
82773
83446
|
}
|
|
82774
83447
|
function previewAttributeName(op) {
|
|
82775
83448
|
return op.type === "attribute" ? resolveFullAttrName(op.property, true) : op.property;
|
|
@@ -82815,16 +83488,16 @@ function useDomEditAttributeCommits({
|
|
|
82815
83488
|
}) {
|
|
82816
83489
|
const domAttributeCommitVersionRef = useRef151(/* @__PURE__ */ new Map());
|
|
82817
83490
|
const commitDataAttribute = useCallback133(
|
|
82818
|
-
async (
|
|
83491
|
+
async (attr2, value, options) => {
|
|
82819
83492
|
if (!domEditSelection) return;
|
|
82820
83493
|
const iframe = previewIframeRef.current;
|
|
82821
|
-
const fullAttr = resolveFullAttrName(
|
|
82822
|
-
const commitKey = `${options.coalescePrefix}:${
|
|
83494
|
+
const fullAttr = resolveFullAttrName(attr2, true);
|
|
83495
|
+
const commitKey = `${options.coalescePrefix}:${attr2}:${getDomEditTargetKey(domEditSelection)}`;
|
|
82823
83496
|
const isLatestCommit = bumpDomEditCommitMapVersion(
|
|
82824
83497
|
domAttributeCommitVersionRef.current,
|
|
82825
83498
|
commitKey
|
|
82826
83499
|
);
|
|
82827
|
-
const op = { type: "attribute", property:
|
|
83500
|
+
const op = { type: "attribute", property: attr2, value };
|
|
82828
83501
|
let editedElement = null;
|
|
82829
83502
|
let previousValue = null;
|
|
82830
83503
|
await runDomEditCommit({
|
|
@@ -82975,9 +83648,9 @@ function useDomEditAttributeCommits({
|
|
|
82975
83648
|
[commitAttributeOps]
|
|
82976
83649
|
);
|
|
82977
83650
|
const handleDomAttributeCommit = useCallback133(
|
|
82978
|
-
async (
|
|
82979
|
-
await commitDataAttribute(
|
|
82980
|
-
label: `Edit ${
|
|
83651
|
+
async (attr2, value) => {
|
|
83652
|
+
await commitDataAttribute(attr2, value, {
|
|
83653
|
+
label: `Edit ${attr2.replace(/-/g, " ")}`,
|
|
82981
83654
|
coalescePrefix: "attr",
|
|
82982
83655
|
skipRefresh: false,
|
|
82983
83656
|
refreshAfter: true
|
|
@@ -82986,9 +83659,9 @@ function useDomEditAttributeCommits({
|
|
|
82986
83659
|
[commitDataAttribute]
|
|
82987
83660
|
);
|
|
82988
83661
|
const handleDomAttributeLiveCommit = useCallback133(
|
|
82989
|
-
async (
|
|
82990
|
-
await commitDataAttribute(
|
|
82991
|
-
label: `Edit ${
|
|
83662
|
+
async (attr2, value, onSettled, live) => {
|
|
83663
|
+
await commitDataAttribute(attr2, value, {
|
|
83664
|
+
label: `Edit ${attr2.replace(/^(data-)?/, "").replace(/-/g, " ")}`,
|
|
82992
83665
|
coalescePrefix: "attr-live",
|
|
82993
83666
|
skipRefresh: true,
|
|
82994
83667
|
onSettled,
|
|
@@ -82998,9 +83671,9 @@ function useDomEditAttributeCommits({
|
|
|
82998
83671
|
[commitDataAttribute]
|
|
82999
83672
|
);
|
|
83000
83673
|
const handleDomAttributeQuietCommit = useCallback133(
|
|
83001
|
-
async (
|
|
83002
|
-
await commitDataAttribute(
|
|
83003
|
-
label: `Edit ${
|
|
83674
|
+
async (attr2, value) => {
|
|
83675
|
+
await commitDataAttribute(attr2, value, {
|
|
83676
|
+
label: `Edit ${attr2.replace(/^(data-)?/, "").replace(/-/g, " ")}`,
|
|
83004
83677
|
coalescePrefix: "attr-quiet",
|
|
83005
83678
|
skipRefresh: true,
|
|
83006
83679
|
refreshAfter: true
|
|
@@ -83009,15 +83682,15 @@ function useDomEditAttributeCommits({
|
|
|
83009
83682
|
[commitDataAttribute]
|
|
83010
83683
|
);
|
|
83011
83684
|
const handleDomHtmlAttributeCommit = useCallback133(
|
|
83012
|
-
async (
|
|
83685
|
+
async (attr2, value) => {
|
|
83013
83686
|
if (!domEditSelection) return;
|
|
83014
83687
|
const iframe = previewIframeRef.current;
|
|
83015
|
-
const commitKey = `html-attr:${
|
|
83688
|
+
const commitKey = `html-attr:${attr2}:${getDomEditTargetKey(domEditSelection)}`;
|
|
83016
83689
|
const isLatestCommit = bumpDomEditCommitMapVersion(
|
|
83017
83690
|
domAttributeCommitVersionRef.current,
|
|
83018
83691
|
commitKey
|
|
83019
83692
|
);
|
|
83020
|
-
const op = { type: "html-attribute", property:
|
|
83693
|
+
const op = { type: "html-attribute", property: attr2, value };
|
|
83021
83694
|
let editedElement = null;
|
|
83022
83695
|
let previousValue = null;
|
|
83023
83696
|
await runDomEditCommit({
|
|
@@ -83026,7 +83699,7 @@ function useDomEditAttributeCommits({
|
|
|
83026
83699
|
iframe?.contentDocument,
|
|
83027
83700
|
domEditSelection,
|
|
83028
83701
|
activeCompPath,
|
|
83029
|
-
|
|
83702
|
+
attr2
|
|
83030
83703
|
);
|
|
83031
83704
|
if (!captured) return;
|
|
83032
83705
|
editedElement = captured.element;
|
|
@@ -83036,19 +83709,19 @@ function useDomEditAttributeCommits({
|
|
|
83036
83709
|
if (!editedElement) return;
|
|
83037
83710
|
setOrRemovePreviewAttribute(
|
|
83038
83711
|
editedElement,
|
|
83039
|
-
|
|
83040
|
-
resolveOptimisticAttributeValue(
|
|
83712
|
+
attr2,
|
|
83713
|
+
resolveOptimisticAttributeValue(attr2, value)
|
|
83041
83714
|
);
|
|
83042
83715
|
},
|
|
83043
83716
|
persist: () => persistDomEditOperations(domEditSelection, [op], {
|
|
83044
|
-
label: `Edit ${
|
|
83717
|
+
label: `Edit ${attr2}`,
|
|
83045
83718
|
coalesceKey: commitKey,
|
|
83046
83719
|
skipRefresh: false
|
|
83047
83720
|
}),
|
|
83048
83721
|
shouldRevert: () => isLatestCommit(),
|
|
83049
83722
|
revert: () => {
|
|
83050
83723
|
if (!editedElement) return;
|
|
83051
|
-
setOrRemovePreviewAttribute(editedElement,
|
|
83724
|
+
setOrRemovePreviewAttribute(editedElement, attr2, previousValue);
|
|
83052
83725
|
},
|
|
83053
83726
|
onError: (error) => reportDomEditPersistFailure(domEditSelection, [op], error, showToast),
|
|
83054
83727
|
shouldResync: () => isLatestCommit(),
|
|
@@ -85740,7 +86413,7 @@ function useGsapSelectionHandlers({
|
|
|
85740
86413
|
"add",
|
|
85741
86414
|
`Add GSAP ${method} animation`
|
|
85742
86415
|
);
|
|
85743
|
-
if (selection
|
|
86416
|
+
if (selectionDataAttribute(selection, "data-hf-studio-path-offset") !== null) {
|
|
85744
86417
|
void landed.then((didLand) => {
|
|
85745
86418
|
if (didLand) void handleDomManualEditsReset(selection).catch(() => void 0);
|
|
85746
86419
|
});
|
|
@@ -87697,7 +88370,7 @@ function useStudioSelectionPublisher({
|
|
|
87697
88370
|
const pendingSelectionRefreshKeyRef = useRef158(null);
|
|
87698
88371
|
useEffect127(() => {
|
|
87699
88372
|
if (!projectId) return;
|
|
87700
|
-
const selection = domEditSelection
|
|
88373
|
+
const selection = domEditSelection && selectionElementLive(domEditSelection) ? buildStudioSelectionSnapshot({
|
|
87701
88374
|
projectId,
|
|
87702
88375
|
selection: domEditSelection,
|
|
87703
88376
|
currentTime: usePlayerStore.getState().currentTime
|
|
@@ -88252,7 +88925,7 @@ function useDomEditSession({
|
|
|
88252
88925
|
}, [domEditGroupSelectionsRef, domEditSelectionRef, groupSelection, showToast]);
|
|
88253
88926
|
const handleUngroupSelection = useCallback152(() => {
|
|
88254
88927
|
const sel = domEditSelectionRef.current;
|
|
88255
|
-
if (!sel
|
|
88928
|
+
if (!sel || selectionDataAttribute(sel, "data-hf-group") === null) {
|
|
88256
88929
|
showToast("Select a group to ungroup", "info");
|
|
88257
88930
|
return;
|
|
88258
88931
|
}
|
|
@@ -96437,25 +97110,13 @@ import { memo as memo62, useCallback as useCallback192 } from "react";
|
|
|
96437
97110
|
import { memo as memo52, useState as useState153, useCallback as useCallback176, useEffect as useEffect151, useRef as useRef184 } from "react";
|
|
96438
97111
|
|
|
96439
97112
|
// src/components/editor/layerKind.ts
|
|
96440
|
-
|
|
96441
|
-
return el.hasAttribute("data-composition-src") || el.hasAttribute("data-composition-file");
|
|
96442
|
-
}
|
|
96443
|
-
function layerKindOf(el, hasChildren) {
|
|
96444
|
-
const tag = el.tagName.toLowerCase();
|
|
96445
|
-
if (tag === "img" || tag === "picture") return "image";
|
|
96446
|
-
if (tag === "video") return "video";
|
|
96447
|
-
if (tag === "audio") return "audio";
|
|
96448
|
-
if (tag === "svg") return "vector";
|
|
96449
|
-
if (el.hasAttribute("data-hf-group") || isCompositionHost(el)) return "group";
|
|
96450
|
-
if (hasOnlyFormattingChildren(el) && el.textContent?.trim()) return "text";
|
|
96451
|
-
return hasChildren ? "group" : "shape";
|
|
96452
|
-
}
|
|
97113
|
+
import { isCompositionHost, layerKindOf } from "@hyperframes/core/runtime/editing-port";
|
|
96453
97114
|
|
|
96454
97115
|
// src/components/editor/useLayerDrag.ts
|
|
96455
97116
|
import { useRef as useRef183, useState as useState152, useCallback as useCallback175 } from "react";
|
|
96456
97117
|
var DRAG_THRESHOLD_PX4 = 4;
|
|
96457
97118
|
function isLayerDraggable(layer) {
|
|
96458
|
-
if (!(layer.selector || layer.id)) return false;
|
|
97119
|
+
if (!(layer.selector || layer.id) || layer.preview) return false;
|
|
96459
97120
|
let el = layer.element;
|
|
96460
97121
|
while (el) {
|
|
96461
97122
|
if (el.hasAttribute("data-timeline-locked")) return false;
|
|
@@ -96630,8 +97291,8 @@ function sortLayersByZIndex(layers) {
|
|
|
96630
97291
|
return layers;
|
|
96631
97292
|
}
|
|
96632
97293
|
chunks.sort((a, b) => {
|
|
96633
|
-
const zA = getElementZIndex(a.root.element);
|
|
96634
|
-
const zB = getElementZIndex(b.root.element);
|
|
97294
|
+
const zA = a.root.preview?.zIndex ?? getElementZIndex(a.root.element);
|
|
97295
|
+
const zB = b.root.preview?.zIndex ?? getElementZIndex(b.root.element);
|
|
96635
97296
|
if (zA !== zB) return zB - zA;
|
|
96636
97297
|
return b.domIndex - a.domIndex;
|
|
96637
97298
|
});
|
|
@@ -96731,9 +97392,24 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96731
97392
|
});
|
|
96732
97393
|
const isMasterView = !activeCompPath || activeCompPath === "index.html";
|
|
96733
97394
|
const livePreviewIframe = useLivePreviewIframe();
|
|
97395
|
+
const opaqueRead = useRef184(null);
|
|
96734
97396
|
const collectLayers = useCallback176(() => {
|
|
96735
97397
|
const iframe = previewIframeRef.current;
|
|
96736
97398
|
if (!iframe) return;
|
|
97399
|
+
if (previewFrameOpaque(iframe)) {
|
|
97400
|
+
if (opaqueRead.current) return void (opaqueRead.current.again = true);
|
|
97401
|
+
const read2 = { again: false };
|
|
97402
|
+
opaqueRead.current = read2;
|
|
97403
|
+
const scope = { activeCompositionPath: activeCompPath, activeGroupElement };
|
|
97404
|
+
void collectPreviewLayerItems(iframe, scope, LAYERS_PANEL_MAX_ROWS).then((reply) => {
|
|
97405
|
+
if (opaqueRead.current !== read2) return;
|
|
97406
|
+
opaqueRead.current = null;
|
|
97407
|
+
if (reply?.missingGroup) return setActiveGroupElement(null);
|
|
97408
|
+
if (reply) setLayers(sortLayersByZIndex(reply.items));
|
|
97409
|
+
if (read2.again) collectLayers();
|
|
97410
|
+
});
|
|
97411
|
+
return;
|
|
97412
|
+
}
|
|
96737
97413
|
let doc = null;
|
|
96738
97414
|
try {
|
|
96739
97415
|
doc = iframe.contentDocument;
|
|
@@ -96754,6 +97430,7 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96754
97430
|
setLayers(sortLayersByZIndex(items));
|
|
96755
97431
|
}, [previewIframeRef, activeCompPath, isMasterView, activeGroupElement, setActiveGroupElement]);
|
|
96756
97432
|
useEffect151(() => {
|
|
97433
|
+
opaqueRead.current = null;
|
|
96757
97434
|
collectLayers();
|
|
96758
97435
|
}, [collectLayers, refreshKey, zEditVersion, livePreviewIframe]);
|
|
96759
97436
|
useEffect151(() => {
|
|
@@ -96780,15 +97457,20 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96780
97457
|
};
|
|
96781
97458
|
}, [collectLayers]);
|
|
96782
97459
|
const resolveSelection = useCallback176(
|
|
96783
|
-
(layer) => {
|
|
96784
|
-
const
|
|
96785
|
-
const
|
|
96786
|
-
return resolveDomEditSelection(el, {
|
|
97460
|
+
async (layer) => {
|
|
97461
|
+
const iframe = previewIframeRef.current;
|
|
97462
|
+
const options = {
|
|
96787
97463
|
activeCompositionPath: activeCompPath,
|
|
96788
97464
|
isMasterView,
|
|
96789
97465
|
preferClipAncestor: false,
|
|
96790
97466
|
activeGroupElement
|
|
96791
|
-
}
|
|
97467
|
+
};
|
|
97468
|
+
if (layer.preview && iframe) {
|
|
97469
|
+
const [described] = await describePreviewElements(iframe, [layer.preview.handle]) ?? [];
|
|
97470
|
+
return described ? resolvePreviewSelection(iframe, described, options) : null;
|
|
97471
|
+
}
|
|
97472
|
+
const el = liveLayerElement(layer, iframe?.contentDocument, activeCompPath);
|
|
97473
|
+
return resolveDomEditSelection(el, options);
|
|
96792
97474
|
},
|
|
96793
97475
|
[activeCompPath, isMasterView, previewIframeRef, activeGroupElement]
|
|
96794
97476
|
);
|
|
@@ -96796,7 +97478,8 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96796
97478
|
async (layer) => {
|
|
96797
97479
|
const selection = await resolveSelection(layer);
|
|
96798
97480
|
if (!selection) return;
|
|
96799
|
-
|
|
97481
|
+
const scope = activeCompPath || "index.html";
|
|
97482
|
+
let matchedId = findMatchingTimelineElementId(selection, timelineElements, scope);
|
|
96800
97483
|
if (!matchedId) {
|
|
96801
97484
|
const sourceFile = selection.sourceFile ?? "index.html";
|
|
96802
97485
|
let ancestor = layer.element.parentElement;
|
|
@@ -96819,7 +97502,7 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96819
97502
|
}
|
|
96820
97503
|
}
|
|
96821
97504
|
},
|
|
96822
|
-
[currentTime, resolveSelection, timelineElements]
|
|
97505
|
+
[activeCompPath, currentTime, resolveSelection, timelineElements]
|
|
96823
97506
|
);
|
|
96824
97507
|
const handleSelectLayer = useCallback176(
|
|
96825
97508
|
async (layer) => {
|
|
@@ -96834,7 +97517,7 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96834
97517
|
const handleLayerDoubleClick = useCallback176(
|
|
96835
97518
|
async (layer) => {
|
|
96836
97519
|
const selection = await resolveSelection(layer);
|
|
96837
|
-
if (selection
|
|
97520
|
+
if (selection && selectionDataAttribute(selection, "data-hf-group") !== null) {
|
|
96838
97521
|
setActiveGroupElement(selection.element);
|
|
96839
97522
|
} else {
|
|
96840
97523
|
await handleSelectLayer(layer);
|
|
@@ -96980,8 +97663,8 @@ var LayersPanel = memo52(function LayersPanel2({ host }) {
|
|
|
96980
97663
|
const draggable = isLayerDraggable(layer);
|
|
96981
97664
|
const isCollapsed = collapsed[layer.key] ?? false;
|
|
96982
97665
|
const hasChildren = layer.childCount > 0;
|
|
96983
|
-
const isCompHost = isCompositionHost(layer.element);
|
|
96984
|
-
const kind = layerKindOf(layer.element, hasChildren);
|
|
97666
|
+
const isCompHost = layer.preview ? layerDataAttribute(layer, "data-composition-src") !== null || layerDataAttribute(layer, "data-composition-file") !== null : isCompositionHost(layer.element);
|
|
97667
|
+
const kind = layer.preview?.kind ?? layerKindOf(layer.element, hasChildren);
|
|
96985
97668
|
const KindIcon = KIND_ICON[kind];
|
|
96986
97669
|
const kindName = kind[0].toUpperCase() + kind.slice(1);
|
|
96987
97670
|
const hint = draggable ? layer.element.hasAttribute("data-hf-group") ? "Double-click to enter group" : void 0 : "This layer can't be reordered";
|
|
@@ -101428,7 +102111,7 @@ var StudioRightPanels = memo62(function StudioRightPanels2({
|
|
|
101428
102111
|
const handleApplyColorGradingScope = useApplyColorGradingScope(recordEdit, reloadPreview);
|
|
101429
102112
|
const handleRemoveBackground = useRemoveBackground(projectId, refreshFileTree, showToast);
|
|
101430
102113
|
const setAttributeWhileDragging = useCallback192(
|
|
101431
|
-
(
|
|
102114
|
+
(attr2, value) => handleDomAttributeLiveCommit(attr2, value, void 0, { previewOnly: true }),
|
|
101432
102115
|
[handleDomAttributeLiveCommit]
|
|
101433
102116
|
);
|
|
101434
102117
|
const handleHideAllSelected = useCallback192(() => {
|
|
@@ -103453,23 +104136,23 @@ function useElementPicker(iframeRef, options) {
|
|
|
103453
104136
|
[pickedElement, getActiveIframe, setPickedElement, syncToSource]
|
|
103454
104137
|
);
|
|
103455
104138
|
const setDataAttr = useCallback198(
|
|
103456
|
-
(
|
|
104139
|
+
(attr2, value) => {
|
|
103457
104140
|
const activeIframe = getActiveIframe();
|
|
103458
104141
|
if (!pickedElement?.selector || !activeIframe) return;
|
|
103459
104142
|
try {
|
|
103460
104143
|
const doc = activeIframe.contentDocument;
|
|
103461
104144
|
const el = doc?.querySelector(pickedElement.selector);
|
|
103462
104145
|
if (el) {
|
|
103463
|
-
el.setAttribute(`data-${
|
|
104146
|
+
el.setAttribute(`data-${attr2}`, value);
|
|
103464
104147
|
setPickedElement(
|
|
103465
104148
|
(prev) => prev ? {
|
|
103466
104149
|
...prev,
|
|
103467
|
-
dataAttributes: { ...prev.dataAttributes, [
|
|
104150
|
+
dataAttributes: { ...prev.dataAttributes, [attr2]: value }
|
|
103468
104151
|
} : null
|
|
103469
104152
|
);
|
|
103470
104153
|
syncToSource(pickedElement, el, activeIframe, {
|
|
103471
104154
|
type: "attribute",
|
|
103472
|
-
property:
|
|
104155
|
+
property: attr2,
|
|
103473
104156
|
value
|
|
103474
104157
|
});
|
|
103475
104158
|
}
|