@hyperframes/core 0.9.91 → 0.9.93
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/clipFacts.d.ts +5 -0
- package/dist/clipFacts.js +21 -6
- 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.d.ts +1 -0
- package/dist/runtime/editing/gsapSnapshot.js +20 -3
- package/dist/runtime/editing/textEdit.d.ts +23 -0
- package/dist/runtime/editing/textEdit.js +88 -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 +26 -4
- package/dist/runtime/editingPort.js +29 -3
- 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/inlineTextStyleRange.d.ts +33 -0
- package/dist/utils/inlineTextStyleRange.js +503 -0
- package/dist/utils/inlineTextStyleRead.d.ts +20 -0
- package/dist/utils/inlineTextStyleRead.js +72 -0
- package/dist/utils/richTextSanitize.js +16 -2
- package/package.json +12 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { readCoveredInlineStyleChars } from "./inlineTextStyleRange.js";
|
|
2
|
+
/** What the formatting toolbar shows and sets on a selection. */
|
|
3
|
+
export const INLINE_STYLE_PROPERTIES = [
|
|
4
|
+
"color",
|
|
5
|
+
"font-weight",
|
|
6
|
+
"font-style",
|
|
7
|
+
"text-decoration-line",
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* What the range is styled with, for a toolbar that has to open showing the
|
|
11
|
+
* truth rather than a default. Reports a property only when the whole range
|
|
12
|
+
* agrees about it, which is what a control can honestly display.
|
|
13
|
+
*/
|
|
14
|
+
export function readInlineStyle(range, properties) {
|
|
15
|
+
const chars = readCoveredInlineStyleChars(range);
|
|
16
|
+
if (!chars)
|
|
17
|
+
return {};
|
|
18
|
+
const styles = {};
|
|
19
|
+
for (const property of properties) {
|
|
20
|
+
const first = chars[0]?.style[property];
|
|
21
|
+
if (first === undefined)
|
|
22
|
+
continue;
|
|
23
|
+
if (chars.every(({ style }) => style[property] === first))
|
|
24
|
+
styles[property] = first;
|
|
25
|
+
}
|
|
26
|
+
return styles;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The distinct values one property takes across the range, in document order:
|
|
30
|
+
* `["red", "lime"]`.
|
|
31
|
+
*
|
|
32
|
+
* `readInlineStyle` above answers "what is this range" and reports nothing when
|
|
33
|
+
* the range disagrees with itself — right for a toggle, which can only be on or
|
|
34
|
+
* off. A swatch can show more than one value at once, and showing the default
|
|
35
|
+
* instead reads as "this text is white" when none of it is.
|
|
36
|
+
*/
|
|
37
|
+
export function readInlineStyleSpread(range, property) {
|
|
38
|
+
const covered = readCoveredInlineStyleChars(range);
|
|
39
|
+
if (!covered)
|
|
40
|
+
return [];
|
|
41
|
+
const seen = new Set();
|
|
42
|
+
const spread = [];
|
|
43
|
+
for (const { char, style, painter } of covered) {
|
|
44
|
+
// A space paints nothing, so the colour it inherits is not a colour anyone
|
|
45
|
+
// can see. Counting it puts the element's own colour in the swatch for text
|
|
46
|
+
// that shows none of it — the stray band on a selection that happens to
|
|
47
|
+
// start or end next to a space.
|
|
48
|
+
if (!char.trim())
|
|
49
|
+
continue;
|
|
50
|
+
if (style[property] === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
// As painted, where `var()` and `currentColor` mean what they mean for the text.
|
|
53
|
+
const shown = painter?.ownerDocument.defaultView
|
|
54
|
+
?.getComputedStyle(painter)
|
|
55
|
+
.getPropertyValue(property);
|
|
56
|
+
const value = shown || style[property];
|
|
57
|
+
if (seen.has(value))
|
|
58
|
+
continue;
|
|
59
|
+
seen.add(value);
|
|
60
|
+
spread.push(value);
|
|
61
|
+
}
|
|
62
|
+
return spread;
|
|
63
|
+
}
|
|
64
|
+
export function readFirstPaintedElement(range, property) {
|
|
65
|
+
const covered = readCoveredInlineStyleChars(range);
|
|
66
|
+
if (!covered)
|
|
67
|
+
return null;
|
|
68
|
+
const painted = covered.filter(({ char }) => char.trim());
|
|
69
|
+
const owner = painted.find(({ style }) => style[property] !== undefined) ?? painted[0] ?? covered[0];
|
|
70
|
+
return owner?.painter ?? null;
|
|
71
|
+
}
|
|
72
|
+
export { applyInlineStyle } from "./inlineTextStyleRange.js";
|
|
@@ -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.93",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -120,6 +120,10 @@
|
|
|
120
120
|
"import": "./dist/utils/richTextSanitize.js",
|
|
121
121
|
"types": "./dist/utils/richTextSanitize.d.ts"
|
|
122
122
|
},
|
|
123
|
+
"./inline-text-style": {
|
|
124
|
+
"import": "./dist/utils/inlineTextStyleRead.js",
|
|
125
|
+
"types": "./dist/utils/inlineTextStyleRead.d.ts"
|
|
126
|
+
},
|
|
123
127
|
"./composition-contract": {
|
|
124
128
|
"import": "./dist/compositionContract.js",
|
|
125
129
|
"types": "./dist/compositionContract.d.ts"
|
|
@@ -272,6 +276,10 @@
|
|
|
272
276
|
"import": "./dist/audioFade.js",
|
|
273
277
|
"types": "./dist/audioFade.d.ts"
|
|
274
278
|
},
|
|
279
|
+
"./audio-decode": {
|
|
280
|
+
"import": "./dist/audioDecode.js",
|
|
281
|
+
"types": "./dist/audioDecode.d.ts"
|
|
282
|
+
},
|
|
275
283
|
"./speed-ramp": {
|
|
276
284
|
"import": "./dist/speedRamp.js",
|
|
277
285
|
"types": "./dist/speedRamp.d.ts"
|
|
@@ -505,9 +513,9 @@
|
|
|
505
513
|
"linkedom": "^0.18.12",
|
|
506
514
|
"postcss": "^8.5.8",
|
|
507
515
|
"wawoff2": "^2.0.1",
|
|
508
|
-
"@hyperframes/lint": "0.9.
|
|
509
|
-
"@hyperframes/studio-server": "0.9.
|
|
510
|
-
"@hyperframes/parsers": "0.9.
|
|
516
|
+
"@hyperframes/lint": "0.9.93",
|
|
517
|
+
"@hyperframes/studio-server": "0.9.93",
|
|
518
|
+
"@hyperframes/parsers": "0.9.93"
|
|
511
519
|
},
|
|
512
520
|
"devDependencies": {
|
|
513
521
|
"@fontsource/archivo-black": "^5.2.8",
|