@threlte/theatre 3.0.0-next.1 → 3.0.0-next.3

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.
@@ -1,13 +1,9 @@
1
1
  <script lang="ts">import { globalProjects } from '../consts';
2
2
  import { getProject } from '../theatre';
3
3
  import { setContext } from 'svelte';
4
- // PROPS
5
- export let name = 'default';
6
- export let config = undefined;
7
- // BINDINGS
8
- export const project = globalProjects.get(name) ?? getProject(name, config);
4
+ let { name = 'default', config, project = $bindable(), isReady = $bindable(), children } = $props();
5
+ project = globalProjects.get(name) ?? getProject(name, config);
9
6
  globalProjects.set(name, project);
10
- export let isReady = false;
11
7
  const syncReady = async () => {
12
8
  await project.ready;
13
9
  isReady = true;
@@ -18,5 +14,5 @@ setContext(`theatre-project`, project);
18
14
  </script>
19
15
 
20
16
  {#await project.ready then}
21
- <slot {project} />
17
+ {@render children?.({ project })}
22
18
  {/await}
@@ -1,30 +1,24 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import type { IProjectConfig } from '@theatre/core';
2
+ import { type Snippet } from 'svelte';
3
+ import type { IProject, IProjectConfig } from '@theatre/core';
3
4
  declare const __propDef: {
4
5
  props: {
5
- name?: string | undefined;
6
+ name: string;
6
7
  config?: IProjectConfig | undefined;
7
- project?: import("@theatre/core").IProject | undefined;
8
+ project?: IProject | undefined;
8
9
  isReady?: boolean | undefined;
9
- children?: ((this: void, args_0: {
10
- project: import("@theatre/core").IProject;
11
- }) => typeof import("svelte").SnippetReturn & {
12
- _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
13
- }) | undefined;
10
+ children?: Snippet<[{
11
+ project: IProject;
12
+ }]> | undefined;
14
13
  };
15
14
  events: {
16
15
  [evt: string]: CustomEvent<any>;
17
16
  };
18
- slots: {
19
- default: {
20
- project: import("@theatre/core").IProject;
21
- };
22
- };
17
+ slots: {};
23
18
  };
24
19
  export type ProjectProps = typeof __propDef.props;
25
20
  export type ProjectEvents = typeof __propDef.events;
26
21
  export type ProjectSlots = typeof __propDef.slots;
27
22
  export default class Project extends SvelteComponent<ProjectProps, ProjectEvents, ProjectSlots> {
28
- get project(): import("@theatre/core").IProject;
29
23
  }
30
24
  export {};
@@ -25,7 +25,7 @@ declare const __propDef: {
25
25
  rafDriver?: IRafDriver | undefined;
26
26
  } | undefined) => Promise<boolean>) | undefined;
27
27
  pause?: (() => void) | undefined;
28
- children?: ((this: void, args_0: {
28
+ children?: import("svelte").Snippet<[{
29
29
  sequence: import("./SequenceController").SequenceController;
30
30
  position: number;
31
31
  playing: boolean;
@@ -37,9 +37,7 @@ declare const __propDef: {
37
37
  rafDriver?: IRafDriver | undefined;
38
38
  } | undefined) => Promise<boolean>;
39
39
  pause: () => void;
40
- }) => typeof import("svelte").SnippetReturn & {
41
- _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
42
- }) | undefined;
40
+ }]> | undefined;
43
41
  };
44
42
  events: {
45
43
  [evt: string]: CustomEvent<any>;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="svelte" />
2
- /// <reference types="svelte" />
3
2
  import type { ISequence } from '@theatre/core';
4
3
  import type { Readable, Subscriber, Writable } from 'svelte/store';
5
4
  import { onChange } from '../theatre';
@@ -8,11 +8,9 @@ declare const __propDef: {
8
8
  instance?: string | undefined;
9
9
  sheet?: import("@theatre/core").ISheet | undefined;
10
10
  sequence?: SequenceController | undefined;
11
- children?: ((this: void, args_0: {
11
+ children?: import("svelte").Snippet<[{
12
12
  sheet: import("@theatre/core").ISheet;
13
- }) => typeof import("svelte").SnippetReturn & {
14
- _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
15
- }) | undefined;
13
+ }]> | undefined;
16
14
  };
17
15
  events: {
18
16
  [evt: string]: CustomEvent<any>;
@@ -9,7 +9,8 @@ import { getContext, onDestroy, onMount, setContext } from 'svelte';
9
9
  import Declare from './declare/Declare.svelte';
10
10
  import Sync from './sync/Sync.svelte';
11
11
  import Transform from './transform/Transform.svelte';
12
- let { key, detach = false, props, selected = $bindable(false), ...restProps } = $props();
12
+ import { createSheetContext } from './useSheet';
13
+ let { key, detach = false, props, selected = $bindable(false), onchange, children } = $props();
13
14
  const { invalidate } = useThrelte();
14
15
  let aggregatedProps = { ...props };
15
16
  const { sheet } = getContext('theatre-sheet');
@@ -21,7 +22,7 @@ onMount(() => {
21
22
  // values change, we're emitting the initial value here. Doing this in
22
23
  // onMount also means that child components which might add props to the
23
24
  // sheet object have already been mounted.
24
- restProps.$$events?.change?.(sheetObject.current.value);
25
+ onchange?.(sheetObject.current.value);
25
26
  });
26
27
  // This flag is used to prevent the sheet object from being created after it
27
28
  // has been detached.
@@ -69,15 +70,15 @@ const removeProps = (propNames) => {
69
70
  updateSheetObject();
70
71
  }
71
72
  };
72
- setContext('threlte-theater-sheet-context', {
73
+ createSheetContext({
73
74
  sheetObject,
74
75
  addProps,
75
76
  removeProps
76
77
  });
77
- let values = $sheetObject?.value;
78
+ let values = $state($sheetObject?.value);
78
79
  watch(sheetObject, (sheetObject) => {
79
80
  return sheetObject.onValuesChange((newValues) => {
80
- restProps.$$events?.change?.(newValues);
81
+ onchange?.(newValues);
81
82
  values = newValues;
82
83
  // this invalidation also invalidates changes catched by slotted
83
84
  // components such as <Sync> or <Declare>.
@@ -104,13 +105,13 @@ const deselect = () => {
104
105
  };
105
106
  </script>
106
107
 
107
- <slot
108
- {values}
109
- {selected}
110
- {select}
111
- {deselect}
112
- sheetObject={$sheetObject}
113
- {Sync}
114
- {Transform}
115
- {Declare}
116
- />
108
+ {@render children?.({
109
+ values,
110
+ selected,
111
+ select,
112
+ deselect,
113
+ sheetObject: $sheetObject,
114
+ Sync,
115
+ Transform,
116
+ Declare
117
+ })}
@@ -1,29 +1,32 @@
1
1
  import type { ISheetObject, UnknownShorthandCompoundProps } from '@theatre/core'
2
- import { SvelteComponent } from 'svelte'
2
+ import { SvelteComponent, type Snippet } from 'svelte'
3
3
  import type Declare from './declare/Declare.svelte'
4
4
  import type Sync from './sync/Sync.svelte'
5
5
  import type Transform from './transform/Transform.svelte'
6
6
 
7
+ export type SheetObjectProps<T> = {
8
+ key: string
9
+ detach?: boolean
10
+ selected?: boolean
11
+ props?: T
12
+
13
+ children?: Snippet<
14
+ [
15
+ {
16
+ values: ISheetObject['value']
17
+ selected: boolean
18
+ select: () => void
19
+ deselect: () => void
20
+ sheetObject: ISheetObject
21
+ Sync: typeof Sync
22
+ Transform: typeof Transform
23
+ Declare: typeof Declare
24
+ }
25
+ ]
26
+ >
27
+
28
+ onchange?: (sheet: ISheetObject['value']) => void
29
+ }
7
30
  export default class SheetObject<T extends UnknownShorthandCompoundProps> extends SvelteComponent<
8
- {
9
- key: string
10
- detach?: boolean
11
- selected?: boolean
12
- props?: T
13
- },
14
- {
15
- change: ISheetObject<T>['value']
16
- },
17
- {
18
- default: {
19
- values: ISheetObject<T>['value']
20
- selected: boolean
21
- select: () => void
22
- deselect: () => void
23
- sheetObject: ISheetObject<T>
24
- Sync: typeof Sync
25
- Transform: typeof Transform
26
- Declare: typeof Declare
27
- }
28
- }
31
+ SheetObjectProps<T>
29
32
  > {}
@@ -1,8 +1,9 @@
1
- <script lang="ts">import { watch, currentWritable } from '@threlte/core';
2
- import { onDestroy, getContext } from 'svelte';
3
- export let props;
4
- const { sheetObject, addProps, removeProps } = getContext('threlte-theater-sheet-context');
5
- let values = $sheetObject?.value;
1
+ <script lang="ts">import { watch } from '@threlte/core';
2
+ import { onDestroy } from 'svelte';
3
+ import { useSheet } from '../useSheet';
4
+ let { props, children } = $props();
5
+ const { sheetObject, addProps, removeProps } = useSheet();
6
+ let values = $state($sheetObject?.value);
6
7
  addProps(props);
7
8
  onDestroy(() => {
8
9
  removeProps(Object.keys(props));
@@ -14,4 +15,4 @@ watch(sheetObject, (sheetObject) => {
14
15
  });
15
16
  </script>
16
17
 
17
- <slot {values} />
18
+ {@render children?.({ values })}
@@ -1,14 +1,12 @@
1
1
  import type { ISheetObject, UnknownShorthandCompoundProps } from '@theatre/core'
2
- import type { SvelteComponent } from 'svelte'
2
+ import type { Snippet, SvelteComponent } from 'svelte'
3
+
4
+ export type DeclareProps<T extends UnknownShorthandCompoundProps> = {
5
+ props: T
6
+
7
+ children?: Snippet<[{ values: ISheetObject<T>['value'] }]>
8
+ }
3
9
 
4
10
  export default class Declare<T extends UnknownShorthandCompoundProps> extends SvelteComponent<
5
- {
6
- props: T
7
- },
8
- Record<string, unknown>,
9
- {
10
- default: {
11
- values: ISheetObject<T>['value']
12
- }
13
- }
11
+ DeclareProps<T>
14
12
  > {}
@@ -1,21 +1,21 @@
1
1
  <script lang="ts">import { resolvePropertyPath, useParent, watch } from '@threlte/core';
2
- import { onDestroy, getContext } from 'svelte';
2
+ import { onDestroy } from 'svelte';
3
3
  import { getInitialValue } from './utils/getInitialValue';
4
4
  import { isComplexProp } from './utils/isComplexProp';
5
5
  import { makeAlphanumeric } from './utils/makeAlphanumeric';
6
6
  import { parsePropLabel } from './utils/parsePropLabel';
7
7
  import { isStringProp } from './utils/isStringProp';
8
8
  import { useStudio } from '../../studio/useStudio';
9
- // used for type hinting auto props
10
- export let type = undefined;
11
- const { sheetObject, addProps, removeProps } = getContext('threlte-theater-sheet-context');
9
+ import { useSheet } from '../useSheet';
10
+ let { type, children, ...rest } = $props();
11
+ const { sheetObject, addProps, removeProps } = useSheet();
12
12
  const parent = useParent();
13
13
  // serves as a map to map (custom) prop names to object target properties
14
14
  let propMappings = {};
15
15
  const initProps = () => {
16
16
  const props = {};
17
17
  // propertyPath is for example "position.x" or "intensity", so a property path on the parent object
18
- Object.entries($$restProps).forEach(([propertyPath, propertyValue]) => {
18
+ Object.entries(rest).forEach(([propertyPath, propertyValue]) => {
19
19
  // The prop might have a custom name, for example "intensity" might be mapped to "light-intensity"
20
20
  const customKey = isComplexProp(propertyValue)
21
21
  ? propertyValue.key
@@ -96,4 +96,4 @@ onDestroy(() => {
96
96
  });
97
97
  </script>
98
98
 
99
- <slot {capture} />
99
+ {@render children?.({ capture })}
@@ -1,4 +1,4 @@
1
- import type { SvelteComponent } from 'svelte'
1
+ import type { Snippet, SvelteComponent } from 'svelte'
2
2
  import type { Transformer } from '../transfomers/types'
3
3
  import type { ConditionalKeys, Primitive } from 'type-fest'
4
4
 
@@ -54,18 +54,12 @@ type AnyProps<T> = {
54
54
  [P in keyof InstanceProps<T>]?: AnyProp
55
55
  }
56
56
 
57
- type AllProps<T> = AnyProps<T> &
57
+ export type SyncProps<T> = AnyProps<T> &
58
58
  ObjectProp<T> &
59
59
  Record<string, AnyProp | T> & {
60
60
  capture?: () => void
61
+ } & {
62
+ children?: Snippet<[{ capture: () => void }]>
61
63
  }
62
64
 
63
- export default class Sync<T> extends SvelteComponent<
64
- AllProps<T>,
65
- Record<string, any>,
66
- {
67
- default: {
68
- capture: () => void
69
- }
70
- }
71
- > {}
65
+ export default class Sync<T> extends SvelteComponent<SyncProps<T>> {}
@@ -1,40 +1,37 @@
1
1
  <script lang="ts">import { types } from '../../theatre';
2
- import { T, watch, currentWritable } from '@threlte/core';
2
+ import { T, watch } from '@threlte/core';
3
3
  import { TransformControls } from '@threlte/extras';
4
- import { onMount, getContext } from 'svelte';
4
+ import { onMount } from 'svelte';
5
5
  import { Group } from 'three';
6
6
  import { RAD2DEG } from 'three/src/math/MathUtils.js';
7
7
  import { useStudio } from '../../studio/useStudio';
8
8
  import { getDefaultTransformer } from '../transfomers/getDefaultTransformer';
9
- export let label = undefined;
10
- export let key = undefined;
11
- export let mode = 'translate';
12
- export let space = undefined;
13
- export let translationSnap = undefined;
14
- export let rotationSnap = undefined;
15
- export let scaleSnap = undefined;
16
- const { sheetObject, addProps, removeProps } = getContext('threlte-theater-sheet-context');
17
- let controls;
18
- $: if (controls) {
19
- if (translationSnap) {
20
- controls.setTranslationSnap(translationSnap);
21
- }
22
- else {
23
- controls.setTranslationSnap(null);
24
- }
25
- if (rotationSnap) {
26
- controls.setRotationSnap(rotationSnap);
27
- }
28
- else {
29
- controls.setRotationSnap(null);
30
- }
31
- if (scaleSnap) {
32
- controls.setScaleSnap(scaleSnap);
33
- }
34
- else {
35
- controls.setScaleSnap(null);
9
+ import { useSheet } from '../useSheet';
10
+ let { label, key, mode = 'translate', space, translationSnap, rotationSnap, scaleSnap, children } = $props();
11
+ const { sheetObject, addProps, removeProps } = useSheet();
12
+ let controls = $state(undefined);
13
+ $effect.pre(() => {
14
+ if (controls) {
15
+ if (translationSnap) {
16
+ controls.setTranslationSnap(translationSnap);
17
+ }
18
+ else {
19
+ controls.setTranslationSnap(null);
20
+ }
21
+ if (rotationSnap) {
22
+ controls.setRotationSnap(rotationSnap);
23
+ }
24
+ else {
25
+ controls.setRotationSnap(null);
26
+ }
27
+ if (scaleSnap) {
28
+ controls.setScaleSnap(scaleSnap);
29
+ }
30
+ else {
31
+ controls.setScaleSnap(null);
32
+ }
36
33
  }
37
- }
34
+ });
38
35
  const group = new Group();
39
36
  const positionTransformer = getDefaultTransformer(group, 'position', 'position');
40
37
  const rotationTransformer = getDefaultTransformer(group, 'rotation', 'rotation');
@@ -90,7 +87,7 @@ onMount(() => {
90
87
  });
91
88
  const studio = useStudio();
92
89
  let scrub;
93
- let isSelected = false;
90
+ let isSelected = $state(false);
94
91
  watch([studio], ([studio]) => {
95
92
  return studio?.onSelectionChange((selection) => {
96
93
  if (!$sheetObject)
@@ -141,11 +138,11 @@ const groupRef = group;
141
138
  {mode}
142
139
  {space}
143
140
  bind:controls
144
- on:mouseDown={onMouseDown}
145
- on:objectChange={onChange}
146
- on:mouseUp={onMouseUp}
141
+ onmouseDown={onMouseDown}
142
+ onobjectChange={onChange}
143
+ onmouseUp={onMouseUp}
147
144
  />
148
145
  {/if}
149
146
 
150
- <slot />
147
+ {@render children?.()}
151
148
  </T>
@@ -1,20 +1,22 @@
1
- import type { SvelteComponent } from 'svelte'
1
+ import type { Snippet, SvelteComponent } from 'svelte'
2
+
3
+ export type TransformProps<T extends string | undefined> = {
4
+ label?: T
5
+ mode?: 'translate' | 'rotate' | 'scale'
6
+ translationSnap?: number
7
+ rotationSnap?: number
8
+ scaleSnap?: number
9
+ space?: 'world' | 'local'
10
+
11
+ children?: Snippet
12
+ } & (T extends string
13
+ ? {
14
+ key: string
15
+ }
16
+ : {
17
+ key?: string
18
+ })
2
19
 
3
20
  export default class Transform<Label extends string | undefined> extends SvelteComponent<
4
- {
5
- label?: Label
6
- mode?: 'translate' | 'rotate' | 'scale'
7
- translationSnap?: number
8
- rotationSnap?: number
9
- scaleSnap?: number
10
- space?: 'world' | 'local'
11
- } & (Label extends string
12
- ? {
13
- key: string
14
- }
15
- : {
16
- key?: string
17
- }),
18
- Record<string, unknown>,
19
- Record<string, unknown>
21
+ TransformProps<Label>
20
22
  > {}
@@ -0,0 +1,10 @@
1
+ import type { ISheetObject, UnknownShorthandCompoundProps } from '@theatre/core';
2
+ import type { CurrentWritable } from '@threlte/core';
3
+ interface Context {
4
+ sheetObject: CurrentWritable<ISheetObject<any>>;
5
+ addProps: (props: UnknownShorthandCompoundProps) => void;
6
+ removeProps: (names: string[]) => void;
7
+ }
8
+ export declare const createSheetContext: (context: Context) => void;
9
+ export declare const useSheet: () => Context;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ const key = 'threlte-theater-sheet-context';
3
+ export const createSheetContext = (context) => {
4
+ setContext(key, context);
5
+ };
6
+ export const useSheet = () => {
7
+ return getContext(key);
8
+ };
@@ -2,9 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  hide: boolean;
5
- children?: ((this: void) => typeof import("svelte").SnippetReturn & {
6
- _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
7
- }) | undefined;
5
+ children?: import("svelte").Snippet<[]> | undefined;
8
6
  };
9
7
  events: {
10
8
  [evt: string]: CustomEvent<any>;
@@ -3,9 +3,7 @@ declare const __propDef: {
3
3
  props: {
4
4
  enabled?: boolean | undefined;
5
5
  hide?: boolean | undefined;
6
- children?: ((this: void) => typeof import("svelte").SnippetReturn & {
7
- _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
8
- }) | undefined;
6
+ children?: import("svelte").Snippet<[]> | undefined;
9
7
  };
10
8
  events: {
11
9
  [evt: string]: CustomEvent<any>;
@@ -7,9 +7,7 @@ declare const __propDef: {
7
7
  hide?: boolean | undefined;
8
8
  } | undefined;
9
9
  config?: IProjectConfig | undefined;
10
- children?: ((this: void) => typeof import("svelte").SnippetReturn & {
11
- _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
12
- }) | undefined;
10
+ children?: import("svelte").Snippet<[]> | undefined;
13
11
  };
14
12
  events: {
15
13
  [evt: string]: CustomEvent<any>;
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@threlte/theatre",
3
- "version": "3.0.0-next.1",
3
+ "version": "3.0.0-next.3",
4
4
  "author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
5
5
  "license": "MIT",
6
+ "description": "Threlte Components for Theatre, an animation library with a professional motion design toolset",
6
7
  "devDependencies": {
7
8
  "@sveltejs/adapter-auto": "^3.2.0",
8
9
  "@sveltejs/kit": "^2.5.5",
9
10
  "@sveltejs/package": "^2.3.1",
10
11
  "@sveltejs/vite-plugin-svelte": "^3.1.0",
11
12
  "@types/node": "^20.12.7",
12
- "@types/three": "^0.163.0",
13
+ "@types/three": "^0.165.0",
13
14
  "@typescript-eslint/eslint-plugin": "^7.6.0",
14
15
  "@typescript-eslint/parser": "^7.6.0",
15
16
  "@yushijinhun/three-minifier-rollup": "^0.4.0",
@@ -20,27 +21,46 @@
20
21
  "prettier-plugin-svelte": "^3.2.2",
21
22
  "publint": "^0.2.7",
22
23
  "rimraf": "^5.0.5",
23
- "svelte": "^5.0.0-next.95",
24
+ "svelte": "^5.0.0-next.181",
24
25
  "svelte-check": "^3.6.9",
25
26
  "svelte-preprocess": "^5.1.3",
26
27
  "svelte2tsx": "^0.7.6",
27
- "three": "^0.163.0",
28
+ "three": "^0.165.0",
28
29
  "tslib": "^2.6.2",
29
30
  "type-fest": "^4.15.0",
30
31
  "typescript": "^5.4.5",
31
32
  "vite": "^5.2.8",
32
- "@threlte/core": "8.0.0-next.2",
33
- "@threlte/extras": "9.0.0-next.2"
33
+ "@threlte/core": "8.0.0-next.10",
34
+ "@threlte/extras": "9.0.0-next.15"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "svelte": ">=4",
37
- "three": ">=0.152",
38
+ "three": ">=0.155",
38
39
  "@threlte/core": ">=8.0.0-next.0",
39
40
  "@threlte/extras": ">=9.0.0-next.0",
40
41
  "@theatre/core": ">=0.6",
41
42
  "@theatre/studio": ">=0.6"
42
43
  },
43
44
  "type": "module",
45
+ "keywords": [
46
+ "theatre",
47
+ "threlte",
48
+ "svelte",
49
+ "three",
50
+ "three.js",
51
+ "3d",
52
+ "animation",
53
+ "motion"
54
+ ],
55
+ "homepage": "https://threlte.xyz",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "https://github.com/threlte/threlte.git",
59
+ "directory": "packages/theatre"
60
+ },
61
+ "bugs": {
62
+ "url": "https://github.com/threlte/threlte/issues"
63
+ },
44
64
  "exports": {
45
65
  ".": {
46
66
  "types": "./dist/index.d.ts",
@@ -57,8 +77,8 @@
57
77
  "package": "svelte-kit sync && svelte-package && node ./scripts/cleanupPackage.js && publint",
58
78
  "check": "svelte-check --tsconfig ./tsconfig.json",
59
79
  "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
60
- "lint": "prettier --check --plugin-search-dir=. . && eslint .",
61
- "format": "prettier --write --plugin-search-dir=. .",
80
+ "lint": "prettier --check .",
81
+ "format": "prettier --write .",
62
82
  "cleanup": "rimraf node_modules .svelte-kit dist"
63
83
  }
64
84
  }