@editframe/elements 0.15.0-beta.19 → 0.15.0-beta.20

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.
@@ -136,6 +136,7 @@ class EfFramegen {
136
136
  await new Promise(queueMicrotask);
137
137
  console.log("Awaiting frame tasks");
138
138
  const now = performance.now();
139
+ console.log("HTML", document.body.innerHTML);
139
140
  await Promise.all(
140
141
  temporals.filter((temporal) => temporal.frameTask.status < TaskStatus.COMPLETE).map((temporal) => {
141
142
  return temporal.frameTask;
@@ -80,8 +80,11 @@ const _EFMedia = class _EFMedia2 extends EFTargetable(
80
80
  }
81
81
  },
82
82
  onComplete: () => {
83
+ this.requestUpdate("intrinsicDurationMs");
83
84
  this.requestUpdate("ownCurrentTimeMs");
85
+ console.log("Requesting update for durationMs", this, this.rootTimegroup);
84
86
  this.rootTimegroup?.requestUpdate("ownCurrentTimeMs");
87
+ this.rootTimegroup?.requestUpdate("durationMs");
85
88
  }
86
89
  });
87
90
  this.initSegmentsLoader = new Task(this, {
@@ -20,8 +20,8 @@ export declare const RenderInfo: z.ZodObject<{
20
20
  }, "strip", z.ZodTypeAny, {
21
21
  width: number;
22
22
  height: number;
23
- fps: number;
24
23
  durationMs: number;
24
+ fps: number;
25
25
  assets: {
26
26
  efMedia: Record<string, any>;
27
27
  efCaptions: string[];
@@ -30,8 +30,8 @@ export declare const RenderInfo: z.ZodObject<{
30
30
  }, {
31
31
  width: number;
32
32
  height: number;
33
- fps: number;
34
33
  durationMs: number;
34
+ fps: number;
35
35
  assets: {
36
36
  efMedia: Record<string, any>;
37
37
  efCaptions: string[];
@@ -14,7 +14,9 @@ export declare class EFFitScale extends LitElement {
14
14
  contentWidth: number;
15
15
  contentHeight: number;
16
16
  };
17
+ scaleLastSetOn: HTMLElement | null;
17
18
  setScale: () => void;
19
+ removeScale: () => void;
18
20
  connectedCallback(): void;
19
21
  disconnectedCallback(): void;
20
22
  }
@@ -18,6 +18,7 @@ let EFFitScale = class extends LitElement {
18
18
  this.contentRef = createRef();
19
19
  this.uniqueId = Math.random().toString(36).substring(2, 15);
20
20
  this.scale = 1;
21
+ this.scaleLastSetOn = null;
21
22
  this.setScale = () => {
22
23
  if (this.isConnected) {
23
24
  const { scale } = this.scaleInfo;
@@ -30,15 +31,28 @@ let EFFitScale = class extends LitElement {
30
31
  const scaledHeight = unscaledHeight * scale;
31
32
  const translateX = (containerRect.width - scaledWidth) / 2;
32
33
  const translateY = (containerRect.height - scaledHeight) / 2;
34
+ if (this.scaleLastSetOn !== this.contentChild) {
35
+ this.removeScale();
36
+ }
33
37
  Object.assign(this.contentChild.style, {
34
38
  transform: `translate(${translateX.toFixed(4)}px, ${translateY.toFixed(4)}px) scale(${scale.toFixed(4)})`,
35
39
  transformOrigin: "top left"
36
40
  });
37
41
  this.scale = scale;
42
+ this.scaleLastSetOn = this.contentChild;
38
43
  }
39
44
  this.animationFrameId = requestAnimationFrame(this.setScale);
40
45
  }
41
46
  };
47
+ this.removeScale = () => {
48
+ if (this.scaleLastSetOn) {
49
+ Object.assign(this.scaleLastSetOn.style, {
50
+ transform: "",
51
+ transformOrigin: ""
52
+ });
53
+ this.scaleLastSetOn = null;
54
+ }
55
+ };
42
56
  }
43
57
  createRenderRoot() {
44
58
  Object.assign(this.style, {
@@ -61,7 +61,7 @@ let EFWorkbench = class extends ContextMixin(TWMixin(LitElement)) {
61
61
  }
62
62
  }
63
63
  render() {
64
- if (this.rendering) {
64
+ if (this.rendering || typeof window !== "undefined" && window.FRAMEGEN_BRIDGE) {
65
65
  return html`
66
66
  <slot class="fixed inset-0 h-full w-full" name="canvas"></slot>
67
67
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/elements",
3
- "version": "0.15.0-beta.19",
3
+ "version": "0.15.0-beta.20",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -27,7 +27,7 @@
27
27
  "license": "UNLICENSED",
28
28
  "dependencies": {
29
29
  "@bramus/style-observer": "^1.3.0",
30
- "@editframe/assets": "0.15.0-beta.19",
30
+ "@editframe/assets": "0.15.0-beta.20",
31
31
  "@lit/context": "^1.1.2",
32
32
  "@lit/task": "^1.0.1",
33
33
  "d3": "^7.9.0",
@@ -137,8 +137,11 @@ export class EFMedia extends EFTargetable(
137
137
  }
138
138
  },
139
139
  onComplete: () => {
140
+ this.requestUpdate("intrinsicDurationMs");
140
141
  this.requestUpdate("ownCurrentTimeMs");
142
+ console.log("Requesting update for durationMs", this, this.rootTimegroup);
141
143
  this.rootTimegroup?.requestUpdate("ownCurrentTimeMs");
144
+ this.rootTimegroup?.requestUpdate("durationMs");
142
145
  },
143
146
  });
144
147
 
@@ -129,9 +129,6 @@ export function ContextMixin<T extends Constructor<LitElement>>(superClass: T) {
129
129
  @property({ type: Boolean, reflect: true })
130
130
  loop = false;
131
131
 
132
- // @state()
133
- // private stageScale = 1;
134
-
135
132
  @property({ type: Boolean })
136
133
  rendering = false;
137
134
 
@@ -87,6 +87,8 @@ export class EFFitScale extends LitElement {
87
87
  };
88
88
  }
89
89
 
90
+ scaleLastSetOn: HTMLElement | null = null;
91
+
90
92
  setScale = () => {
91
93
  if (this.isConnected) {
92
94
  const { scale } = this.scaleInfo;
@@ -101,6 +103,11 @@ export class EFFitScale extends LitElement {
101
103
  const translateX = (containerRect.width - scaledWidth) / 2;
102
104
  const translateY = (containerRect.height - scaledHeight) / 2;
103
105
 
106
+ // In the rare event that the content child is changed, we need to remove the scale
107
+ // because we don't want to have a scale on the old content child that is somewhere else in the DOM
108
+ if (this.scaleLastSetOn !== this.contentChild) {
109
+ this.removeScale();
110
+ }
104
111
  // Use toFixed to avoid floating point precision issues
105
112
  // this will update every frame with sub-pixel changes if we don't pin it down
106
113
  Object.assign(this.contentChild.style, {
@@ -108,11 +115,22 @@ export class EFFitScale extends LitElement {
108
115
  transformOrigin: "top left",
109
116
  });
110
117
  this.scale = scale;
118
+ this.scaleLastSetOn = this.contentChild;
111
119
  }
112
120
  this.animationFrameId = requestAnimationFrame(this.setScale);
113
121
  }
114
122
  };
115
123
 
124
+ removeScale = () => {
125
+ if (this.scaleLastSetOn) {
126
+ Object.assign(this.scaleLastSetOn.style, {
127
+ transform: "",
128
+ transformOrigin: "",
129
+ });
130
+ this.scaleLastSetOn = null;
131
+ }
132
+ };
133
+
116
134
  connectedCallback(): void {
117
135
  super.connectedCallback();
118
136
  this.animationFrameId = requestAnimationFrame(this.setScale);
@@ -71,7 +71,12 @@ export class EFWorkbench extends ContextMixin(TWMixin(LitElement)) {
71
71
  };
72
72
 
73
73
  render() {
74
- if (this.rendering) {
74
+ // TODO: this.rendering is not correctly set when using the framegen bridge
75
+ // so to hack we're checking for the existence of the framegen bridge on the window
76
+ if (
77
+ this.rendering ||
78
+ (typeof window !== "undefined" && window.FRAMEGEN_BRIDGE)
79
+ ) {
75
80
  return html`
76
81
  <slot class="fixed inset-0 h-full w-full" name="canvas"></slot>
77
82
  `;