@hyperframes/core 0.9.85 → 0.9.87
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/compiler/compositionSizeLimit.d.ts +3 -11
- package/dist/compiler/compositionSizeLimit.js +7 -11
- package/dist/compiler/htmlBundler.js +25 -8
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/runtime/editing/editElement.d.ts +4 -2
- package/dist/runtime/editing/editElement.js +26 -27
- package/dist/runtime/editing/textEdit.d.ts +4 -1
- package/dist/runtime/editing/textEdit.js +46 -26
- package/dist/runtime/editing/textMarkup.d.ts +4 -0
- package/dist/runtime/editing/textMarkup.js +22 -0
- package/dist/runtime/editingElement.d.ts +1 -0
- package/dist/runtime/editingGestureStart.d.ts +7 -0
- package/dist/runtime/editingGestureStart.js +11 -0
- package/dist/runtime/editingHandles.js +2 -0
- package/dist/runtime/editingPort.d.ts +13 -4
- package/dist/runtime/editingPort.js +5 -1
- package/dist/runtime/types.d.ts +7 -0
- package/package.json +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EditingElementHandle } from "../editingElement.js";
|
|
2
|
+
import { MAX_EDIT_VALUE } from "./textMarkup.js";
|
|
2
3
|
export type ElementEditEntry = [name: string, value: string | null];
|
|
3
4
|
export type StyleEditEntry = [name: string, value: string | null, priority?: "important"];
|
|
4
5
|
export type EditElementParams = {
|
|
@@ -6,6 +7,7 @@ export type EditElementParams = {
|
|
|
6
7
|
styles: StyleEditEntry[];
|
|
7
8
|
attributes: ElementEditEntry[];
|
|
8
9
|
html?: string;
|
|
10
|
+
expect?: string;
|
|
9
11
|
};
|
|
10
12
|
export type EditElementResult = {
|
|
11
13
|
applied: boolean;
|
|
@@ -14,9 +16,9 @@ export type EditElementResult = {
|
|
|
14
16
|
html?: string;
|
|
15
17
|
};
|
|
16
18
|
export declare const MAX_EDIT_ENTRIES = 64;
|
|
17
|
-
export
|
|
18
|
-
/** Markup a text field writes: text in inline text tags, no URL, no handler. */
|
|
19
|
+
export { MAX_EDIT_VALUE };
|
|
19
20
|
export declare function isTextMarkup(html: string): boolean;
|
|
21
|
+
export declare const openTextEdits: WeakSet<Element>;
|
|
20
22
|
export declare function parseEditElement(params: unknown): EditElementParams | null;
|
|
21
23
|
/** Draws nothing it could not put back: `src` off media, a too-long value, or non-text markup. */
|
|
22
24
|
export declare function editElement(params: EditElementParams): EditElementResult;
|
|
@@ -3,38 +3,21 @@
|
|
|
3
3
|
import { EDITING_ELEMENT_HANDLE } from "../editingElement.js";
|
|
4
4
|
import { elementForHandle } from "../editingHandles.js";
|
|
5
5
|
import { isStylableElement } from "../domRealm.js";
|
|
6
|
+
import { DATA_ATTRIBUTE, holdsOnlyTextMarkup, MAX_EDIT_VALUE } from "./textMarkup.js";
|
|
6
7
|
export const MAX_EDIT_ENTRIES = 64;
|
|
7
|
-
export
|
|
8
|
+
export { MAX_EDIT_VALUE };
|
|
8
9
|
const STYLE_NAME = /^(?:-?[a-z][a-z0-9-]*|--[\w\u0080-\uffff-]+)$/;
|
|
9
|
-
const DATA_ATTRIBUTE = /^data-[a-z0-9_-]+$/;
|
|
10
10
|
const PANEL_ATTRIBUTES = new Set(["loop", "muted", "alt", "title", "src"]);
|
|
11
11
|
const MEDIA_TAGS = new Set(["img", "video", "audio"]);
|
|
12
12
|
const isAttributeName = (name) => DATA_ATTRIBUTE.test(name) || PANEL_ATTRIBUTES.has(name);
|
|
13
|
-
const TEXT_TAGS = new Set([
|
|
14
|
-
"span",
|
|
15
|
-
"strong",
|
|
16
|
-
"b",
|
|
17
|
-
"em",
|
|
18
|
-
"i",
|
|
19
|
-
"u",
|
|
20
|
-
"s",
|
|
21
|
-
"br",
|
|
22
|
-
"sub",
|
|
23
|
-
"sup",
|
|
24
|
-
"small",
|
|
25
|
-
]);
|
|
26
|
-
const TEXT_ATTRIBUTES = new Set(["class", "id", "style", "title", "lang", "dir"]);
|
|
27
|
-
/** Markup a text field writes: text in inline text tags, no URL, no handler. */
|
|
28
13
|
export function isTextMarkup(html) {
|
|
29
14
|
if (html.length > MAX_EDIT_VALUE)
|
|
30
15
|
return false;
|
|
31
16
|
const holder = document.createElement("template");
|
|
32
17
|
holder.innerHTML = html;
|
|
33
|
-
return
|
|
34
|
-
el
|
|
35
|
-
.getAttributeNames()
|
|
36
|
-
.every((name) => TEXT_ATTRIBUTES.has(name) || DATA_ATTRIBUTE.test(name)));
|
|
18
|
+
return holdsOnlyTextMarkup(holder.content);
|
|
37
19
|
}
|
|
20
|
+
export const openTextEdits = new WeakSet();
|
|
38
21
|
const isValue = (value) => value === null || (typeof value === "string" && value.length <= MAX_EDIT_VALUE);
|
|
39
22
|
function entries(value, valid) {
|
|
40
23
|
if (!Array.isArray(value) || value.length > MAX_EDIT_ENTRIES)
|
|
@@ -48,28 +31,44 @@ const styleEntry = ([name, value, priority, ...rest]) => typeof name === "string
|
|
|
48
31
|
(priority === undefined || priority === "important") &&
|
|
49
32
|
rest.length === 0;
|
|
50
33
|
const attributeEntry = ([name, value, ...rest]) => typeof name === "string" && isAttributeName(name) && isValue(value) && rest.length === 0;
|
|
34
|
+
const EDIT_KEYS = new Set([
|
|
35
|
+
"attributes,handle,styles",
|
|
36
|
+
"attributes,handle,html,styles",
|
|
37
|
+
"attributes,expect,handle,html,styles",
|
|
38
|
+
]);
|
|
39
|
+
const isOptionalMarkup = (value) => value === undefined || (typeof value === "string" && value.length <= MAX_EDIT_VALUE);
|
|
40
|
+
const markupFieldsOk = (html, expect) => isOptionalMarkup(html) &&
|
|
41
|
+
isOptionalMarkup(expect) &&
|
|
42
|
+
(expect === undefined || html !== undefined);
|
|
51
43
|
export function parseEditElement(params) {
|
|
52
44
|
if (Object.prototype.toString.call(params) !== "[object Object]")
|
|
53
45
|
return null;
|
|
54
46
|
const record = params;
|
|
55
47
|
const keys = Object.keys(record).sort().join();
|
|
56
|
-
if (keys
|
|
48
|
+
if (!EDIT_KEYS.has(keys))
|
|
57
49
|
return null;
|
|
58
|
-
const { handle, html } = record;
|
|
50
|
+
const { handle, html, expect } = record;
|
|
59
51
|
if (typeof handle !== "string" || !EDITING_ELEMENT_HANDLE.test(handle))
|
|
60
52
|
return null;
|
|
61
|
-
if (
|
|
53
|
+
if (!markupFieldsOk(html, expect))
|
|
62
54
|
return null;
|
|
63
55
|
const styles = entries(record.styles, styleEntry);
|
|
64
56
|
const attributes = entries(record.attributes, attributeEntry);
|
|
65
57
|
if (!styles || !attributes)
|
|
66
58
|
return null;
|
|
67
|
-
|
|
59
|
+
const parsed = { handle, styles, attributes };
|
|
60
|
+
if (html !== undefined)
|
|
61
|
+
parsed.html = html;
|
|
62
|
+
if (expect !== undefined)
|
|
63
|
+
parsed.expect = expect;
|
|
64
|
+
return parsed;
|
|
68
65
|
}
|
|
69
66
|
const NOT_APPLIED = { applied: false, styles: [], attributes: [] };
|
|
70
|
-
function refused(element, attributes, html) {
|
|
67
|
+
function refused(element, { attributes, html, expect }) {
|
|
71
68
|
if (attributes.some(([name]) => name === "src") && !MEDIA_TAGS.has(element.localName))
|
|
72
69
|
return true;
|
|
70
|
+
if (expect !== undefined && (openTextEdits.has(element) || element.innerHTML !== expect))
|
|
71
|
+
return true;
|
|
73
72
|
return html !== undefined && !(isTextMarkup(element.innerHTML) && isTextMarkup(html));
|
|
74
73
|
}
|
|
75
74
|
function valuesBefore(element, { styles, attributes, html }) {
|
|
@@ -103,7 +102,7 @@ function draw(element, { styles, attributes, html }) {
|
|
|
103
102
|
/** Draws nothing it could not put back: `src` off media, a too-long value, or non-text markup. */
|
|
104
103
|
export function editElement(params) {
|
|
105
104
|
const element = elementForHandle(params.handle);
|
|
106
|
-
if (!isStylableElement(element) || refused(element, params
|
|
105
|
+
if (!isStylableElement(element) || refused(element, params))
|
|
107
106
|
return NOT_APPLIED;
|
|
108
107
|
const before = valuesBefore(element, params);
|
|
109
108
|
if (![...before.styles, ...before.attributes].every(([, value]) => isValue(value)))
|
|
@@ -17,7 +17,7 @@ export type TextEditResult = {
|
|
|
17
17
|
html: string | null;
|
|
18
18
|
previous: string | null;
|
|
19
19
|
};
|
|
20
|
-
/** Posted to the starting port when Enter or
|
|
20
|
+
/** Posted to the starting port when Enter, Escape or a blur ends the session in the frame; null html was refused. */
|
|
21
21
|
export type TextEditEndedEvent = {
|
|
22
22
|
handle: EditingElementHandle;
|
|
23
23
|
html: string | null;
|
|
@@ -25,7 +25,10 @@ export type TextEditEndedEvent = {
|
|
|
25
25
|
};
|
|
26
26
|
export declare function parseTextEdit(params: unknown): TextEditParams | null;
|
|
27
27
|
export declare function textEditEndedEvent(data: unknown, version: number): TextEditEndedEvent | null;
|
|
28
|
+
export declare function textEditResult(reply: unknown): TextEditResult | null;
|
|
28
29
|
/** Ends an open session with its original markup back; the agent's dispose and a page hide call it. */
|
|
29
30
|
export declare function endTextEdit(): void;
|
|
31
|
+
export declare function caretRangeAt(doc: Document, at: Point): Range | null;
|
|
32
|
+
export declare function takePlainTextOnly(element: HTMLElement): () => void;
|
|
30
33
|
export declare function textEdit(params: TextEditParams, port: MessagePort, version: number): TextEditResult;
|
|
31
34
|
export {};
|
|
@@ -4,7 +4,8 @@ import { EDITING_ELEMENT_HANDLE } from "../editingElement.js";
|
|
|
4
4
|
import { elementForHandle } from "../editingHandles.js";
|
|
5
5
|
import { isStylableElement } from "../domRealm.js";
|
|
6
6
|
import { sanitizeRichTextChildren } from "../../utils/richTextSanitize.js";
|
|
7
|
-
import { isTextMarkup, MAX_EDIT_VALUE } from "./editElement.js";
|
|
7
|
+
import { openTextEdits, isTextMarkup, MAX_EDIT_VALUE } from "./editElement.js";
|
|
8
|
+
import { isEditableText } from "./textMarkup.js";
|
|
8
9
|
const EDITING_OUTLINE = "2px solid #3CE6AC";
|
|
9
10
|
const isRecord = (value) => Object.prototype.toString.call(value) === "[object Object]";
|
|
10
11
|
const keysAre = (value, keys) => Object.keys(value).sort().join() === keys;
|
|
@@ -22,16 +23,27 @@ export function parseTextEdit(params) {
|
|
|
22
23
|
return { handle, action, keep: params.keep };
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
|
-
const
|
|
26
|
+
const isValue = (value) => value === null || (typeof value === "string" && value.length <= MAX_EDIT_VALUE);
|
|
27
|
+
const isTextMarkupOrNull = (value) => value === null || (typeof value === "string" && isTextMarkup(value));
|
|
26
28
|
export function textEditEndedEvent(data, version) {
|
|
27
29
|
if (!isRecord(data) || !keysAre(data, "event,handle,html,previous,v"))
|
|
28
30
|
return null;
|
|
29
31
|
if (data.v !== version || data.event !== "text-edit-ended" || !isHandle(data.handle))
|
|
30
32
|
return null;
|
|
31
33
|
const { handle, html, previous } = data;
|
|
32
|
-
if (!
|
|
34
|
+
if (!isValue(html) || typeof previous !== "string" || !isValue(previous))
|
|
33
35
|
return null;
|
|
34
|
-
|
|
36
|
+
if (!isTextMarkupOrNull(html) || !isTextMarkupOrNull(previous))
|
|
37
|
+
return { handle, html: null, previous: "" };
|
|
38
|
+
return { handle, html, previous };
|
|
39
|
+
}
|
|
40
|
+
export function textEditResult(reply) {
|
|
41
|
+
if (!isRecord(reply) || !keysAre(reply, "applied,html,previous"))
|
|
42
|
+
return null;
|
|
43
|
+
const { applied, html, previous } = reply;
|
|
44
|
+
if (typeof applied !== "boolean" || !isTextMarkupOrNull(html) || !isTextMarkupOrNull(previous))
|
|
45
|
+
return null;
|
|
46
|
+
return { applied, html, previous };
|
|
35
47
|
}
|
|
36
48
|
let session = null;
|
|
37
49
|
const NOTHING = { applied: false, html: null, previous: null };
|
|
@@ -55,8 +67,9 @@ function close(keep) {
|
|
|
55
67
|
session = null;
|
|
56
68
|
open.stop();
|
|
57
69
|
const { element } = open;
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
openTextEdits.delete(element);
|
|
71
|
+
const html = keep ? keptMarkup(element) : null;
|
|
72
|
+
if (html === null || !element.isConnected)
|
|
60
73
|
element.innerHTML = open.original;
|
|
61
74
|
element.removeAttribute("contenteditable");
|
|
62
75
|
element.style.outline = open.outline;
|
|
@@ -71,7 +84,7 @@ function close(keep) {
|
|
|
71
84
|
export function endTextEdit() {
|
|
72
85
|
close(false);
|
|
73
86
|
}
|
|
74
|
-
function caretRangeAt(doc, at) {
|
|
87
|
+
export function caretRangeAt(doc, at) {
|
|
75
88
|
const legacy = doc;
|
|
76
89
|
if (typeof legacy.caretRangeFromPoint === "function")
|
|
77
90
|
return legacy.caretRangeFromPoint(at.x, at.y);
|
|
@@ -97,13 +110,7 @@ function placeCaret(element, at) {
|
|
|
97
110
|
selection.removeAllRanges();
|
|
98
111
|
selection.addRange(range);
|
|
99
112
|
}
|
|
100
|
-
function
|
|
101
|
-
const onKeyDown = (event) => {
|
|
102
|
-
if ((event.key !== "Enter" || event.shiftKey) && event.key !== "Escape")
|
|
103
|
-
return;
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
endInFrame();
|
|
106
|
-
};
|
|
113
|
+
export function takePlainTextOnly(element) {
|
|
107
114
|
const insertPlainText = (text) => {
|
|
108
115
|
if (text)
|
|
109
116
|
element.ownerDocument.execCommand("insertText", false, text);
|
|
@@ -117,24 +124,36 @@ function listen(element, endInFrame) {
|
|
|
117
124
|
event.preventDefault();
|
|
118
125
|
insertPlainText(event.dataTransfer?.getData("text/plain"));
|
|
119
126
|
};
|
|
127
|
+
element.addEventListener("paste", onPaste);
|
|
128
|
+
element.addEventListener("dragover", onDragOver);
|
|
129
|
+
element.addEventListener("drop", onDrop);
|
|
130
|
+
return () => {
|
|
131
|
+
element.removeEventListener("paste", onPaste);
|
|
132
|
+
element.removeEventListener("dragover", onDragOver);
|
|
133
|
+
element.removeEventListener("drop", onDrop);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function listen(element, endInFrame) {
|
|
137
|
+
const onKeyDown = (event) => {
|
|
138
|
+
if ((event.key !== "Enter" || event.shiftKey) && event.key !== "Escape")
|
|
139
|
+
return;
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
endInFrame();
|
|
142
|
+
};
|
|
120
143
|
const removed = new MutationObserver(() => {
|
|
121
144
|
if (!element.isConnected)
|
|
122
|
-
|
|
145
|
+
endInFrame();
|
|
123
146
|
});
|
|
124
147
|
removed.observe(element.ownerDocument, { childList: true, subtree: true });
|
|
125
148
|
const view = element.ownerDocument.defaultView;
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
["dragover", onDragOver],
|
|
130
|
-
["drop", onDrop],
|
|
131
|
-
];
|
|
132
|
-
for (const [type, listener] of events)
|
|
133
|
-
element.addEventListener(type, listener);
|
|
149
|
+
const releasePlainText = takePlainTextOnly(element);
|
|
150
|
+
element.addEventListener("keydown", onKeyDown);
|
|
151
|
+
element.addEventListener("blur", endInFrame);
|
|
134
152
|
view?.addEventListener("pagehide", endTextEdit);
|
|
135
153
|
return () => {
|
|
136
|
-
|
|
137
|
-
|
|
154
|
+
releasePlainText();
|
|
155
|
+
element.removeEventListener("keydown", onKeyDown);
|
|
156
|
+
element.removeEventListener("blur", endInFrame);
|
|
138
157
|
view?.removeEventListener("pagehide", endTextEdit);
|
|
139
158
|
removed.disconnect();
|
|
140
159
|
};
|
|
@@ -142,7 +161,7 @@ function listen(element, endInFrame) {
|
|
|
142
161
|
function start(handle, caret, port, version) {
|
|
143
162
|
close(false);
|
|
144
163
|
const element = elementForHandle(handle);
|
|
145
|
-
if (!isStylableElement(element) || !
|
|
164
|
+
if (!isStylableElement(element) || !isEditableText(element))
|
|
146
165
|
return NOTHING;
|
|
147
166
|
const editable = element;
|
|
148
167
|
const open = {
|
|
@@ -162,6 +181,7 @@ function start(handle, caret, port, version) {
|
|
|
162
181
|
port.postMessage({ v: version, event: "text-edit-ended", handle, ...ended });
|
|
163
182
|
});
|
|
164
183
|
session = open;
|
|
184
|
+
openTextEdits.add(editable);
|
|
165
185
|
editable.style.outline = EDITING_OUTLINE;
|
|
166
186
|
editable.style.outlineOffset = "2px";
|
|
167
187
|
editable.setAttribute("contenteditable", "true");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Text markup: text in inline text tags carrying plain attributes, so no URL and no handler.
|
|
2
|
+
export const DATA_ATTRIBUTE = /^data-[a-z0-9_-]+$/;
|
|
3
|
+
export const MAX_EDIT_VALUE = 200_000;
|
|
4
|
+
const TEXT_TAGS = new Set([
|
|
5
|
+
"span",
|
|
6
|
+
"strong",
|
|
7
|
+
"b",
|
|
8
|
+
"em",
|
|
9
|
+
"i",
|
|
10
|
+
"u",
|
|
11
|
+
"s",
|
|
12
|
+
"br",
|
|
13
|
+
"sub",
|
|
14
|
+
"sup",
|
|
15
|
+
"small",
|
|
16
|
+
]);
|
|
17
|
+
const TEXT_ATTRIBUTES = new Set(["class", "id", "style", "title", "lang", "dir"]);
|
|
18
|
+
export const holdsOnlyTextMarkup = (root) => Array.from(root.querySelectorAll("*")).every((el) => TEXT_TAGS.has(el.localName) &&
|
|
19
|
+
el
|
|
20
|
+
.getAttributeNames()
|
|
21
|
+
.every((name) => TEXT_ATTRIBUTES.has(name) || DATA_ATTRIBUTE.test(name)));
|
|
22
|
+
export const isEditableText = (element) => holdsOnlyTextMarkup(element) && element.innerHTML.length <= MAX_EDIT_VALUE;
|
|
@@ -32,6 +32,13 @@ export interface EditingGestureStart extends EditingElementGeometry {
|
|
|
32
32
|
d: number;
|
|
33
33
|
} | null;
|
|
34
34
|
}
|
|
35
|
+
export type EditingGestureBase = {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
opacity: number;
|
|
39
|
+
scale: number;
|
|
40
|
+
};
|
|
41
|
+
export declare function gestureBase(handle: EditingElementHandle): EditingGestureBase | null;
|
|
35
42
|
/** Each handle's gesture start, null as in `describe`, and the snap boxes of the page around them. */
|
|
36
43
|
export declare function gestureStart(handles: readonly EditingElementHandle[]): {
|
|
37
44
|
elements: Array<EditingGestureStart | null>;
|
|
@@ -113,6 +113,17 @@ function tweensOn(element) {
|
|
|
113
113
|
return timelines.flatMap((timeline) => (timeline?.getChildren?.(true) ?? []).filter((tween) => (tween.targets?.() ?? []).some((target) => target === element || (!!element.id && target?.id === element.id))));
|
|
114
114
|
}
|
|
115
115
|
const rendersTransform = (element) => !!element._gsap?.renderTransform;
|
|
116
|
+
export function gestureBase(handle) {
|
|
117
|
+
const element = elementForHandle(handle);
|
|
118
|
+
const gsap = window.gsap;
|
|
119
|
+
if (!element)
|
|
120
|
+
return null;
|
|
121
|
+
if (!gsap?.getProperty)
|
|
122
|
+
return { x: 0, y: 0, opacity: 1, scale: 1 };
|
|
123
|
+
const read = (property) => Number(gsap.getProperty?.(element, property));
|
|
124
|
+
const base = { x: read("x"), y: read("y"), opacity: read("opacity"), scale: read("scaleX") };
|
|
125
|
+
return Object.values(base).every(Number.isFinite) ? base : null;
|
|
126
|
+
}
|
|
116
127
|
// Read only once GSAP owns it: asking GSAP for x makes it fold a CSS translate into its transform.
|
|
117
128
|
const readGsap = (element, property) => Number(window.gsap?.getProperty?.(element, property)) || 0;
|
|
118
129
|
/** GSAP's x/y when it owns the element's position: it renders its transform, or a tween writes it. */
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { buildStableSelector, MAX_DESCRIBE_HANDLES, MAX_ELEMENT_ENTRIES, MAX_ELEMENT_TEXT, MAX_ELEMENT_VALUE, MAX_POINT_STACK, MAX_QUERY_MATCHES, MAX_SOURCE_GROUPS, readElementSource, } from "./editingElement.js";
|
|
7
7
|
import { buildElementLabel, NO_TEXT, renderedTextOf } from "./elementLabel.js";
|
|
8
|
+
import { isEditableText } from "./editing/textMarkup.js";
|
|
8
9
|
// Drawn on first use, not at load: a render seeds getRandomValues, and a draw here would shift the
|
|
9
10
|
// composition's own random values.
|
|
10
11
|
let load = "";
|
|
@@ -158,6 +159,7 @@ function describeElement(element) {
|
|
|
158
159
|
text: renderedText(element, state),
|
|
159
160
|
children: children(element, state),
|
|
160
161
|
truncated: state.truncated,
|
|
162
|
+
textMarkup: isEditableText(element),
|
|
161
163
|
};
|
|
162
164
|
}
|
|
163
165
|
export function elementsAtPoint(x, y) {
|
|
@@ -13,7 +13,7 @@ import type { RestoreAttributesParams } from "./editing/restoreAttributes.js";
|
|
|
13
13
|
import { type EditingGeometryEvent, type WatchGeometryParams } from "./editing/watchGeometry.js";
|
|
14
14
|
import { MAX_DRAFT_PX, type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch } from "./editingElement.js";
|
|
15
15
|
import type { EditingElementBox, EditingElementGeometry } from "./editingGeometry.js";
|
|
16
|
-
import type { EditingGestureStart } from "./editingGestureStart.js";
|
|
16
|
+
import type { EditingGestureBase, EditingGestureStart } from "./editingGestureStart.js";
|
|
17
17
|
import type { GsapSnapshot } from "./editing/gsapSnapshot.js";
|
|
18
18
|
import type { MotionPathFrameHome } from "./editing/motionPathHome.js";
|
|
19
19
|
import type { EditingLayer, EditingStackingSibling } from "./editingLayers.js";
|
|
@@ -36,7 +36,7 @@ import { type EditElementParams, type EditElementResult } from "./editing/editEl
|
|
|
36
36
|
import { type TextEditEndedEvent, type TextEditParams, type TextEditResult } from "./editing/textEdit.js";
|
|
37
37
|
export { buildStableSelector, escapeCssString, getPreferredClassSelector, isEditableTextLeaf, readElementSource, readTextLayer, EDITING_ELEMENT_HANDLE, MAX_DESCRIBE_HANDLES, MAX_ELEMENT_ENTRIES, MAX_ELEMENT_TEXT, MAX_ELEMENT_VALUE, MAX_TIMELINE_TEXT, MAX_POINT_STACK, MAX_QUERY_MATCHES, MAX_SOURCE_GROUPS, type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch, type EditingElementSource, type EditingRect, type TextLayerRead, } from "./editingElement.js";
|
|
38
38
|
export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTransformSnapshot, rotationDegreesFromMatrix, snapCandidates, MAX_GEOMETRY_CHILDREN, MAX_SNAP_TARGETS, ROTATION_GATE_EPSILON_DEG, type EditingCorner, type EditingCorners, type EditingElementBox, type EditingElementGeometry, type ElementTransformSnapshot, } from "./editingGeometry.js";
|
|
39
|
-
export type { EditingGestureStart } from "./editingGestureStart.js";
|
|
39
|
+
export type { EditingGestureBase, EditingGestureStart } from "./editingGestureStart.js";
|
|
40
40
|
export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
|
|
41
41
|
export { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_SNAPSHOT_TEXT, MAX_SNAPSHOT_TWEENS, MAX_VARS_DEPTH, } from "./editing/gsapSnapshotLimits.js";
|
|
42
42
|
export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, type EditingLocalPointer, type EditingViewport, } from "./editingTargets.js";
|
|
@@ -46,7 +46,7 @@ export declare const EDITING_PROTOCOL_VERSION: 1;
|
|
|
46
46
|
export declare const EDITING_CONNECT = "editing-connect";
|
|
47
47
|
/** Frame to parent, on the window: carries the port in its transfer list. */
|
|
48
48
|
export declare const EDITING_PORT = "editing-port";
|
|
49
|
-
export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "elements-at-point", "pointer-targets", "describe", "ancestors", "query", "geometry", "layers", "draft", "gesture-start", "console-errors", "watch-keys", "restore-attributes", "caption-words", "caption-transform", "color-grading-status", "color-grading-previews", "color-grading-playback", "watch-geometry", "audio-meter", "document-markup", "set-audio-group-attribute", "assign-audio-group", "gsap-snapshot", "motion-path-home", "max-z-index", "crop-lift", "edit-element", "stacking-family", "gsap-set", "patch-tweens", "soft-reload", "hold-scenes", "mark-scenes-stale", "swap-scenes", "live-retime", "assets-unloaded", "text-edit", "serve-paused-frames"];
|
|
49
|
+
export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "elements-at-point", "pointer-targets", "describe", "ancestors", "query", "geometry", "layers", "draft", "gesture-start", "gesture-base", "console-errors", "watch-keys", "restore-attributes", "caption-words", "caption-transform", "color-grading-status", "color-grading-previews", "color-grading-playback", "watch-geometry", "audio-meter", "document-markup", "set-audio-group-attribute", "assign-audio-group", "gsap-snapshot", "motion-path-home", "max-z-index", "crop-lift", "edit-element", "stacking-family", "gsap-set", "patch-tweens", "soft-reload", "hold-scenes", "mark-scenes-stale", "swap-scenes", "live-retime", "assets-unloaded", "text-edit", "serve-paused-frames"];
|
|
50
50
|
export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
|
|
51
51
|
export interface EditingRuntimeSnapshot {
|
|
52
52
|
/** The runtime has installed its player API. */
|
|
@@ -59,6 +59,7 @@ export interface EditingRuntimeSnapshot {
|
|
|
59
59
|
clipParents: Array<[string, string]>;
|
|
60
60
|
}
|
|
61
61
|
export { MAX_DRAFT_PX };
|
|
62
|
+
export declare const EDITING_REQUEST_TIMEOUT_MS = 5000;
|
|
62
63
|
export declare const MAX_DRAFT_DEG = 36000;
|
|
63
64
|
export declare const MAX_WATCHED_KEYS = 32;
|
|
64
65
|
/** A keystroke the frame forwards for `watch-keys`, as an unasked port message with no id. */
|
|
@@ -231,6 +232,14 @@ export interface EditingRequests {
|
|
|
231
232
|
snap: EditingElementBox[];
|
|
232
233
|
};
|
|
233
234
|
};
|
|
235
|
+
"gesture-base": {
|
|
236
|
+
params: {
|
|
237
|
+
handles: EditingElementHandle[];
|
|
238
|
+
};
|
|
239
|
+
result: {
|
|
240
|
+
elements: Array<EditingGestureBase | null>;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
234
243
|
"console-errors": {
|
|
235
244
|
params: {
|
|
236
245
|
from: number;
|
|
@@ -467,5 +476,5 @@ export declare function createEditingPortClient(options: {
|
|
|
467
476
|
host?: Window;
|
|
468
477
|
}): EditingPortClient;
|
|
469
478
|
export { elementHome, transformWDivisor, type MotionPathHome } from "./editing/motionPathHome.js";
|
|
470
|
-
export type
|
|
479
|
+
export { caretRangeAt, takePlainTextOnly, textEditResult, type TextEditEndedEvent, type TextEditResult, } from "./editing/textEdit.js";
|
|
471
480
|
export { parsePausedFrameAsk, PAUSED_FRAME_BYTES, PAUSED_FRAME_PARAMS, PAUSED_FRAME_SOURCES, type PausedFrameAsk, type PausedFrameAskMessage, type PausedFrameImage, type PausedFrameReply, } from "./editing/pausedFrames.js";
|
|
@@ -44,6 +44,7 @@ export const EDITING_REQUEST_KINDS = [
|
|
|
44
44
|
"layers",
|
|
45
45
|
"draft",
|
|
46
46
|
"gesture-start",
|
|
47
|
+
"gesture-base",
|
|
47
48
|
"console-errors",
|
|
48
49
|
"watch-keys",
|
|
49
50
|
"restore-attributes",
|
|
@@ -75,6 +76,7 @@ export const EDITING_REQUEST_KINDS = [
|
|
|
75
76
|
"serve-paused-frames",
|
|
76
77
|
];
|
|
77
78
|
export { MAX_DRAFT_PX };
|
|
79
|
+
export const EDITING_REQUEST_TIMEOUT_MS = 5_000;
|
|
78
80
|
export const MAX_DRAFT_DEG = 36_000;
|
|
79
81
|
export const MAX_WATCHED_KEYS = 32;
|
|
80
82
|
export function isPlainRecord(value) {
|
|
@@ -252,6 +254,7 @@ const PARAM_PARSERS = {
|
|
|
252
254
|
layers: (params) => noParams(params) ?? layerParams(params),
|
|
253
255
|
draft: draftList,
|
|
254
256
|
"gesture-start": handleList,
|
|
257
|
+
"gesture-base": handleList,
|
|
255
258
|
"console-errors": (params) => hasKeys(params, "from") && isOffset(params.from) ? { from: params.from } : null,
|
|
256
259
|
"watch-keys": comboList,
|
|
257
260
|
"restore-attributes": parseRestoreAttributesRerun,
|
|
@@ -347,7 +350,7 @@ const portsTaken = new WeakSet();
|
|
|
347
350
|
* that frame sends. Replies are data from the frame, so callers validate results.
|
|
348
351
|
*/
|
|
349
352
|
export function createEditingPortClient(options) {
|
|
350
|
-
const { iframe, timeoutMs =
|
|
353
|
+
const { iframe, timeoutMs = EDITING_REQUEST_TIMEOUT_MS, host = window } = options;
|
|
351
354
|
const pending = new Map();
|
|
352
355
|
const keyListeners = new Set();
|
|
353
356
|
const geometryListeners = new Set();
|
|
@@ -475,4 +478,5 @@ export function createEditingPortClient(options) {
|
|
|
475
478
|
};
|
|
476
479
|
}
|
|
477
480
|
export { elementHome, transformWDivisor } from "./editing/motionPathHome.js";
|
|
481
|
+
export { caretRangeAt, takePlainTextOnly, textEditResult, } from "./editing/textEdit.js";
|
|
478
482
|
export { parsePausedFrameAsk, PAUSED_FRAME_BYTES, PAUSED_FRAME_PARAMS, PAUSED_FRAME_SOURCES, } from "./editing/pausedFrames.js";
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -147,6 +147,13 @@ export type RuntimeStageSizeMessage = {
|
|
|
147
147
|
type: "stage-size";
|
|
148
148
|
width: number;
|
|
149
149
|
height: number;
|
|
150
|
+
} | {
|
|
151
|
+
source: "hf-preview";
|
|
152
|
+
type: "stage-size";
|
|
153
|
+
measuredSize: {
|
|
154
|
+
width: number;
|
|
155
|
+
height: number;
|
|
156
|
+
};
|
|
150
157
|
};
|
|
151
158
|
/**
|
|
152
159
|
* Fired once per session when the runtime's attempt to play a timed media
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.87",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -501,9 +501,9 @@
|
|
|
501
501
|
"linkedom": "^0.18.12",
|
|
502
502
|
"postcss": "^8.5.8",
|
|
503
503
|
"wawoff2": "^2.0.1",
|
|
504
|
-
"@hyperframes/lint": "0.9.
|
|
505
|
-
"@hyperframes/parsers": "0.9.
|
|
506
|
-
"@hyperframes/studio-server": "0.9.
|
|
504
|
+
"@hyperframes/lint": "0.9.87",
|
|
505
|
+
"@hyperframes/parsers": "0.9.87",
|
|
506
|
+
"@hyperframes/studio-server": "0.9.87"
|
|
507
507
|
},
|
|
508
508
|
"devDependencies": {
|
|
509
509
|
"@fontsource/archivo-black": "^5.2.8",
|