@hyperframes/core 0.9.103 → 0.9.106
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/compositionScoping.js +3 -3
- package/dist/compiler/htmlDocument.js +9 -2
- package/dist/compiler/svgIdNamespacing.js +2 -2
- package/dist/fonts/authoredGoogleFonts.js +2 -2
- package/dist/fonts/deterministicFonts.js +14 -12
- package/dist/fonts/fontDiagnostics.d.ts +3 -0
- package/dist/fonts/fontDiagnostics.js +32 -1
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/runtime/drawnBox.d.ts +5 -0
- package/dist/runtime/drawnBox.js +5 -0
- package/dist/runtime/editing/canvasKeys.d.ts +0 -1
- package/dist/runtime/editing/canvasKeys.js +4 -28
- package/dist/runtime/editing/dragChrome.d.ts +32 -0
- package/dist/runtime/editing/dragChrome.js +154 -0
- package/dist/runtime/editing/pausedFrames.js +7 -7
- package/dist/runtime/editing/softReload.js +4 -2
- package/dist/runtime/editing/stageAct.js +3 -2
- package/dist/runtime/editing/textEdit.js +4 -3
- package/dist/runtime/editing/watchGeometry.js +8 -8
- package/dist/runtime/editing/watchPointer.d.ts +26 -0
- package/dist/runtime/editing/watchPointer.js +105 -0
- package/dist/runtime/editingDraft.d.ts +3 -2
- package/dist/runtime/editingDraft.js +13 -8
- package/dist/runtime/editingDraftEnd.d.ts +1 -0
- package/dist/runtime/editingElement.d.ts +4 -0
- package/dist/runtime/editingGeometry.js +1 -4
- package/dist/runtime/editingHandles.d.ts +0 -5
- package/dist/runtime/editingHandles.js +7 -0
- package/dist/runtime/editingPort.d.ts +22 -3
- package/dist/runtime/editingPort.js +63 -8
- package/dist/runtime/mediaProxy.js +78 -7
- package/dist/runtime/runtimePort.d.ts +21 -0
- package/dist/runtime/runtimePort.js +122 -0
- package/dist/studioPreviewMark.d.ts +2 -0
- package/dist/studioPreviewMark.js +2 -0
- package/package.json +4 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// The runtime's MessagePort calls, bound to built-ins read when the runtime first evaluates, before any
|
|
2
|
+
// composition script runs. Best-effort: it covers the port, channel, event-data and container calls the
|
|
3
|
+
// runtime makes with a port; a built-in reached some other way after load is not covered.
|
|
4
|
+
const apply = Reflect.apply;
|
|
5
|
+
const protoOf = Object.getPrototypeOf;
|
|
6
|
+
const descriptor = Object.getOwnPropertyDescriptor;
|
|
7
|
+
const NativeMessageChannel = typeof MessageChannel !== "undefined" ? MessageChannel : null;
|
|
8
|
+
function accessor(proto, name, kind) {
|
|
9
|
+
for (let at = proto; at; at = protoOf(at)) {
|
|
10
|
+
const found = descriptor(at, name)?.[kind];
|
|
11
|
+
if (found)
|
|
12
|
+
return found;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
// Browsers expose a channel's ports through prototype getters; Node keeps them as the channel's own data.
|
|
17
|
+
function channelPort(channel, getter, name) {
|
|
18
|
+
return (getter ? apply(getter, channel, []) : descriptor(channel, name)?.value);
|
|
19
|
+
}
|
|
20
|
+
const native = (() => {
|
|
21
|
+
if (!NativeMessageChannel)
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
const probe = new NativeMessageChannel();
|
|
25
|
+
const channelProto = protoOf(probe);
|
|
26
|
+
const port1 = accessor(channelProto, "port1", "get");
|
|
27
|
+
const port2 = accessor(channelProto, "port2", "get");
|
|
28
|
+
const proto = protoOf(channelPort(probe, port1, "port1"));
|
|
29
|
+
const setOnMessage = accessor(proto, "onmessage", "set");
|
|
30
|
+
const eventProto = typeof MessageEvent !== "undefined" ? MessageEvent.prototype : null;
|
|
31
|
+
const eventData = accessor(eventProto, "data", "get");
|
|
32
|
+
if (!setOnMessage)
|
|
33
|
+
return null;
|
|
34
|
+
const methods = {
|
|
35
|
+
proto,
|
|
36
|
+
post: proto.postMessage,
|
|
37
|
+
close: proto.close,
|
|
38
|
+
setOnMessage,
|
|
39
|
+
port1,
|
|
40
|
+
port2,
|
|
41
|
+
eventData,
|
|
42
|
+
eventProto,
|
|
43
|
+
};
|
|
44
|
+
apply(methods.close, channelPort(probe, port1, "port1"), []);
|
|
45
|
+
apply(methods.close, channelPort(probe, port2, "port2"), []);
|
|
46
|
+
return methods;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
let standIns = false;
|
|
53
|
+
/** Tests only: stand-in ports and events from another realm (jsdom over Node) keep their own methods. */
|
|
54
|
+
export function allowPortStandInsForTests() {
|
|
55
|
+
standIns = true;
|
|
56
|
+
}
|
|
57
|
+
function bound(port) {
|
|
58
|
+
if (native && protoOf(port) === native.proto)
|
|
59
|
+
return native;
|
|
60
|
+
if (standIns)
|
|
61
|
+
return null;
|
|
62
|
+
throw new Error("not a runtime port");
|
|
63
|
+
}
|
|
64
|
+
/** Null when the browser's own port methods could not be read at load: the agent then never connects. */
|
|
65
|
+
export function createRuntimeChannel() {
|
|
66
|
+
if (!native || !NativeMessageChannel || !(native.eventData || standIns))
|
|
67
|
+
return null;
|
|
68
|
+
const channel = new NativeMessageChannel();
|
|
69
|
+
return {
|
|
70
|
+
port1: channelPort(channel, native.port1, "port1"),
|
|
71
|
+
port2: channelPort(channel, native.port2, "port2"),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function postOnPort(port, message, transfer) {
|
|
75
|
+
const methods = bound(port);
|
|
76
|
+
if (methods)
|
|
77
|
+
apply(methods.post, port, [message, transfer ?? []]);
|
|
78
|
+
else if (transfer)
|
|
79
|
+
port.postMessage(message, transfer);
|
|
80
|
+
else
|
|
81
|
+
port.postMessage(message);
|
|
82
|
+
}
|
|
83
|
+
export function onPortMessage(port, handler) {
|
|
84
|
+
const methods = bound(port);
|
|
85
|
+
const onMessage = (event) => {
|
|
86
|
+
const read = native?.eventData;
|
|
87
|
+
if (read && protoOf(event) === native?.eventProto)
|
|
88
|
+
handler(apply(read, event, []));
|
|
89
|
+
else if (standIns)
|
|
90
|
+
handler(event.data);
|
|
91
|
+
};
|
|
92
|
+
if (methods)
|
|
93
|
+
apply(methods.setOnMessage, port, [onMessage]);
|
|
94
|
+
else
|
|
95
|
+
port.onmessage = onMessage;
|
|
96
|
+
}
|
|
97
|
+
export function closePort(port) {
|
|
98
|
+
const methods = bound(port);
|
|
99
|
+
if (methods)
|
|
100
|
+
apply(methods.close, port, []);
|
|
101
|
+
else
|
|
102
|
+
port.close();
|
|
103
|
+
}
|
|
104
|
+
const mapGet = Map.prototype.get;
|
|
105
|
+
const mapSet = Map.prototype.set;
|
|
106
|
+
const mapHas = Map.prototype.has;
|
|
107
|
+
const mapDelete = Map.prototype.delete;
|
|
108
|
+
const mapClear = Map.prototype.clear;
|
|
109
|
+
const mapForEach = Map.prototype.forEach;
|
|
110
|
+
const mapSize = accessor(Map.prototype, "size", "get");
|
|
111
|
+
export function portMap() {
|
|
112
|
+
const map = new Map();
|
|
113
|
+
return {
|
|
114
|
+
get: (port) => apply(mapGet, map, [port]),
|
|
115
|
+
set: (port, value) => void apply(mapSet, map, [port, value]),
|
|
116
|
+
has: (port) => apply(mapHas, map, [port]),
|
|
117
|
+
delete: (port) => apply(mapDelete, map, [port]),
|
|
118
|
+
clear: () => void apply(mapClear, map, []),
|
|
119
|
+
forEach: (each) => void apply(mapForEach, map, [each]),
|
|
120
|
+
size: () => apply(mapSize, map, []),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -23,6 +23,8 @@ export declare const STUDIO_PREVIEW_LAZY_ATTR = "data-hf-preview-lazy";
|
|
|
23
23
|
export declare const STUDIO_PREVIEW_ERRORS = "__hfPreviewErrors";
|
|
24
24
|
export declare const STUDIO_PREVIEW_ERROR_MESSAGE = "preview-error";
|
|
25
25
|
export declare const STUDIO_PREVIEW_ERROR_KINDS = "__hfPreviewErrorKinds";
|
|
26
|
+
export declare const STUDIO_PREVIEW_RETRY_AFTER = "__hfPreviewRetryAfter";
|
|
27
|
+
export declare const STUDIO_PREVIEW_PAGE_DEADLINE_MS = 120000;
|
|
26
28
|
export declare function previewConsoleErrorText(args: readonly unknown[]): string | null;
|
|
27
29
|
export declare const refusedPreviewMessage: (status: number) => string;
|
|
28
30
|
export declare function refusedPreviewStatus(message: string): number | null;
|
|
@@ -51,6 +51,8 @@ export const STUDIO_PREVIEW_LAZY_ATTR = "data-hf-preview-lazy";
|
|
|
51
51
|
export const STUDIO_PREVIEW_ERRORS = "__hfPreviewErrors";
|
|
52
52
|
export const STUDIO_PREVIEW_ERROR_MESSAGE = "preview-error";
|
|
53
53
|
export const STUDIO_PREVIEW_ERROR_KINDS = "__hfPreviewErrorKinds";
|
|
54
|
+
export const STUDIO_PREVIEW_RETRY_AFTER = "__hfPreviewRetryAfter";
|
|
55
|
+
export const STUDIO_PREVIEW_PAGE_DEADLINE_MS = 120_000;
|
|
54
56
|
export function previewConsoleErrorText(args) {
|
|
55
57
|
const text = args.map((a) => (a instanceof Error ? a.message : String(a))).join(" ");
|
|
56
58
|
return text.includes("favicon") ? null : text;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.106",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -525,9 +525,9 @@
|
|
|
525
525
|
"linkedom": "^0.18.12",
|
|
526
526
|
"postcss": "^8.5.8",
|
|
527
527
|
"wawoff2": "^2.0.1",
|
|
528
|
-
"@hyperframes/lint": "0.9.
|
|
529
|
-
"@hyperframes/studio-server": "0.9.
|
|
530
|
-
"@hyperframes/parsers": "0.9.
|
|
528
|
+
"@hyperframes/lint": "0.9.106",
|
|
529
|
+
"@hyperframes/studio-server": "0.9.106",
|
|
530
|
+
"@hyperframes/parsers": "0.9.106"
|
|
531
531
|
},
|
|
532
532
|
"devDependencies": {
|
|
533
533
|
"@fontsource/archivo-black": "^5.2.8",
|