@hyperframes/core 0.9.87 → 0.9.89
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/htmlDocument.d.ts +2 -2
- package/dist/compiler/htmlDocument.js +2 -42
- package/dist/compiler/htmlTokens.d.ts +7 -0
- package/dist/compiler/htmlTokens.js +43 -0
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/previewProxyBox.d.ts +1 -0
- package/dist/runtime/editing/gsapSet.js +2 -0
- package/dist/runtime/editing/patchTween.js +2 -1
- package/dist/runtime/editing/restoreAttributes.js +30 -3
- package/dist/runtime/editingDraft.d.ts +1 -5
- package/dist/runtime/editingDraft.js +111 -3
- package/dist/runtime/editingDraftEnd.d.ts +3 -3
- package/dist/runtime/editingDraftEnd.js +2 -2
- package/dist/runtime/editingGestureStart.d.ts +2 -0
- package/dist/runtime/editingGestureStart.js +2 -2
- package/dist/runtime/editingPort.d.ts +7 -0
- package/dist/runtime/editingPort.js +39 -5
- package/dist/runtime/runtimeAttributes.d.ts +4 -0
- package/dist/runtime/runtimeAttributes.js +17 -0
- package/dist/studioPreviewMark.d.ts +3 -0
- package/dist/studioPreviewMark.js +5 -0
- package/dist/utils/richTextSanitize.js +30 -40
- package/package.json +8 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { escapeInlineScriptSource, RUNTIME_BOOTSTRAP_ATTR } from "./htmlTokens.js";
|
|
2
|
+
export { escapeInlineScriptSource, RUNTIME_BOOTSTRAP_ATTR };
|
|
2
3
|
export interface SceneRootLookup {
|
|
3
4
|
root: Element | null;
|
|
4
5
|
hasTemplate: boolean;
|
|
@@ -14,7 +15,6 @@ export declare function isFullHtmlDocument(html: string): boolean;
|
|
|
14
15
|
export declare function parseHTMLContent(html: string): Document;
|
|
15
16
|
export declare function stripEmbeddedRuntimeScripts(html: string): string;
|
|
16
17
|
export declare function isRuntimeFileUrl(src: string | null | undefined): boolean;
|
|
17
|
-
export declare function escapeInlineScriptSource(source: string): string;
|
|
18
18
|
export declare function mapStartTagsAndStyles(html: string, map: {
|
|
19
19
|
tag: (tag: string) => string;
|
|
20
20
|
style: (css: string) => string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { acceleratedCanvasTrackerSource } from "../pageMotionBlur.js";
|
|
2
2
|
import { findSceneTemplate, templateContent } from "@hyperframes/parsers/sub-composition-validity";
|
|
3
3
|
import { parseHTML } from "linkedom";
|
|
4
|
-
|
|
4
|
+
import { escapeInlineScriptSource, indexOfLower, lowerAscii, RUNTIME_BOOTSTRAP_ATTR, startsWithLower, } from "./htmlTokens.js";
|
|
5
|
+
export { escapeInlineScriptSource, RUNTIME_BOOTSTRAP_ATTR };
|
|
5
6
|
const RUNTIME_FILES = [
|
|
6
7
|
"hyperframe.runtime.iife.js",
|
|
7
8
|
"hyperframes-runtime.modular.inline.js",
|
|
@@ -41,27 +42,6 @@ export function parseHTMLContent(html) {
|
|
|
41
42
|
}
|
|
42
43
|
return parseHTML(`<!DOCTYPE html><html><head></head><body>${html}</body></html>`).document;
|
|
43
44
|
}
|
|
44
|
-
/** ASCII-only chunks bound match arrays; starting at uppercase preserves unchanged spans. */
|
|
45
|
-
function lowerAscii(text) {
|
|
46
|
-
return text.replace(/[A-Z][\s\S]{0,65535}/g, (chunk) => chunk.replace(/[A-Z]+/g, (letters) => letters.toLowerCase()));
|
|
47
|
-
}
|
|
48
|
-
function startsWithLower(text, token, at) {
|
|
49
|
-
if (at < 0 || at + token.length > text.length)
|
|
50
|
-
return false;
|
|
51
|
-
for (let i = 0; i < token.length; i += 1) {
|
|
52
|
-
const code = text.charCodeAt(at + i);
|
|
53
|
-
if ((code >= 65 && code <= 90 ? code + 32 : code) !== token.charCodeAt(i))
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
function indexOfLower(text, token, from) {
|
|
59
|
-
for (let at = text.indexOf(token.charAt(0), from); at !== -1; at = text.indexOf(token.charAt(0), at + 1)) {
|
|
60
|
-
if (startsWithLower(text, token, at))
|
|
61
|
-
return at;
|
|
62
|
-
}
|
|
63
|
-
return -1;
|
|
64
|
-
}
|
|
65
45
|
function lastIndexOfLower(text, token) {
|
|
66
46
|
for (let at = text.lastIndexOf(token.charAt(0)); at !== -1; at = at === 0 ? -1 : text.lastIndexOf(token.charAt(0), at - 1)) {
|
|
67
47
|
if (startsWithLower(text, token, at))
|
|
@@ -187,26 +167,6 @@ function isTagBoundary(char) {
|
|
|
187
167
|
function isHtmlWhitespace(char) {
|
|
188
168
|
return char === " " || char === "\n" || char === "\t" || char === "\r" || char === "\f";
|
|
189
169
|
}
|
|
190
|
-
export function escapeInlineScriptSource(source) {
|
|
191
|
-
return escapeCaseInsensitiveToken(escapeCaseInsensitiveToken(source, "</script", (match) => `<\\/${match.slice(2)}`), "<!--", () => "\\x3C!--");
|
|
192
|
-
}
|
|
193
|
-
function escapeCaseInsensitiveToken(source, token, replacement) {
|
|
194
|
-
const loweredToken = lowerAscii(token);
|
|
195
|
-
let output = "";
|
|
196
|
-
let cursor = 0;
|
|
197
|
-
while (cursor < source.length) {
|
|
198
|
-
const tokenStart = indexOfLower(source, loweredToken, cursor);
|
|
199
|
-
if (tokenStart === -1) {
|
|
200
|
-
output += source.slice(cursor);
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
output +=
|
|
204
|
-
source.slice(cursor, tokenStart) +
|
|
205
|
-
replacement(source.slice(tokenStart, tokenStart + token.length));
|
|
206
|
-
cursor = tokenStart + token.length;
|
|
207
|
-
}
|
|
208
|
-
return output;
|
|
209
|
-
}
|
|
210
170
|
function inlineScriptTags(scripts) {
|
|
211
171
|
return scripts
|
|
212
172
|
.map((source, index) => `${source}\n//# sourceURL=hyperframes://injected/${index}`)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Case-insensitive HTML token scans, with no DOM: the player inlines scripts with these too. */
|
|
2
|
+
export declare const RUNTIME_BOOTSTRAP_ATTR = "data-hyperframes-preview-runtime";
|
|
3
|
+
/** ASCII-only chunks bound match arrays; starting at uppercase preserves unchanged spans. */
|
|
4
|
+
export declare function lowerAscii(text: string): string;
|
|
5
|
+
export declare function startsWithLower(text: string, token: string, at: number): boolean;
|
|
6
|
+
export declare function indexOfLower(text: string, token: string, from: number): number;
|
|
7
|
+
export declare function escapeInlineScriptSource(source: string): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Case-insensitive HTML token scans, with no DOM: the player inlines scripts with these too. */
|
|
2
|
+
export const RUNTIME_BOOTSTRAP_ATTR = "data-hyperframes-preview-runtime";
|
|
3
|
+
/** ASCII-only chunks bound match arrays; starting at uppercase preserves unchanged spans. */
|
|
4
|
+
export function lowerAscii(text) {
|
|
5
|
+
return text.replace(/[A-Z][\s\S]{0,65535}/g, (chunk) => chunk.replace(/[A-Z]+/g, (letters) => letters.toLowerCase()));
|
|
6
|
+
}
|
|
7
|
+
export function startsWithLower(text, token, at) {
|
|
8
|
+
if (at < 0 || at + token.length > text.length)
|
|
9
|
+
return false;
|
|
10
|
+
for (let i = 0; i < token.length; i += 1) {
|
|
11
|
+
const code = text.charCodeAt(at + i);
|
|
12
|
+
if ((code >= 65 && code <= 90 ? code + 32 : code) !== token.charCodeAt(i))
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
export function indexOfLower(text, token, from) {
|
|
18
|
+
for (let at = text.indexOf(token.charAt(0), from); at !== -1; at = text.indexOf(token.charAt(0), at + 1)) {
|
|
19
|
+
if (startsWithLower(text, token, at))
|
|
20
|
+
return at;
|
|
21
|
+
}
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
export function escapeInlineScriptSource(source) {
|
|
25
|
+
return escapeCaseInsensitiveToken(escapeCaseInsensitiveToken(source, "</script", (match) => `<\\/${match.slice(2)}`), "<!--", () => "\\x3C!--");
|
|
26
|
+
}
|
|
27
|
+
function escapeCaseInsensitiveToken(source, token, replacement) {
|
|
28
|
+
const loweredToken = lowerAscii(token);
|
|
29
|
+
let output = "";
|
|
30
|
+
let cursor = 0;
|
|
31
|
+
while (cursor < source.length) {
|
|
32
|
+
const tokenStart = indexOfLower(source, loweredToken, cursor);
|
|
33
|
+
if (tokenStart === -1) {
|
|
34
|
+
output += source.slice(cursor);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
output +=
|
|
38
|
+
source.slice(cursor, tokenStart) +
|
|
39
|
+
replacement(source.slice(tokenStart, tokenStart + token.length));
|
|
40
|
+
cursor = tokenStart + token.length;
|
|
41
|
+
}
|
|
42
|
+
return output;
|
|
43
|
+
}
|