@threlte/theatre 2.0.0 → 2.1.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.
- package/dist/sequence/Sequence.svelte +1 -1
- package/dist/sequence/SequenceController.d.ts +2 -1
- package/dist/sequence/SequenceController.js +1 -1
- package/dist/sheetObject/sync/Sync.svelte +22 -0
- package/dist/sheetObject/sync/Sync.svelte.d.ts +12 -4
- package/dist/sheetObject/transfomers/defaults/color.js +1 -1
- package/dist/sheetObject/transfomers/defaults/degrees.js +1 -1
- package/dist/sheetObject/transfomers/defaults/euler.js +1 -1
- package/dist/sheetObject/transfomers/defaults/generic.js +1 -1
- package/dist/sheetObject/transfomers/defaults/normalized.js +1 -1
- package/dist/sheetObject/transfomers/defaults/side.js +1 -1
- package/dist/sheetObject/transform/Transform.svelte +1 -1
- package/dist/studio/InnerStudio.svelte +4 -1
- package/dist/studio/Studio.svelte +4 -1
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ISequence } from '@theatre/core';
|
|
2
2
|
import type { Readable, Subscriber, Writable } from 'svelte/store';
|
|
3
|
+
import { onChange } from '../theatre';
|
|
3
4
|
import type { SequenceOptions } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* ### `SequenceController`
|
|
@@ -5,6 +5,7 @@ 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
|
+
import { useStudio } from '../../studio/useStudio';
|
|
8
9
|
// used for type hinting auto props
|
|
9
10
|
export let type = undefined;
|
|
10
11
|
/** @package */
|
|
@@ -76,7 +77,28 @@ watch([parent, sheetObject], ([parent, sheetObject]) => {
|
|
|
76
77
|
});
|
|
77
78
|
});
|
|
78
79
|
initProps();
|
|
80
|
+
const studio = useStudio();
|
|
81
|
+
export const capture = () => {
|
|
82
|
+
if (!$studio)
|
|
83
|
+
return;
|
|
84
|
+
const scrub = $studio.scrub();
|
|
85
|
+
Object.keys(sheetObject.current.value).forEach((key) => {
|
|
86
|
+
// first, check if the prop is mapped in this component
|
|
87
|
+
const propMapping = propMappings[key];
|
|
88
|
+
if (!propMapping)
|
|
89
|
+
return;
|
|
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($parent, propMapping.propertyPath);
|
|
92
|
+
const value = propMapping.transformer.transform(target[targetKey]).default;
|
|
93
|
+
scrub.capture(({ set }) => {
|
|
94
|
+
set(sheetObject.current.props[key], value);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
scrub.commit();
|
|
98
|
+
};
|
|
79
99
|
onDestroy(() => {
|
|
80
100
|
removeProps(Object.keys(propMappings));
|
|
81
101
|
});
|
|
82
102
|
</script>
|
|
103
|
+
|
|
104
|
+
<slot {capture} />
|
|
@@ -2,7 +2,7 @@ import type { SvelteComponent } from 'svelte'
|
|
|
2
2
|
import type { Transformer } from '../transfomers/types'
|
|
3
3
|
import type { ConditionalKeys, Primitive } from 'type-fest'
|
|
4
4
|
|
|
5
|
-
/* COPIED FROM @
|
|
5
|
+
/* COPIED FROM @threlte/core START */
|
|
6
6
|
type OmittedPropKeys =
|
|
7
7
|
| 'type'
|
|
8
8
|
| 'args'
|
|
@@ -36,7 +36,7 @@ type InstanceProps<Type extends any> = Partial<
|
|
|
36
36
|
ConditionalKeys<MaybeInstance<Type>, AnyFn> | OmittedPropKeys
|
|
37
37
|
>
|
|
38
38
|
>
|
|
39
|
-
/* COPIED FROM @
|
|
39
|
+
/* COPIED FROM @threlte/core END */
|
|
40
40
|
|
|
41
41
|
type ObjectProp<T> = {
|
|
42
42
|
type?: T
|
|
@@ -54,10 +54,18 @@ type AnyProps<T> = {
|
|
|
54
54
|
[P in keyof InstanceProps<T>]?: AnyProp
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
type AllProps<T> = AnyProps<T> &
|
|
57
|
+
type AllProps<T> = AnyProps<T> &
|
|
58
|
+
ObjectProp<T> &
|
|
59
|
+
Record<string, AnyProp | T> & {
|
|
60
|
+
capture?: () => void
|
|
61
|
+
}
|
|
58
62
|
|
|
59
63
|
export default class Sync<T> extends SvelteComponent<
|
|
60
64
|
AllProps<T>,
|
|
61
65
|
Record<string, any>,
|
|
62
|
-
|
|
66
|
+
{
|
|
67
|
+
default: {
|
|
68
|
+
capture: () => void
|
|
69
|
+
}
|
|
70
|
+
}
|
|
63
71
|
> {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils';
|
|
2
2
|
import { createTransformer } from '../createTransformer';
|
|
3
|
-
import { types } from '
|
|
3
|
+
import { types } from '../../../theatre';
|
|
4
4
|
export const degrees = createTransformer({
|
|
5
5
|
transform(target) {
|
|
6
6
|
return types.number(target * RAD2DEG);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { types } from '@theatre/core';
|
|
2
1
|
import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils';
|
|
3
2
|
import { createTransformer } from '../createTransformer';
|
|
3
|
+
import { types } from '../../../theatre';
|
|
4
4
|
export const euler = createTransformer({
|
|
5
5
|
transform(value) {
|
|
6
6
|
return types.compound({
|
|
@@ -5,7 +5,10 @@ const browser = typeof window !== 'undefined';
|
|
|
5
5
|
|
|
6
6
|
{#if browser && enabled}
|
|
7
7
|
{#await import('./InnerStudio.svelte') then Component}
|
|
8
|
-
<svelte:component
|
|
8
|
+
<svelte:component
|
|
9
|
+
this={Component.default}
|
|
10
|
+
{hide}
|
|
11
|
+
>
|
|
9
12
|
<slot />
|
|
10
13
|
</svelte:component>
|
|
11
14
|
{/await}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/theatre",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"devDependencies": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"type-fest": "^2.13.0",
|
|
29
29
|
"typescript": "^5.0.0",
|
|
30
30
|
"vite": "^4.3.6",
|
|
31
|
-
"@threlte/core": "6.0.
|
|
32
|
-
"@threlte/extras": "5.
|
|
31
|
+
"@threlte/core": "6.0.5",
|
|
32
|
+
"@threlte/extras": "5.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"svelte": ">=4",
|