@threlte/theatre 3.1.2 → 3.2.1

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.
@@ -95,9 +95,9 @@
95
95
  positionChangedBy = 'code'
96
96
  position = value
97
97
  })
98
- $: position,
98
+ $: (position,
99
99
  positionChangedBy === 'user' && ($positionStore = position),
100
- (positionChangedBy = 'user')
100
+ (positionChangedBy = 'user'))
101
101
 
102
102
  // playing
103
103
  let playingChangedBy = 'user'
@@ -105,7 +105,9 @@
105
105
  playingChangedBy = 'code'
106
106
  playing = value
107
107
  })
108
- $: playing, playingChangedBy === 'user' && ($playingStore = playing), (playingChangedBy = 'user')
108
+ $: (playing,
109
+ playingChangedBy === 'user' && ($playingStore = playing),
110
+ (playingChangedBy = 'user'))
109
111
 
110
112
  // pass sequence to children via context
111
113
  setContext('theatre-sequence', sequence)
@@ -9,7 +9,7 @@
9
9
  >
10
10
  import { useStudio } from '../studio/useStudio.js'
11
11
  import type { ISheetObject, UnknownShorthandCompoundProps } from '@theatre/core'
12
- import { currentWritable, useThrelte, watch, type CurrentWritable } from '@threlte/core'
12
+ import { currentWritable, useThrelte, observe, type CurrentWritable } from '@threlte/core'
13
13
  import { getContext, onDestroy, onMount } from 'svelte'
14
14
  import type { SheetContext } from '../sheet/types.js'
15
15
  import Declare from './declare/Declare.svelte'
@@ -108,25 +108,31 @@
108
108
 
109
109
  let values = $state($sheetObject?.value)
110
110
 
111
- watch(sheetObject, (sheetObject) => {
112
- return sheetObject.onValuesChange((newValues) => {
113
- onchange?.(newValues)
114
- values = newValues
115
- // this invalidation also invalidates changes catched by slotted
116
- // components such as <Sync> or <Declare>.
117
- invalidate()
118
- })
119
- })
111
+ observe.pre(
112
+ () => [sheetObject],
113
+ ([sheetObject]) => {
114
+ return sheetObject.onValuesChange((newValues) => {
115
+ onchange?.(newValues)
116
+ values = newValues
117
+ // this invalidation also invalidates changes catched by slotted
118
+ // components such as <Sync> or <Declare>.
119
+ invalidate()
120
+ })
121
+ }
122
+ )
120
123
 
121
124
  // Provide a flag to indicate whether this sheet object is selected in the
122
125
  // Theatre.js studio.
123
126
  const studio = useStudio()
124
127
 
125
- watch([studio, sheetObject], ([studio, sheetObject]) => {
126
- return studio?.onSelectionChange((selection) => {
127
- selected = selection.includes(sheetObject)
128
- })
129
- })
128
+ observe.pre(
129
+ () => [studio, sheetObject],
130
+ ([studio, sheetObject]) => {
131
+ return studio?.onSelectionChange((selection) => {
132
+ selected = selection.includes(sheetObject)
133
+ })
134
+ }
135
+ )
130
136
 
131
137
  // Provide a select function to select this sheet object in the Theatre.js
132
138
  // studio.
@@ -3,7 +3,7 @@
3
3
  generics="P extends UnknownShorthandCompoundProps"
4
4
  >
5
5
  import type { UnknownShorthandCompoundProps } from '@theatre/core'
6
- import { watch } from '@threlte/core'
6
+ import { observe } from '@threlte/core'
7
7
  import { onDestroy } from 'svelte'
8
8
  import { useSheet } from '../useSheet.js'
9
9
  import type { DeclareProps } from './types.js'
@@ -20,11 +20,14 @@
20
20
  removeProps(Object.keys(props))
21
21
  })
22
22
 
23
- watch(sheetObject, (sheetObject) => {
24
- return sheetObject?.onValuesChange((v) => {
25
- values = v
26
- })
27
- })
23
+ observe.pre(
24
+ () => [sheetObject],
25
+ ([sheetObject]) => {
26
+ return sheetObject?.onValuesChange((v) => {
27
+ values = v
28
+ })
29
+ }
30
+ )
28
31
  </script>
29
32
 
30
33
  {@render children?.({ values })}
@@ -2,7 +2,7 @@
2
2
  lang="ts"
3
3
  generics="Type"
4
4
  >
5
- import { resolvePropertyPath, useParent, watch } from '@threlte/core'
5
+ import { resolvePropertyPath, useParent, observe } from '@threlte/core'
6
6
  import { onDestroy } from 'svelte'
7
7
  import { useStudio } from '../../studio/useStudio.js'
8
8
  import type { Transformer } from '../transfomers/types.js'
@@ -75,34 +75,37 @@
75
75
  'aspect'
76
76
  ]
77
77
 
78
- watch([parent, sheetObject], ([parent, sheetObject]) => {
79
- if (!parent) return
78
+ observe.pre(
79
+ () => [parent, sheetObject],
80
+ ([parent, sheetObject]) => {
81
+ if (!parent) return
80
82
 
81
- return sheetObject?.onValuesChange((values) => {
82
- // Ensure that the parent is still mounted
83
+ return sheetObject?.onValuesChange((values) => {
84
+ // Ensure that the parent is still mounted
83
85
 
84
- Object.keys(values).forEach((key) => {
85
- // first, check if the prop is mapped in this component
86
- const propMapping = propMappings[key]
86
+ Object.keys(values).forEach((key) => {
87
+ // first, check if the prop is mapped in this component
88
+ const propMapping = propMappings[key]
87
89
 
88
- if (!propMapping) return
90
+ if (!propMapping) return
89
91
 
90
- // we're using the addedProps map to infer the target property name from the property name on values
91
- const { target, key: targetKey } = resolvePropertyPath(
92
- parent as any,
93
- propMapping.propertyPath
94
- )
92
+ // we're using the addedProps map to infer the target property name from the property name on values
93
+ const { target, key: targetKey } = resolvePropertyPath(
94
+ parent as any,
95
+ propMapping.propertyPath
96
+ )
95
97
 
96
- // use a transformer to apply value
97
- const transformer = propMapping.transformer
98
- transformer.apply(target, targetKey, values[key])
98
+ // use a transformer to apply value
99
+ const transformer = propMapping.transformer
100
+ transformer.apply(target, targetKey, values[key])
99
101
 
100
- if (updateProjectionMatrixKeys.includes(targetKey)) {
101
- target.updateProjectionMatrix?.()
102
- }
102
+ if (updateProjectionMatrixKeys.includes(targetKey)) {
103
+ target.updateProjectionMatrix?.()
104
+ }
105
+ })
103
106
  })
104
- })
105
- })
107
+ }
108
+ )
106
109
 
107
110
  initProps()
108
111
 
@@ -3,7 +3,7 @@
3
3
  generics="Label extends string | undefined"
4
4
  >
5
5
  import type { IScrub } from '@theatre/studio'
6
- import { T, watch } from '@threlte/core'
6
+ import { T, observe } from '@threlte/core'
7
7
  import { TransformControls } from '@threlte/extras'
8
8
  import { onMount } from 'svelte'
9
9
  import { Group } from 'three'
@@ -83,25 +83,28 @@
83
83
  }
84
84
  }
85
85
 
86
- watch([sheetObject], ([sheetObject]) => {
87
- return sheetObject?.onValuesChange((values) => {
88
- let object = values
89
-
90
- if (key) {
91
- if (!values[key]) return
92
- object = values[key]
93
- } else {
94
- if (!values.position || !values.rotation || !values.scale) return
95
- }
96
-
97
- // sanity check
98
- if (!object) return
99
-
100
- positionTransformer.apply(group, 'position', object.position)
101
- rotationTransformer.apply(group, 'rotation', object.rotation)
102
- scaleTransformer.apply(group, 'scale', object.scale)
103
- })
104
- })
86
+ observe.pre(
87
+ () => [sheetObject],
88
+ ([sheetObject]) => {
89
+ return sheetObject?.onValuesChange((values) => {
90
+ let object = values
91
+
92
+ if (key) {
93
+ if (!values[key]) return
94
+ object = values[key]
95
+ } else {
96
+ if (!values.position || !values.rotation || !values.scale) return
97
+ }
98
+
99
+ // sanity check
100
+ if (!object) return
101
+
102
+ positionTransformer.apply(group, 'position', object.position)
103
+ rotationTransformer.apply(group, 'rotation', object.rotation)
104
+ scaleTransformer.apply(group, 'scale', object.scale)
105
+ })
106
+ }
107
+ )
105
108
 
106
109
  onMount(() => {
107
110
  initTransform()
@@ -114,12 +117,15 @@
114
117
  let scrub: IScrub | undefined
115
118
  let isSelected = $state(false)
116
119
 
117
- watch([studio], ([studio]) => {
118
- return studio?.onSelectionChange((selection) => {
119
- if (!$sheetObject) return
120
- isSelected = selection.includes($sheetObject)
121
- })
122
- })
120
+ observe.pre(
121
+ () => [studio],
122
+ ([studio]) => {
123
+ return studio?.onSelectionChange((selection) => {
124
+ if (!$sheetObject) return
125
+ isSelected = selection.includes($sheetObject)
126
+ })
127
+ }
128
+ )
123
129
 
124
130
  const onMouseDown = () => {
125
131
  if (!studio.current) return
@@ -10,7 +10,7 @@
10
10
  </script>
11
11
 
12
12
  <script lang="ts">
13
- import { watch } from '@threlte/core'
13
+ import { observe } from '@threlte/core'
14
14
  import { writable } from 'svelte/store'
15
15
 
16
16
  interface Props {
@@ -25,17 +25,20 @@
25
25
  hideStore.set(hide)
26
26
  })
27
27
 
28
- watch([studio, hideStore], ([studio, hide]) => {
29
- if (hide) {
30
- studio?.ui.hide()
31
- } else {
32
- studio?.ui.restore()
28
+ observe.pre(
29
+ () => [studio, hideStore],
30
+ ([studio, hide]) => {
31
+ if (hide) {
32
+ studio?.ui.hide()
33
+ } else {
34
+ studio?.ui.restore()
35
+ }
36
+
37
+ return () => {
38
+ studio?.ui.hide()
39
+ }
33
40
  }
34
-
35
- return () => {
36
- studio?.ui.hide()
37
- }
38
- })
41
+ )
39
42
  </script>
40
43
 
41
44
  {@render children?.()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threlte/theatre",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
5
5
  "license": "MIT",
6
6
  "description": "Threlte Components for Theatre, an animation library with a professional motion design toolset",
@@ -16,21 +16,20 @@
16
16
  "eslint": "^9.26.0",
17
17
  "eslint-plugin-svelte": "^3.5.1",
18
18
  "globals": "^16.1.0",
19
- "prettier": "^3.2.5",
20
- "prettier-plugin-svelte": "^3.2.2",
19
+ "prettier": "^3.8.1",
20
+ "prettier-plugin-svelte": "^3.5.1",
21
21
  "publint": "^0.2.7",
22
22
  "rimraf": "^6.0.1",
23
- "svelte": "5.26.2",
23
+ "svelte": "5.53.6",
24
24
  "svelte-check": "^4.3.1",
25
- "svelte2tsx": "^0.7.6",
26
25
  "three": "^0.175.0",
27
26
  "tslib": "^2.6.2",
28
27
  "type-fest": "^4.15.0",
29
28
  "typescript": "5.9.2",
30
29
  "typescript-eslint": "^8.32.0",
31
30
  "vite": "^7.1.4",
32
- "@threlte/core": "8.3.0",
33
- "@threlte/extras": "9.7.1"
31
+ "@threlte/core": "8.5.1",
32
+ "@threlte/extras": "9.12.1"
34
33
  },
35
34
  "peerDependencies": {
36
35
  "@theatre/core": ">=0.6",
@@ -54,7 +53,7 @@
54
53
  "homepage": "https://threlte.xyz",
55
54
  "repository": {
56
55
  "type": "git",
57
- "url": "https://github.com/threlte/threlte.git",
56
+ "url": "https://github.com/threlte/threlte",
58
57
  "directory": "packages/theatre"
59
58
  },
60
59
  "bugs": {