@revideo/2d 0.10.2 → 0.10.4-alpha.1119

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.
@@ -11,7 +11,7 @@ import {is} from '../utils';
11
11
  import type {Node} from './Node';
12
12
  import type {ShapeProps} from './Shape';
13
13
  import {Shape} from './Shape';
14
- import {TxtLeaf} from './TxtLeaf';
14
+ import {TXT_TYPE, TxtLeaf} from './TxtLeaf';
15
15
  import type {ComponentChildren} from './types';
16
16
 
17
17
  type TxtChildren = string | Node | (string | Node)[];
@@ -24,6 +24,8 @@ export interface TxtProps extends ShapeProps {
24
24
 
25
25
  @nodeName('Txt')
26
26
  export class Txt extends Shape {
27
+ public readonly [TXT_TYPE] = true;
28
+
27
29
  /**
28
30
  * Create a bold text node.
29
31
  *
@@ -15,6 +15,8 @@ export interface TxtLeafProps extends ShapeProps {
15
15
  text?: SignalValue<string>;
16
16
  }
17
17
 
18
+ export const TXT_TYPE = Symbol('Txt');
19
+
18
20
  @nodeName('TxtLeaf')
19
21
  export class TxtLeaf extends Shape {
20
22
  @lazy(() => {
@@ -43,7 +45,15 @@ export class TxtLeaf extends Shape {
43
45
  @computed()
44
46
  protected parentTxt() {
45
47
  const parent = this.parent();
46
- return parent?.constructor.name === 'Txt' ? parent : null;
48
+ if (!parent) {
49
+ return null;
50
+ }
51
+
52
+ if (!(TXT_TYPE in parent)) {
53
+ return null;
54
+ }
55
+
56
+ return parent;
47
57
  }
48
58
 
49
59
  protected override async draw(context: CanvasRenderingContext2D) {
@@ -113,7 +113,7 @@ export class Video extends Media {
113
113
  video = document.createElement('video');
114
114
  video.crossOrigin = 'anonymous';
115
115
 
116
- const parsedSrc = new URL(src);
116
+ const parsedSrc = new URL(src, window.location.origin);
117
117
  if (parsedSrc.pathname.endsWith('.m3u8')) {
118
118
  const hls = new Hls();
119
119
  hls.loadSource(src);
@@ -21,7 +21,8 @@ function isClassComponent(
21
21
  return !!fn.prototype?.isClass;
22
22
  }
23
23
 
24
- export const Fragment = Symbol.for('@revideo/2d/fragment');
24
+ export const Fragment: FunctionComponent = ({children}) => children;
25
+
25
26
  export function jsx(
26
27
  type: NodeConstructor | FunctionComponent | typeof Fragment,
27
28
  config: JSXProps,