@hyperframes/core 0.9.91 → 0.9.92
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/audioAnalysis.d.ts +3 -0
- package/dist/audioAnalysis.js +18 -1
- package/dist/audioCarve.js +15 -24
- package/dist/audioDecode.d.ts +22 -0
- package/dist/audioDecode.js +64 -0
- package/dist/audioLeveller.js +3 -17
- package/dist/beats/beatDetection.js +2 -3
- package/dist/compositionSource.d.ts +2 -0
- package/dist/compositionSource.js +5 -0
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/runtime/editing/gsapSet.d.ts +3 -1
- package/dist/runtime/editing/gsapSet.js +4 -2
- package/dist/runtime/editing/gsapSnapshot.js +13 -3
- package/dist/runtime/editingElement.js +8 -7
- package/dist/runtime/editingGestureStart.d.ts +3 -0
- package/dist/runtime/editingGestureStart.js +46 -3
- package/dist/runtime/editingPort.d.ts +23 -2
- package/dist/runtime/editingPort.js +18 -1
- package/dist/runtime/positionEdits.js +2 -2
- package/dist/safePath.d.ts +5 -1
- package/dist/safePath.js +38 -4
- package/dist/studioPreviewMark.d.ts +1 -0
- package/dist/studioPreviewMark.js +1 -0
- package/dist/utils/htmlAttrSafety.js +7 -1
- package/dist/utils/richTextSanitize.js +16 -2
- package/package.json +8 -4
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type EditingElementHandle } from "../editingElement.js";
|
|
2
|
+
import type { EditingDraft } from "../editingPort.js";
|
|
2
3
|
export type GsapSetParams = {
|
|
3
4
|
handle: EditingElementHandle;
|
|
4
5
|
props: Record<string, number>;
|
|
6
|
+
drafts?: EditingDraft[];
|
|
5
7
|
};
|
|
6
8
|
export declare function parseGsapSet(params: unknown): GsapSetParams | null;
|
|
7
|
-
export declare function gsapSet({ handle, props }: GsapSetParams): {
|
|
9
|
+
export declare function gsapSet({ handle, props, drafts }: GsapSetParams): {
|
|
8
10
|
applied: boolean;
|
|
9
11
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Studio's live value preview (a 3D-transform slider mid-drag) in a frame it cannot script.
|
|
2
|
+
import { drawDrafts, rebaseDrawnPosition } from "../editingDraft.js";
|
|
2
3
|
import { EDITING_ELEMENT_HANDLE } from "../editingElement.js";
|
|
3
4
|
import { elementForHandle } from "../editingHandles.js";
|
|
4
|
-
import { rebaseDrawnPosition } from "../editingDraft.js";
|
|
5
5
|
const GSAP_SET_CHANNELS = new Set([
|
|
6
6
|
"x",
|
|
7
7
|
"y",
|
|
@@ -29,7 +29,9 @@ export function parseGsapSet(params) {
|
|
|
29
29
|
const valid = entries.every(([channel, value]) => GSAP_SET_CHANNELS.has(channel) && typeof value === "number" && Number.isFinite(value));
|
|
30
30
|
return valid && entries.length > 0 ? { handle, props: props } : null;
|
|
31
31
|
}
|
|
32
|
-
export function gsapSet({ handle, props }) {
|
|
32
|
+
export function gsapSet({ handle, props, drafts }) {
|
|
33
|
+
if (drafts)
|
|
34
|
+
drawDrafts(drafts);
|
|
33
35
|
const element = elementForHandle(handle);
|
|
34
36
|
const gsap = window.gsap;
|
|
35
37
|
if (!element || typeof gsap?.set !== "function")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { handleFor } from "../editingHandles.js";
|
|
2
|
+
import { MOVES, rendersTransform, withoutGsapTakeover } from "../editingGestureStart.js";
|
|
2
3
|
import { isPlainRecord } from "../editingPort.js";
|
|
3
4
|
import { isElementNode } from "../domRealm.js";
|
|
4
5
|
import { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_SNAPSHOT_TEXT, MAX_SNAPSHOT_TWEENS, MAX_VARS_DEPTH, } from "./gsapSnapshotLimits.js";
|
|
@@ -76,11 +77,20 @@ class SnapshotReader {
|
|
|
76
77
|
if (channels.size > MAX_SNAPSHOT_CHANNELS)
|
|
77
78
|
throw new SnapshotBound("channels");
|
|
78
79
|
const values = {};
|
|
79
|
-
|
|
80
|
+
const read = (channel) => {
|
|
80
81
|
const value = Number(gsap?.getProperty?.(element, channel));
|
|
81
82
|
if (Number.isFinite(value))
|
|
82
83
|
values[channel] = value;
|
|
83
|
-
}
|
|
84
|
+
};
|
|
85
|
+
const gsapOwnsPosition = rendersTransform(element) || MOVES.some((channel) => channels.has(channel));
|
|
86
|
+
withoutGsapTakeover(element, () => {
|
|
87
|
+
for (const channel of channels)
|
|
88
|
+
read(channel);
|
|
89
|
+
if (gsapOwnsPosition)
|
|
90
|
+
for (const axis of ["x", "y"])
|
|
91
|
+
if (!(axis in values))
|
|
92
|
+
read(axis);
|
|
93
|
+
});
|
|
84
94
|
const className = element.getAttribute("class") ?? "";
|
|
85
95
|
if (className.length > MAX_SNAPSHOT_TEXT)
|
|
86
96
|
throw new SnapshotBound("class names");
|
|
@@ -88,7 +98,7 @@ class SnapshotReader {
|
|
|
88
98
|
});
|
|
89
99
|
}
|
|
90
100
|
note(element, vars, parsed, parts) {
|
|
91
|
-
const channels = this.channels.get(element) ?? new Set(
|
|
101
|
+
const channels = this.channels.get(element) ?? new Set();
|
|
92
102
|
this.channels.set(element, channels);
|
|
93
103
|
const steps = isPlainRecord(vars) ? [vars, ...stepsOf(vars.keyframes)] : [];
|
|
94
104
|
for (const step of steps)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// How an element is addressed in source: one rule for Studio and the runtime's editing agent.
|
|
2
|
+
import { COMPOSITION_ROOT_ATTRS, SOURCE_HOST_ATTRS } from "../compositionSource.js";
|
|
2
3
|
import { isHtmlElement } from "./domRealm.js";
|
|
3
4
|
export const EDITING_ELEMENT_HANDLE = /^[0-9a-f]{16}:[1-9][0-9]{0,14}$/;
|
|
4
5
|
export const MAX_ELEMENT_ENTRIES = 256;
|
|
@@ -118,13 +119,13 @@ function closestWithAny(el, names) {
|
|
|
118
119
|
return null;
|
|
119
120
|
}
|
|
120
121
|
export function readElementSource(el) {
|
|
121
|
-
const
|
|
122
|
-
const
|
|
122
|
+
const [fileAttr, srcAttr] = SOURCE_HOST_ATTRS;
|
|
123
|
+
const [idAttr, originalIdAttr] = COMPOSITION_ROOT_ATTRS;
|
|
124
|
+
const host = closestWithAny(el, SOURCE_HOST_ATTRS);
|
|
125
|
+
const root = closestWithAny(el, [idAttr]);
|
|
123
126
|
return {
|
|
124
|
-
file: host?.getAttribute(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
compositionId: root?.getAttribute("data-composition-id") ?? null,
|
|
128
|
-
originalCompositionId: root?.getAttribute("data-hf-original-composition-id") ?? null,
|
|
127
|
+
file: host?.getAttribute(fileAttr) ?? host?.getAttribute(srcAttr) ?? null,
|
|
128
|
+
compositionId: root?.getAttribute(idAttr) ?? null,
|
|
129
|
+
originalCompositionId: root?.getAttribute(originalIdAttr) ?? null,
|
|
129
130
|
};
|
|
130
131
|
}
|
|
@@ -33,6 +33,9 @@ export interface EditingGestureStart extends EditingElementGeometry {
|
|
|
33
33
|
d: number;
|
|
34
34
|
} | null;
|
|
35
35
|
}
|
|
36
|
+
export declare const MOVES: string[];
|
|
37
|
+
export declare const rendersTransform: (element: Element) => boolean;
|
|
38
|
+
export declare function withoutGsapTakeover<T>(element: Element, read: () => T): T;
|
|
36
39
|
export type EditingGestureBase = {
|
|
37
40
|
x: number;
|
|
38
41
|
y: number;
|
|
@@ -86,7 +86,7 @@ function measureGrowResponse(element, layout) {
|
|
|
86
86
|
}
|
|
87
87
|
// The channels Studio's move route and drag commit read as GSAP moving an element.
|
|
88
88
|
const POSITION = ["x", "y", "xPercent", "yPercent", "left", "top", "translateX", "translateY"];
|
|
89
|
-
const MOVES = [...POSITION, "motionPath"];
|
|
89
|
+
export const MOVES = [...POSITION, "motionPath"];
|
|
90
90
|
const TURNS = [
|
|
91
91
|
"rotation",
|
|
92
92
|
"rotationX",
|
|
@@ -112,7 +112,48 @@ function tweensOn(element) {
|
|
|
112
112
|
const timelines = Object.values(window.__timelines ?? {});
|
|
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
|
-
const rendersTransform = (element) => !!element._gsap?.renderTransform;
|
|
115
|
+
export const rendersTransform = (element) => !!element._gsap?.renderTransform;
|
|
116
|
+
const isPlainFields = (value) => !!value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
|
|
117
|
+
function keptFields(fields, depth = 1) {
|
|
118
|
+
const values = { ...fields };
|
|
119
|
+
const nested = depth > 0 ? Object.values(fields).filter(isPlainFields) : [];
|
|
120
|
+
const inner = nested.map((value) => keptFields(value, depth - 1));
|
|
121
|
+
return () => {
|
|
122
|
+
for (const key of Object.keys(fields))
|
|
123
|
+
if (!(key in values))
|
|
124
|
+
Reflect.deleteProperty(fields, key);
|
|
125
|
+
Object.assign(fields, values);
|
|
126
|
+
for (const restore of inner)
|
|
127
|
+
restore();
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function keptAttributes(element) {
|
|
131
|
+
const names = element.getAttributeNames();
|
|
132
|
+
const attributes = new Map(names.map((name) => [name, element.getAttribute(name) ?? ""]));
|
|
133
|
+
return () => {
|
|
134
|
+
for (const name of element.getAttributeNames())
|
|
135
|
+
if (!attributes.has(name))
|
|
136
|
+
element.removeAttribute(name);
|
|
137
|
+
for (const [name, value] of attributes)
|
|
138
|
+
if (element.getAttribute(name) !== value)
|
|
139
|
+
element.setAttribute(name, value);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function withoutGsapTakeover(element, read) {
|
|
143
|
+
if (rendersTransform(element))
|
|
144
|
+
return read();
|
|
145
|
+
const host = element;
|
|
146
|
+
const cache = host._gsap;
|
|
147
|
+
const restoreCache = cache ? keptFields(cache) : () => Reflect.deleteProperty(host, "_gsap");
|
|
148
|
+
const restoreAttributes = keptAttributes(element);
|
|
149
|
+
try {
|
|
150
|
+
return read();
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
restoreAttributes();
|
|
154
|
+
restoreCache();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
116
157
|
export function gestureBase(handle) {
|
|
117
158
|
const element = elementForHandle(handle);
|
|
118
159
|
const gsap = window.gsap;
|
|
@@ -136,7 +177,9 @@ function gsapPosition(element) {
|
|
|
136
177
|
}
|
|
137
178
|
function gsapRotation(element) {
|
|
138
179
|
const turned = tweensOn(element).some((tween) => tween.vars && carries(tween.vars, TURNS));
|
|
139
|
-
|
|
180
|
+
if (!rendersTransform(element) && !turned)
|
|
181
|
+
return null;
|
|
182
|
+
return withoutGsapTakeover(element, () => readGsap(element, "rotation"));
|
|
140
183
|
}
|
|
141
184
|
function planarOf(element) {
|
|
142
185
|
const matrix = readElementTransformSnapshot(window, element)?.matrix;
|
|
@@ -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", "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"];
|
|
49
|
+
export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "authored-styles", "font-faces", "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. */
|
|
@@ -150,6 +150,25 @@ export interface EditingRequests {
|
|
|
150
150
|
styles: Record<string, string> | null;
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
|
+
"authored-styles": {
|
|
154
|
+
params: {
|
|
155
|
+
handle: EditingElementHandle;
|
|
156
|
+
properties: string[];
|
|
157
|
+
};
|
|
158
|
+
result: {
|
|
159
|
+
styles: Record<string, string> | null;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
"font-faces": {
|
|
163
|
+
params: NoParams;
|
|
164
|
+
result: {
|
|
165
|
+
families: string[];
|
|
166
|
+
ownFaces: Array<{
|
|
167
|
+
family: string;
|
|
168
|
+
src: string;
|
|
169
|
+
}>;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
153
172
|
/** The stack under a viewport point, topmost first, up to MAX_POINT_STACK. Describe one to keep. */
|
|
154
173
|
"elements-at-point": {
|
|
155
174
|
params: {
|
|
@@ -228,7 +247,9 @@ export interface EditingRequests {
|
|
|
228
247
|
params: {
|
|
229
248
|
drafts: EditingDraft[];
|
|
230
249
|
};
|
|
231
|
-
result: EditingDraftReply
|
|
250
|
+
result: EditingDraftReply & {
|
|
251
|
+
gsapSetTakesDrafts?: true;
|
|
252
|
+
};
|
|
232
253
|
};
|
|
233
254
|
"gesture-start": {
|
|
234
255
|
params: {
|
|
@@ -35,6 +35,8 @@ export const EDITING_REQUEST_KINDS = [
|
|
|
35
35
|
"wait-for-seek",
|
|
36
36
|
"set-loop-start",
|
|
37
37
|
"computed-styles",
|
|
38
|
+
"authored-styles",
|
|
39
|
+
"font-faces",
|
|
38
40
|
"elements-at-point",
|
|
39
41
|
"pointer-targets",
|
|
40
42
|
"describe",
|
|
@@ -214,6 +216,14 @@ function draftPropsWithOneXYWriter(value, translate) {
|
|
|
214
216
|
return false;
|
|
215
217
|
return entries.every(isDraftValue);
|
|
216
218
|
}
|
|
219
|
+
function gsapSetWithDrafts(params) {
|
|
220
|
+
if (!isPlainRecord(params) || !("drafts" in params))
|
|
221
|
+
return parseGsapSet(params);
|
|
222
|
+
const { drafts, ...set } = params;
|
|
223
|
+
const parsed = parseGsapSet(set);
|
|
224
|
+
const drawn = draftList({ drafts });
|
|
225
|
+
return parsed && drawn ? { ...parsed, drafts: drawn.drafts } : null;
|
|
226
|
+
}
|
|
217
227
|
function draftList(params) {
|
|
218
228
|
if (!hasKeys(params, "drafts") || !Array.isArray(params.drafts))
|
|
219
229
|
return null;
|
|
@@ -269,6 +279,13 @@ const PARAM_PARSERS = {
|
|
|
269
279
|
const properties = styleProperties(params.properties);
|
|
270
280
|
return target && properties ? { ...target, properties } : null;
|
|
271
281
|
},
|
|
282
|
+
"authored-styles": (params) => {
|
|
283
|
+
if (!hasKeys(params, "handle,properties") || !isHandle(params.handle))
|
|
284
|
+
return null;
|
|
285
|
+
const properties = styleProperties(params.properties);
|
|
286
|
+
return properties?.length ? { handle: params.handle, properties } : null;
|
|
287
|
+
},
|
|
288
|
+
"font-faces": noParams,
|
|
272
289
|
"elements-at-point": point,
|
|
273
290
|
"pointer-targets": point,
|
|
274
291
|
describe: handleList,
|
|
@@ -312,7 +329,7 @@ const PARAM_PARSERS = {
|
|
|
312
329
|
: null,
|
|
313
330
|
"edit-element": parseEditElement,
|
|
314
331
|
"stacking-family": (params) => hasKeys(params, "handle") && isHandle(params.handle) ? { handle: params.handle } : null,
|
|
315
|
-
"gsap-set":
|
|
332
|
+
"gsap-set": gsapSetWithDrafts,
|
|
316
333
|
"patch-tweens": parsePatchTweensRequest,
|
|
317
334
|
"soft-reload": parseSoftReload,
|
|
318
335
|
"hold-scenes": parseHoldScenes,
|
|
@@ -79,8 +79,8 @@ export const composeTranslate = (original, x, y) => {
|
|
|
79
79
|
* the edit translate is written. GSAP folds a CSS `translate` it sees at an
|
|
80
80
|
* element's first parse into its cached transform (losing it per-axis on
|
|
81
81
|
* absolute tweens); once the cache exists, later tweens and positioned set()s
|
|
82
|
-
* reuse it and never read the translate again.
|
|
83
|
-
*
|
|
82
|
+
* reuse it and never read the translate again. The parse also writes the
|
|
83
|
+
* folded transform onto the element. Best-effort — absent or failing GSAP is fine.
|
|
84
84
|
*/
|
|
85
85
|
const primeGsapTransformCache = (el) => {
|
|
86
86
|
try {
|
package/dist/safePath.d.ts
CHANGED
|
@@ -62,5 +62,9 @@ export declare function realFilePath(filePath: string): string;
|
|
|
62
62
|
export type EntryKind = "file" | "folder";
|
|
63
63
|
/** A script only Node runs, whatever folder holds it. */
|
|
64
64
|
export declare function nodeOnlyScript(relPath: string): boolean;
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* A Node-only script, or below (at any depth, past the project too) a package.json that is not the scaffold's: a
|
|
67
|
+
* `.js`/`.mjs` file, an extensionless file, or a file Node resolves before the module of its name plus an extension
|
|
68
|
+
* beside it.
|
|
69
|
+
*/
|
|
66
70
|
export declare function nodeMayRun(projectDir: string, relPath: string, kind: EntryKind): boolean;
|
package/dist/safePath.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { resolve, sep, join, dirname, basename, relative, isAbsolute, parse } from "node:path";
|
|
2
|
-
import { lstatSync, mkdirSync, readFileSync, realpath as realpathWalk, realpathSync, statSync, } from "node:fs";
|
|
2
|
+
import { lstatSync, mkdirSync, readdirSync, readFileSync, realpath as realpathWalk, realpathSync, statSync, } from "node:fs";
|
|
3
3
|
import { realpath as realpathNative } from "node:fs/promises";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
|
+
import { isWithinProjectRoot } from "@hyperframes/parsers/asset-resolution";
|
|
5
6
|
import { projectPathSegments } from "@hyperframes/parsers/private-path";
|
|
6
7
|
export { isCredentialOrToolStatePath, isPrivateFileUnder, isStudioPrivatePath, isVcsOrSecretPath, projectPathSegments, } from "@hyperframes/parsers/private-path";
|
|
7
8
|
// Some Windows volumes (RAM disks) refuse the native realpath with EISDIR; the JS walk still resolves there.
|
|
@@ -75,6 +76,8 @@ export function isSafePath(base, resolved) {
|
|
|
75
76
|
// Base must exist and be resolvable; fail closed if not.
|
|
76
77
|
return false;
|
|
77
78
|
}
|
|
79
|
+
if (!isWithinProjectRoot(base, target) && !isWithinProjectRoot(baseReal, target))
|
|
80
|
+
return false;
|
|
78
81
|
const trailing = [];
|
|
79
82
|
let probe = target;
|
|
80
83
|
for (;;) {
|
|
@@ -312,17 +315,48 @@ const isExtensionless = (name) => name !== "" && !name.includes(".");
|
|
|
312
315
|
export function nodeOnlyScript(relPath) {
|
|
313
316
|
return NODE_ONLY_SCRIPT.test(foldedPath(relPath).split("/").at(-1) ?? "");
|
|
314
317
|
}
|
|
315
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* A Node-only script, or below (at any depth, past the project too) a package.json that is not the scaffold's: a
|
|
320
|
+
* `.js`/`.mjs` file, an extensionless file, or a file Node resolves before the module of its name plus an extension
|
|
321
|
+
* beside it.
|
|
322
|
+
*/
|
|
316
323
|
export function nodeMayRun(projectDir, relPath, kind) {
|
|
317
324
|
if (nodeOnlyScript(relPath))
|
|
318
325
|
return true;
|
|
319
326
|
const name = foldedPath(relPath).split("/").at(-1) ?? "";
|
|
320
|
-
const
|
|
327
|
+
const folder = dirname(resolve(projectDir, relPath));
|
|
328
|
+
const sharedWithNode = BROWSER_OR_NODE_SCRIPT.test(name) ||
|
|
329
|
+
(kind === "file" && (isExtensionless(name) || shadowsModuleIn(folder, name)));
|
|
321
330
|
if (!sharedWithNode)
|
|
322
331
|
return false;
|
|
323
|
-
const folder = dirname(resolve(projectDir, relPath));
|
|
324
332
|
return [folder, realFilePath(folder)].some((from) => foldersUp(from).some(manifestBringsNode));
|
|
325
333
|
}
|
|
334
|
+
const MODULE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx", "json", "node"];
|
|
335
|
+
const shadowsModuleIn = (folder, name) => name !== "" &&
|
|
336
|
+
[folder, realFilePath(folder)].some((at) => {
|
|
337
|
+
const entries = foldedEntriesOf(at);
|
|
338
|
+
return MODULE_EXTENSIONS.some((extension) => entries.has(`${name}.${extension}`));
|
|
339
|
+
});
|
|
340
|
+
const folderEntryCache = new Map();
|
|
341
|
+
function foldedEntriesOf(folder) {
|
|
342
|
+
const stat = statSync(folder, { throwIfNoEntry: false });
|
|
343
|
+
if (!stat?.isDirectory())
|
|
344
|
+
return new Set();
|
|
345
|
+
const key = `${stat.ino}:${stat.mtimeMs}`;
|
|
346
|
+
const cached = folderEntryCache.get(folder);
|
|
347
|
+
if (cached?.stat === key)
|
|
348
|
+
return cached.names;
|
|
349
|
+
let listed = [];
|
|
350
|
+
try {
|
|
351
|
+
listed = readdirSync(folder);
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
// expected: a folder that cannot be listed has no module beside the name to shadow
|
|
355
|
+
}
|
|
356
|
+
const names = new Set(listed.map(foldedPath));
|
|
357
|
+
folderEntryCache.set(folder, { stat: key, names });
|
|
358
|
+
return names;
|
|
359
|
+
}
|
|
326
360
|
function foldersUp(from) {
|
|
327
361
|
const parent = dirname(from);
|
|
328
362
|
return parent === from ? [from] : [from, ...foldersUp(parent)];
|
|
@@ -21,6 +21,7 @@ export declare function captureStillsIn(doc: Document): boolean;
|
|
|
21
21
|
export declare const STUDIO_PREVIEW_UPCOMING_ATTR = "data-hf-upcoming";
|
|
22
22
|
export declare const STUDIO_PREVIEW_LAZY_ATTR = "data-hf-preview-lazy";
|
|
23
23
|
export declare const STUDIO_PREVIEW_ERRORS = "__hfPreviewErrors";
|
|
24
|
+
export declare const STUDIO_PREVIEW_ERROR_MESSAGE = "preview-error";
|
|
24
25
|
export declare const STUDIO_PREVIEW_ERROR_KINDS = "__hfPreviewErrorKinds";
|
|
25
26
|
export declare function previewConsoleErrorText(args: readonly unknown[]): string | null;
|
|
26
27
|
export declare const refusedPreviewMessage: (status: number) => string;
|
|
@@ -49,6 +49,7 @@ export function captureStillsIn(doc) {
|
|
|
49
49
|
export const STUDIO_PREVIEW_UPCOMING_ATTR = "data-hf-upcoming";
|
|
50
50
|
export const STUDIO_PREVIEW_LAZY_ATTR = "data-hf-preview-lazy";
|
|
51
51
|
export const STUDIO_PREVIEW_ERRORS = "__hfPreviewErrors";
|
|
52
|
+
export const STUDIO_PREVIEW_ERROR_MESSAGE = "preview-error";
|
|
52
53
|
export const STUDIO_PREVIEW_ERROR_KINDS = "__hfPreviewErrorKinds";
|
|
53
54
|
export function previewConsoleErrorText(args) {
|
|
54
55
|
const text = args.map((a) => (a instanceof Error ? a.message : String(a))).join(" ");
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* used by sourceMutation (core), sdkCutover (studio), and mutate (sdk).
|
|
6
6
|
*/
|
|
7
7
|
import { SVG_ATTRIBUTES, SVG_ELEMENTS } from "./svgAllowlist.js";
|
|
8
|
-
import { CODE_LOADING_ATTRS } from "../compositionSource.js";
|
|
8
|
+
import { CODE_LOADING_ATTRS, COMPOSITION_ROOT_ATTRS, SOURCE_HOST_ATTRS, } from "../compositionSource.js";
|
|
9
9
|
export const ALLOWED_HTML_ATTRS = new Set([
|
|
10
10
|
"id",
|
|
11
11
|
"class",
|
|
@@ -129,9 +129,15 @@ function elementAllowed(element, tag) {
|
|
|
129
129
|
return tag !== "style" && SVG_ELEMENTS.has(element.tagName);
|
|
130
130
|
return ELEMENTS_PARSED_ALIKE_WITH_SCRIPTING_ON.has(tag) || /^hf-[a-z0-9-]+$/.test(tag);
|
|
131
131
|
}
|
|
132
|
+
const MARKS_STUDIO_EDITS_THE_FILE_OF = new Set([
|
|
133
|
+
...SOURCE_HOST_ATTRS,
|
|
134
|
+
...COMPOSITION_ROOT_ATTRS,
|
|
135
|
+
]);
|
|
132
136
|
function attributeAllowed(element, name, value) {
|
|
133
137
|
if (!isSafeAttributeValue(name, value) || name.toLowerCase().startsWith("on"))
|
|
134
138
|
return false;
|
|
139
|
+
if (MARKS_STUDIO_EDITS_THE_FILE_OF.has(name.toLowerCase()))
|
|
140
|
+
return false;
|
|
135
141
|
if (isAllowedHtmlAttribute(name))
|
|
136
142
|
return true;
|
|
137
143
|
if (!isSvg(element))
|
|
@@ -176,14 +176,28 @@ function filterStyle(style) {
|
|
|
176
176
|
if (colon === -1)
|
|
177
177
|
return null;
|
|
178
178
|
const property = declaration.slice(0, colon).trim().toLowerCase();
|
|
179
|
-
const value = declaration.slice(colon + 1)
|
|
180
|
-
if (!isRichTextFormattingStyle(property, value))
|
|
179
|
+
const value = serializedValue(declaration.slice(colon + 1));
|
|
180
|
+
if (value === null || !isRichTextFormattingStyle(property, value))
|
|
181
181
|
return null;
|
|
182
182
|
return `${property}: ${value}`;
|
|
183
183
|
})
|
|
184
184
|
.filter((declaration) => declaration !== null)
|
|
185
185
|
.join("; ");
|
|
186
186
|
}
|
|
187
|
+
// Whitespace, a plain string, a number with its unit, a hash, a word or a function's name, a separator, !important.
|
|
188
|
+
const VALUE_TOKEN = /\s+|"[^"\\\n\r\f]*"|'[^'\\\n\r\f]*'|[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?(?:%|[a-z]+)?|#[\w-]+|-?-?[a-z_\u00a0-\uffff][\w\u00a0-\uffff-]*\(?|[(),/+*-]|!important\b/giy;
|
|
189
|
+
/** The value written out again from its tokens, or null when some of it is no token a formatting value uses. */
|
|
190
|
+
function serializedValue(value) {
|
|
191
|
+
const tokens = [];
|
|
192
|
+
VALUE_TOKEN.lastIndex = 0;
|
|
193
|
+
while (VALUE_TOKEN.lastIndex < value.length) {
|
|
194
|
+
const token = VALUE_TOKEN.exec(value)?.[0];
|
|
195
|
+
if (token === undefined)
|
|
196
|
+
return null;
|
|
197
|
+
tokens.push(/^\s/.test(token) ? " " : token);
|
|
198
|
+
}
|
|
199
|
+
return tokens.join("").trim();
|
|
200
|
+
}
|
|
187
201
|
const PLAIN_STRING = /"[^"\\\n\r\f]*"|'[^'\\\n\r\f]*'/g;
|
|
188
202
|
const withoutPlainStrings = (text) => text.replace(PLAIN_STRING, (string) => "_".repeat(string.length));
|
|
189
203
|
// Outside plain strings: an escape, a stray or broken quote, a comment, a bracket no formatting value needs.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.92",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -272,6 +272,10 @@
|
|
|
272
272
|
"import": "./dist/audioFade.js",
|
|
273
273
|
"types": "./dist/audioFade.d.ts"
|
|
274
274
|
},
|
|
275
|
+
"./audio-decode": {
|
|
276
|
+
"import": "./dist/audioDecode.js",
|
|
277
|
+
"types": "./dist/audioDecode.d.ts"
|
|
278
|
+
},
|
|
275
279
|
"./speed-ramp": {
|
|
276
280
|
"import": "./dist/speedRamp.js",
|
|
277
281
|
"types": "./dist/speedRamp.d.ts"
|
|
@@ -505,9 +509,9 @@
|
|
|
505
509
|
"linkedom": "^0.18.12",
|
|
506
510
|
"postcss": "^8.5.8",
|
|
507
511
|
"wawoff2": "^2.0.1",
|
|
508
|
-
"@hyperframes/lint": "0.9.
|
|
509
|
-
"@hyperframes/
|
|
510
|
-
"@hyperframes/
|
|
512
|
+
"@hyperframes/lint": "0.9.92",
|
|
513
|
+
"@hyperframes/parsers": "0.9.92",
|
|
514
|
+
"@hyperframes/studio-server": "0.9.92"
|
|
511
515
|
},
|
|
512
516
|
"devDependencies": {
|
|
513
517
|
"@fontsource/archivo-black": "^5.2.8",
|