@hyperframes/sdk 0.7.21 → 0.7.22
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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-only editing-affordance resolver. Reads live layout (getComputedStyle)
|
|
3
|
+
* from a rendered element and combines it with the SDK model element to call the
|
|
4
|
+
* pure core resolver. MUST NOT be imported on the static/Node SDK path — it
|
|
5
|
+
* touches getComputedStyle and only resolves meaningfully against a laid-out DOM.
|
|
6
|
+
*/
|
|
7
|
+
import { type EditingAffordances } from "@hyperframes/core/editing";
|
|
8
|
+
import type { HyperFramesElement } from "../types.js";
|
|
9
|
+
export interface AffordanceContext {
|
|
10
|
+
/** Studio-app concepts; default false for a generic consumer with no such notion. */
|
|
11
|
+
isCompositionHost?: boolean;
|
|
12
|
+
isCompositionRoot?: boolean;
|
|
13
|
+
isInsideLockedComposition?: boolean;
|
|
14
|
+
isMasterView?: boolean;
|
|
15
|
+
}
|
|
16
|
+
type ModelFacts = Pick<HyperFramesElement, "text" | "animationIds" | "start">;
|
|
17
|
+
export declare function resolveElementAffordances(liveEl: HTMLElement, modelEl: ModelFacts | null, ctx?: AffordanceContext): EditingAffordances;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=affordances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affordances.d.ts","sourceRoot":"","sources":["../../src/editing/affordances.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA6B,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,KAAK,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC,CAAC;AAE9E,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,EAC1B,GAAG,GAAE,iBAAsB,GAC1B,kBAAkB,CAqCpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-only editing-affordance resolver. Reads live layout (getComputedStyle)
|
|
3
|
+
* from a rendered element and combines it with the SDK model element to call the
|
|
4
|
+
* pure core resolver. MUST NOT be imported on the static/Node SDK path — it
|
|
5
|
+
* touches getComputedStyle and only resolves meaningfully against a laid-out DOM.
|
|
6
|
+
*/
|
|
7
|
+
import { resolveEditingAffordances } from "@hyperframes/core/editing";
|
|
8
|
+
export function resolveElementAffordances(liveEl, modelEl, ctx = {}) {
|
|
9
|
+
const view = liveEl.ownerDocument.defaultView;
|
|
10
|
+
const cs = view ? view.getComputedStyle(liveEl) : null;
|
|
11
|
+
const computedStyles = cs
|
|
12
|
+
? {
|
|
13
|
+
position: cs.getPropertyValue("position"),
|
|
14
|
+
left: cs.getPropertyValue("left"),
|
|
15
|
+
top: cs.getPropertyValue("top"),
|
|
16
|
+
width: cs.getPropertyValue("width"),
|
|
17
|
+
height: cs.getPropertyValue("height"),
|
|
18
|
+
transform: cs.getPropertyValue("transform"),
|
|
19
|
+
}
|
|
20
|
+
: undefined;
|
|
21
|
+
// Core reads position only from computedStyles; inlineStyles supplies the
|
|
22
|
+
// authored left/top/width/height that override the computed layout.
|
|
23
|
+
const inlineStyles = {
|
|
24
|
+
left: liveEl.style.getPropertyValue("left"),
|
|
25
|
+
top: liveEl.style.getPropertyValue("top"),
|
|
26
|
+
width: liveEl.style.getPropertyValue("width"),
|
|
27
|
+
height: liveEl.style.getPropertyValue("height"),
|
|
28
|
+
};
|
|
29
|
+
return resolveEditingAffordances({
|
|
30
|
+
hasStableTarget: true,
|
|
31
|
+
tag: liveEl.tagName.toLowerCase(),
|
|
32
|
+
inlineStyles,
|
|
33
|
+
computedStyles,
|
|
34
|
+
isCompositionHost: ctx.isCompositionHost ?? false,
|
|
35
|
+
isCompositionRoot: ctx.isCompositionRoot ?? false,
|
|
36
|
+
isInsideLockedComposition: ctx.isInsideLockedComposition ?? false,
|
|
37
|
+
isMasterView: ctx.isMasterView ?? false,
|
|
38
|
+
existsInSource: modelEl != null,
|
|
39
|
+
hasEditableText: modelEl?.text != null,
|
|
40
|
+
hasTimingStart: modelEl ? modelEl.start != null : liveEl.hasAttribute("data-start"),
|
|
41
|
+
animationCount: modelEl?.animationIds.length ?? 0,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=affordances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affordances.js","sourceRoot":"","sources":["../../src/editing/affordances.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,yBAAyB,EAA2B,MAAM,2BAA2B,CAAC;AAa/F,MAAM,UAAU,yBAAyB,CACvC,MAAmB,EACnB,OAA0B,EAC1B,MAAyB,EAAE;IAE3B,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC;IAC9C,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,MAAM,cAAc,GAAuC,EAAE;QAC3D,CAAC,CAAC;YACE,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC;YACzC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC;YACjC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAC/B,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAA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
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.22",
|
|
4
4
|
"description": "Headless, framework-neutral HyperFrames composition editing engine",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"./adapters/headless": {
|
|
30
30
|
"import": "./dist/adapters/headless.js",
|
|
31
31
|
"types": "./dist/adapters/headless.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./editing": {
|
|
34
|
+
"import": "./dist/editing/affordances.js",
|
|
35
|
+
"types": "./dist/editing/affordances.d.ts"
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
38
|
"publishConfig": {
|
|
@@ -36,11 +40,12 @@
|
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
42
|
"linkedom": "^0.18.12",
|
|
39
|
-
"@hyperframes/
|
|
40
|
-
"@hyperframes/
|
|
43
|
+
"@hyperframes/core": "0.7.22",
|
|
44
|
+
"@hyperframes/parsers": "0.7.22"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
47
|
"@types/node": "^25.0.10",
|
|
48
|
+
"happy-dom": "^20.9.0",
|
|
44
49
|
"typescript": "^5.0.0",
|
|
45
50
|
"vitest": "^3.2.4"
|
|
46
51
|
},
|