@editframe/elements 0.11.0-beta.10 → 0.11.0-beta.14

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.
@@ -18,15 +18,6 @@ const timegroupContext = createContext(
18
18
  );
19
19
  const isEFTemporal = (obj) => obj[EF_TEMPORAL];
20
20
  const EF_TEMPORAL = Symbol("EF_TEMPORAL");
21
- const deepGetTemporalElements = (element, temporals = []) => {
22
- for (const child of element.children) {
23
- if (isEFTemporal(child)) {
24
- temporals.push(child);
25
- }
26
- deepGetTemporalElements(child, temporals);
27
- }
28
- return temporals;
29
- };
30
21
  const deepGetElementsWithFrameTasks = (element, elements = []) => {
31
22
  for (const child of element.children) {
32
23
  if ("frameTask" in child && child.frameTask instanceof Task) {
@@ -126,6 +117,9 @@ const EFTemporal = (superClass) => {
126
117
  return this._trimStartMs;
127
118
  }
128
119
  set trimStartMs(value) {
120
+ if (this._trimStartMs === value) {
121
+ return;
122
+ }
129
123
  this._trimStartMs = value;
130
124
  this.setAttribute(
131
125
  "trimstart",
@@ -143,6 +137,9 @@ const EFTemporal = (superClass) => {
143
137
  return this._trimEndMs;
144
138
  }
145
139
  set trimEndMs(value) {
140
+ if (this._trimEndMs === value) {
141
+ return;
142
+ }
146
143
  this._trimEndMs = value;
147
144
  this.setAttribute("trimend", durationConverter.toAttribute(value / 1e3));
148
145
  }
@@ -373,7 +370,6 @@ export {
373
370
  EFTemporal,
374
371
  OwnCurrentTimeController,
375
372
  deepGetElementsWithFrameTasks,
376
- deepGetTemporalElements,
377
373
  isEFTemporal,
378
374
  shallowGetTemporalElements,
379
375
  timegroupContext
@@ -234,7 +234,7 @@ let EFTimegroup = class extends EFTemporal(LitElement) {
234
234
  *
235
235
  */
236
236
  shouldWrapWithWorkbench() {
237
- return EF_INTERACTIVE && this.closest("ef-timegroup") === this && this.contextProvider === null;
237
+ return EF_INTERACTIVE && this.closest("ef-timegroup") === this && this.closest("ef-preview") === null && this.closest("ef-workbench") === null && this.closest("test-context") === null;
238
238
  }
239
239
  wrapWithWorkbench() {
240
240
  const workbench = document.createElement("ef-workbench");
@@ -18,14 +18,13 @@ var __decorateClass = (decorators, target, key, kind) => {
18
18
  };
19
19
  const contextMixinSymbol = Symbol("contextMixin");
20
20
  function isContextMixin(value) {
21
- return typeof value === "object" && value !== null && contextMixinSymbol in value;
21
+ return typeof value === "object" && value !== null && contextMixinSymbol in value.constructor;
22
22
  }
23
23
  function ContextMixin(superClass) {
24
24
  var _a, _b;
25
25
  class ContextElement extends (_b = superClass, _a = contextMixinSymbol, _b) {
26
26
  constructor() {
27
27
  super(...arguments);
28
- this[_a] = true;
29
28
  this.focusContext = this;
30
29
  this.efContext = this;
31
30
  this.fetch = async (url, init = {}) => {
@@ -101,6 +100,9 @@ function ContextMixin(superClass) {
101
100
  this.#playbackAnimationFrameRequest = null;
102
101
  this.#AUDIO_PLAYBACK_SLICE_MS = 1e3;
103
102
  }
103
+ static {
104
+ this[_a] = true;
105
+ }
104
106
  #URLTokens;
105
107
  connectedCallback() {
106
108
  super.connectedCallback();
@@ -1,11 +1,8 @@
1
1
  import { html, css, LitElement } from "lit";
2
- import { TaskStatus } from "@lit/task";
3
2
  import { eventOptions, customElement } from "lit/decorators.js";
4
3
  import { createRef, ref } from "lit/directives/ref.js";
5
- import { deepGetTemporalElements } from "../elements/EFTemporal.js";
6
- import { TWMixin } from "./TWMixin.js";
7
- import { shallowGetTimegroups } from "../elements/EFTimegroup.js";
8
4
  import { ContextMixin } from "./ContextMixin.js";
5
+ import { TWMixin } from "./TWMixin.js";
9
6
  var __defProp = Object.defineProperty;
10
7
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
8
  var __decorateClass = (decorators, target, key, kind) => {
@@ -87,26 +84,6 @@ let EFWorkbench = class extends ContextMixin(TWMixin(LitElement)) {
87
84
  </div>
88
85
  `;
89
86
  }
90
- async stepThrough() {
91
- const stepDurationMs = 1e3 / 30;
92
- const timegroups = shallowGetTimegroups(this);
93
- const firstGroup = timegroups[0];
94
- if (!firstGroup) {
95
- throw new Error("No temporal elements found");
96
- }
97
- firstGroup.currentTimeMs = 0;
98
- const temporals = deepGetTemporalElements(this);
99
- const frameCount = Math.ceil(firstGroup.durationMs / stepDurationMs);
100
- const busyTasks = temporals.filter((temporal) => temporal.frameTask.status < TaskStatus.COMPLETE).map((temporal) => temporal.frameTask);
101
- await Promise.all(busyTasks.map((task) => task.taskComplete));
102
- for (let i = 0; i < frameCount; i++) {
103
- firstGroup.currentTimeMs = i * stepDurationMs;
104
- await new Promise(queueMicrotask);
105
- const busyTasks2 = temporals.filter((temporal) => temporal.frameTask.status < TaskStatus.COMPLETE).map((temporal) => temporal.frameTask);
106
- await Promise.all(busyTasks2.map((task) => task.taskComplete));
107
- await new Promise((resolve) => requestAnimationFrame(resolve));
108
- }
109
- }
110
87
  };
111
88
  EFWorkbench.styles = [
112
89
  css`
@@ -8,7 +8,6 @@ export declare class EFWorkbench extends EFWorkbench_base {
8
8
  update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
9
9
  drawOverlays: () => void;
10
10
  render(): import('lit-html').TemplateResult<1>;
11
- stepThrough(): Promise<void>;
12
11
  }
13
12
  declare global {
14
13
  interface HTMLElementTagNameMap {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/elements",
3
- "version": "0.11.0-beta.10",
3
+ "version": "0.11.0-beta.14",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -20,7 +20,7 @@
20
20
  "author": "",
21
21
  "license": "UNLICENSED",
22
22
  "dependencies": {
23
- "@editframe/assets": "0.11.0-beta.10",
23
+ "@editframe/assets": "0.11.0-beta.14",
24
24
  "@lit/context": "^1.1.2",
25
25
  "@lit/task": "^1.0.1",
26
26
  "d3": "^7.9.0",
@@ -187,6 +187,9 @@ export const EFTemporal = <T extends Constructor<LitElement>>(
187
187
  return this._trimStartMs;
188
188
  }
189
189
  public set trimStartMs(value: number) {
190
+ if (this._trimStartMs === value) {
191
+ return;
192
+ }
190
193
  this._trimStartMs = value;
191
194
  this.setAttribute(
192
195
  "trimstart",
@@ -211,6 +214,9 @@ export const EFTemporal = <T extends Constructor<LitElement>>(
211
214
  return this._trimEndMs;
212
215
  }
213
216
  public set trimEndMs(value: number) {
217
+ if (this._trimEndMs === value) {
218
+ return;
219
+ }
214
220
  this._trimEndMs = value;
215
221
  this.setAttribute("trimend", durationConverter.toAttribute(value / 1000));
216
222
  }
@@ -269,7 +269,9 @@ export class EFTimegroup extends EFTemporal(LitElement) {
269
269
  return (
270
270
  EF_INTERACTIVE &&
271
271
  this.closest("ef-timegroup") === this &&
272
- this.contextProvider === null
272
+ this.closest("ef-preview") === null &&
273
+ this.closest("ef-workbench") === null &&
274
+ this.closest("test-context") === null
273
275
  );
274
276
  }
275
277
 
@@ -30,14 +30,16 @@ const contextMixinSymbol = Symbol("contextMixin");
30
30
 
31
31
  export function isContextMixin(value: any): value is ContextMixinInterface {
32
32
  return (
33
- typeof value === "object" && value !== null && contextMixinSymbol in value
33
+ typeof value === "object" &&
34
+ value !== null &&
35
+ contextMixinSymbol in value.constructor
34
36
  );
35
37
  }
36
38
 
37
39
  type Constructor<T = {}> = new (...args: any[]) => T;
38
40
  export function ContextMixin<T extends Constructor<LitElement>>(superClass: T) {
39
41
  class ContextElement extends superClass {
40
- [contextMixinSymbol] = true;
42
+ static [contextMixinSymbol] = true;
41
43
 
42
44
  @provide({ context: focusContext })
43
45
  focusContext = this as FocusContext;
@@ -1,12 +1,9 @@
1
- import { LitElement, html, css, type PropertyValueMap } from "lit";
2
- import { TaskStatus } from "@lit/task";
1
+ import { LitElement, type PropertyValueMap, css, html } from "lit";
3
2
  import { customElement, eventOptions } from "lit/decorators.js";
4
- import { ref, createRef } from "lit/directives/ref.js";
3
+ import { createRef, ref } from "lit/directives/ref.js";
5
4
 
6
- import { deepGetTemporalElements } from "../elements/EFTemporal.ts";
7
- import { TWMixin } from "./TWMixin.ts";
8
- import { shallowGetTimegroups } from "../elements/EFTimegroup.ts";
9
5
  import { ContextMixin } from "./ContextMixin.ts";
6
+ import { TWMixin } from "./TWMixin.ts";
10
7
 
11
8
  @customElement("ef-workbench")
12
9
  export class EFWorkbench extends ContextMixin(TWMixin(LitElement)) {
@@ -96,36 +93,6 @@ export class EFWorkbench extends ContextMixin(TWMixin(LitElement)) {
96
93
  </div>
97
94
  `;
98
95
  }
99
-
100
- async stepThrough() {
101
- const stepDurationMs = 1000 / 30;
102
- const timegroups = shallowGetTimegroups(this);
103
- const firstGroup = timegroups[0];
104
- if (!firstGroup) {
105
- throw new Error("No temporal elements found");
106
- }
107
- firstGroup.currentTimeMs = 0;
108
-
109
- const temporals = deepGetTemporalElements(this);
110
- const frameCount = Math.ceil(firstGroup.durationMs / stepDurationMs);
111
-
112
- const busyTasks = temporals
113
- .filter((temporal) => temporal.frameTask.status < TaskStatus.COMPLETE)
114
- .map((temporal) => temporal.frameTask);
115
-
116
- await Promise.all(busyTasks.map((task) => task.taskComplete));
117
-
118
- for (let i = 0; i < frameCount; i++) {
119
- firstGroup.currentTimeMs = i * stepDurationMs;
120
- await new Promise<void>(queueMicrotask);
121
- const busyTasks = temporals
122
- .filter((temporal) => temporal.frameTask.status < TaskStatus.COMPLETE)
123
- .map((temporal) => temporal.frameTask);
124
-
125
- await Promise.all(busyTasks.map((task) => task.taskComplete));
126
- await new Promise((resolve) => requestAnimationFrame(resolve));
127
- }
128
- }
129
96
  }
130
97
 
131
98
  declare global {