@threlte/theatre 2.1.6 → 3.0.0-next.0

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,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import type { IProjectConfig } from '@theatre/core';
3
3
  declare const __propDef: {
4
4
  props: {
@@ -19,7 +19,7 @@ declare const __propDef: {
19
19
  export type ProjectProps = typeof __propDef.props;
20
20
  export type ProjectEvents = typeof __propDef.events;
21
21
  export type ProjectSlots = typeof __propDef.slots;
22
- export default class Project extends SvelteComponentTyped<ProjectProps, ProjectEvents, ProjectSlots> {
22
+ export default class Project extends SvelteComponent<ProjectProps, ProjectEvents, ProjectSlots> {
23
23
  get project(): import("@theatre/core").IProject;
24
24
  }
25
25
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import type { IRafDriver } from '@theatre/core';
3
3
  import type { Autoreset, IterationCount, PlaybackDirection, PlaybackRange, SequenceAudioOptions } from './types';
4
4
  declare const __propDef: {
@@ -48,7 +48,7 @@ declare const __propDef: {
48
48
  export type SequenceProps = typeof __propDef.props;
49
49
  export type SequenceEvents = typeof __propDef.events;
50
50
  export type SequenceSlots = typeof __propDef.slots;
51
- export default class Sequence extends SvelteComponentTyped<SequenceProps, SequenceEvents, SequenceSlots> {
51
+ export default class Sequence extends SvelteComponent<SequenceProps, SequenceEvents, SequenceSlots> {
52
52
  get sequence(): import("./SequenceController").SequenceController;
53
53
  get length(): number;
54
54
  get play(): (conf?: {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="svelte" />
2
+ /// <reference types="svelte" />
2
3
  import type { ISequence } from '@theatre/core';
3
4
  import type { Readable, Subscriber, Writable } from 'svelte/store';
4
5
  import { onChange } from '../theatre';
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import type { IProject } from '@theatre/core';
3
3
  import { SequenceController } from '../sequence/SequenceController';
4
4
  declare const __propDef: {
@@ -21,7 +21,7 @@ declare const __propDef: {
21
21
  export type SheetProps = typeof __propDef.props;
22
22
  export type SheetEvents = typeof __propDef.events;
23
23
  export type SheetSlots = typeof __propDef.slots;
24
- export default class Sheet extends SvelteComponentTyped<SheetProps, SheetEvents, SheetSlots> {
24
+ export default class Sheet extends SvelteComponent<SheetProps, SheetEvents, SheetSlots> {
25
25
  get project(): IProject;
26
26
  get sheet(): import("@theatre/core").ISheet;
27
27
  get sequence(): SequenceController;
@@ -4,27 +4,24 @@
4
4
  - Potentially Providing a sheet object
5
5
  -->
6
6
  <script>import { useStudio } from '../studio/useStudio';
7
- import { createRawEventDispatcher, currentWritable, watch, useThrelte } from '@threlte/core';
8
- import { getContext, onDestroy, onMount } from 'svelte';
7
+ import { currentWritable, watch, useThrelte } from '@threlte/core';
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
- export let key;
13
- export let detach = false;
14
- export let props = undefined;
12
+ let { key, detach = false, props, selected = $bindable(false), ...restProps } = $props();
15
13
  const { invalidate } = useThrelte();
16
14
  let aggregatedProps = { ...props };
17
15
  const { sheet } = getContext('theatre-sheet');
18
16
  const sheetObject = currentWritable(sheet.object(key, aggregatedProps, {
19
17
  reconfigure: true
20
18
  }));
21
- const dispatch = createRawEventDispatcher();
22
19
  onMount(() => {
23
20
  // Because the sheet object value subscription is not running before any
24
21
  // values change, we're emitting the initial value here. Doing this in
25
22
  // onMount also means that child components which might add props to the
26
23
  // sheet object have already been mounted.
27
- dispatch('change', sheetObject.current.value);
24
+ restProps.$$events?.change?.(sheetObject.current.value);
28
25
  });
29
26
  // This flag is used to prevent the sheet object from being created after it
30
27
  // has been detached.
@@ -72,36 +69,15 @@ const removeProps = (propNames) => {
72
69
  updateSheetObject();
73
70
  }
74
71
  };
75
- const augmentConstructorArgs = (args) => {
76
- return {
77
- ...args,
78
- props: {
79
- ...args.props,
80
- sheetObject,
81
- addProps,
82
- removeProps
83
- }
84
- };
85
- };
86
- const proxySyncComponent = new Proxy(Sync, {
87
- construct(_target, [args]) {
88
- return new Sync(augmentConstructorArgs(args));
89
- }
90
- });
91
- const proxyTransformComponent = new Proxy(Transform, {
92
- construct(_target, [args]) {
93
- return new Transform(augmentConstructorArgs(args));
94
- }
95
- });
96
- const proxyDeclareComponent = new Proxy(Declare, {
97
- construct(_target, [args]) {
98
- return new Declare(augmentConstructorArgs(args));
99
- }
72
+ setContext('threlte-theater-sheet-context', {
73
+ sheetObject,
74
+ addProps,
75
+ removeProps
100
76
  });
101
77
  let values = $sheetObject?.value;
102
78
  watch(sheetObject, (sheetObject) => {
103
79
  return sheetObject.onValuesChange((newValues) => {
104
- dispatch('change', newValues);
80
+ restProps.$$events?.change?.(newValues);
105
81
  values = newValues;
106
82
  // this invalidation also invalidates changes catched by slotted
107
83
  // components such as <Sync> or <Declare>.
@@ -111,7 +87,6 @@ watch(sheetObject, (sheetObject) => {
111
87
  // Provide a flag to indicate whether this sheet object is selected in the
112
88
  // Theatre.js studio.
113
89
  const studio = useStudio();
114
- export let selected = false;
115
90
  watch([studio, sheetObject], ([studio, sheetObject]) => {
116
91
  return studio?.onSelectionChange((selection) => {
117
92
  selected = selection.includes(sheetObject);
@@ -135,7 +110,7 @@ const deselect = () => {
135
110
  {select}
136
111
  {deselect}
137
112
  sheetObject={$sheetObject}
138
- Sync={proxySyncComponent}
139
- Transform={proxyTransformComponent}
140
- Declare={proxyDeclareComponent}
113
+ {Sync}
114
+ {Transform}
115
+ {Declare}
141
116
  />
@@ -1,19 +1,14 @@
1
- <script>import { watch } from '@threlte/core';
2
- import { onDestroy } from 'svelte';
1
+ <script>import { watch, currentWritable } from '@threlte/core';
2
+ import { onDestroy, getContext } from 'svelte';
3
3
  export let props;
4
- /** @package */
5
- export let sheetObject;
6
- /** @package */
7
- export let addProps;
8
- /** @package */
9
- export let removeProps;
4
+ const { sheetObject, addProps, removeProps } = getContext('threlte-theater-sheet-context');
10
5
  let values = $sheetObject?.value;
11
6
  addProps(props);
12
7
  onDestroy(() => {
13
8
  removeProps(Object.keys(props));
14
9
  });
15
10
  watch(sheetObject, (sheetObject) => {
16
- return sheetObject.onValuesChange((v) => {
11
+ return sheetObject?.onValuesChange((v) => {
17
12
  values = v;
18
13
  });
19
14
  });
@@ -1,5 +1,5 @@
1
1
  <script>import { resolvePropertyPath, useParent, watch } from '@threlte/core';
2
- import { onDestroy } from 'svelte';
2
+ import { onDestroy, getContext } from 'svelte';
3
3
  import { getInitialValue } from './utils/getInitialValue';
4
4
  import { isComplexProp } from './utils/isComplexProp';
5
5
  import { makeAlphanumeric } from './utils/makeAlphanumeric';
@@ -8,12 +8,7 @@ import { isStringProp } from './utils/isStringProp';
8
8
  import { useStudio } from '../../studio/useStudio';
9
9
  // used for type hinting auto props
10
10
  export let type = undefined;
11
- /** @package */
12
- export let sheetObject;
13
- /** @package */
14
- export let addProps;
15
- /** @package */
16
- export let removeProps;
11
+ const { sheetObject, addProps, removeProps } = getContext('threlte-theater-sheet-context');
17
12
  const parent = useParent();
18
13
  // serves as a map to map (custom) prop names to object target properties
19
14
  let propMappings = {};
@@ -30,8 +30,8 @@ type InstanceProps<Type extends any> = Partial<
30
30
  | Parameters<MaybeInstance<Type>[K]['set']>
31
31
  | Parameters<MaybeInstance<Type>[K]['set']>[0]
32
32
  : MaybeInstance<Type>[K] extends AnyFn
33
- ? never
34
- : MaybeInstance<Type>[K]
33
+ ? never
34
+ : MaybeInstance<Type>[K]
35
35
  },
36
36
  ConditionalKeys<MaybeInstance<Type>, AnyFn> | OmittedPropKeys
37
37
  >
@@ -1,4 +1,4 @@
1
- import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils';
1
+ import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils.js';
2
2
  import { createTransformer } from '../createTransformer';
3
3
  import { types } from '../../../theatre';
4
4
  export const degrees = createTransformer({
@@ -1,4 +1,4 @@
1
- import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils';
1
+ import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils.js';
2
2
  import { createTransformer } from '../createTransformer';
3
3
  import { types } from '../../../theatre';
4
4
  export const euler = createTransformer({
@@ -1,4 +1,3 @@
1
- import { Color, Euler } from 'three';
2
1
  import { color } from './defaults/color';
3
2
  import { degrees } from './defaults/degrees';
4
3
  import { euler } from './defaults/euler';
@@ -1,9 +1,9 @@
1
1
  <script>import { types } from '../../theatre';
2
- import { T, watch } from '@threlte/core';
2
+ import { T, watch, currentWritable } from '@threlte/core';
3
3
  import { TransformControls } from '@threlte/extras';
4
- import { onMount } from 'svelte';
4
+ import { onMount, getContext } from 'svelte';
5
5
  import { Group } from 'three';
6
- import { RAD2DEG } from 'three/src/math/MathUtils';
6
+ import { RAD2DEG } from 'three/src/math/MathUtils.js';
7
7
  import { useStudio } from '../../studio/useStudio';
8
8
  import { getDefaultTransformer } from '../transfomers/getDefaultTransformer';
9
9
  export let label = undefined;
@@ -13,12 +13,7 @@ export let space = undefined;
13
13
  export let translationSnap = undefined;
14
14
  export let rotationSnap = undefined;
15
15
  export let scaleSnap = undefined;
16
- /** @package */
17
- export let sheetObject;
18
- /** @package */
19
- export let addProps;
20
- /** @package */
21
- export let removeProps;
16
+ const { sheetObject, addProps, removeProps } = getContext('threlte-theater-sheet-context');
22
17
  let controls;
23
18
  $: if (controls) {
24
19
  if (translationSnap) {
@@ -139,13 +134,10 @@ const onMouseUp = () => {
139
134
  const groupRef = group;
140
135
  </script>
141
136
 
142
- <T
143
- is={groupRef}
144
- let:ref
145
- >
137
+ <T is={groupRef}>
146
138
  {#if isSelected}
147
139
  <TransformControls
148
- object={ref}
140
+ object={groupRef}
149
141
  {mode}
150
142
  {space}
151
143
  bind:controls
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  hide: boolean;
@@ -13,6 +13,6 @@ declare const __propDef: {
13
13
  export type InnerStudioProps = typeof __propDef.props;
14
14
  export type InnerStudioEvents = typeof __propDef.events;
15
15
  export type InnerStudioSlots = typeof __propDef.slots;
16
- export default class InnerStudio extends SvelteComponentTyped<InnerStudioProps, InnerStudioEvents, InnerStudioSlots> {
16
+ export default class InnerStudio extends SvelteComponent<InnerStudioProps, InnerStudioEvents, InnerStudioSlots> {
17
17
  }
18
18
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  enabled?: boolean | undefined;
@@ -14,6 +14,6 @@ declare const __propDef: {
14
14
  export type StudioProps = typeof __propDef.props;
15
15
  export type StudioEvents = typeof __propDef.events;
16
16
  export type StudioSlots = typeof __propDef.slots;
17
- export default class Studio extends SvelteComponentTyped<StudioProps, StudioEvents, StudioSlots> {
17
+ export default class Studio extends SvelteComponent<StudioProps, StudioEvents, StudioSlots> {
18
18
  }
19
19
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import type { IProjectConfig } from '@theatre/core';
3
3
  declare const __propDef: {
4
4
  props: {
@@ -18,6 +18,6 @@ declare const __propDef: {
18
18
  export type TheatreProps = typeof __propDef.props;
19
19
  export type TheatreEvents = typeof __propDef.events;
20
20
  export type TheatreSlots = typeof __propDef.slots;
21
- export default class Theatre extends SvelteComponentTyped<TheatreProps, TheatreEvents, TheatreSlots> {
21
+ export default class Theatre extends SvelteComponent<TheatreProps, TheatreEvents, TheatreSlots> {
22
22
  }
23
23
  export {};
package/package.json CHANGED
@@ -1,41 +1,42 @@
1
1
  {
2
2
  "name": "@threlte/theatre",
3
- "version": "2.1.6",
3
+ "version": "3.0.0-next.0",
4
4
  "author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
5
5
  "license": "MIT",
6
6
  "devDependencies": {
7
- "@sveltejs/adapter-auto": "^2.0.0",
8
- "@sveltejs/kit": "^1.20.4",
9
- "@sveltejs/package": "^2.1.0",
10
- "@types/node": "^18.0.3",
11
- "@types/three": "^0.158.3",
12
- "@typescript-eslint/eslint-plugin": "^5.45.0",
13
- "@typescript-eslint/parser": "^5.45.0",
14
- "@yushijinhun/three-minifier-rollup": "^0.3.1",
15
- "eslint": "^8.28.0",
16
- "eslint-config-prettier": "^8.5.0",
17
- "eslint-plugin-svelte": "^2.30.0",
18
- "prettier": "^2.8.8",
19
- "prettier-plugin-svelte": "^2.10.1",
20
- "publint": "^0.1.12",
21
- "rimraf": "^5.0.1",
22
- "svelte": "^4.1.1",
23
- "svelte-check": "^3.4.3",
24
- "svelte-preprocess": "^5.0.4",
25
- "svelte2tsx": "^0.6.19",
26
- "three": "^0.158.0",
27
- "tslib": "^2.4.1",
28
- "type-fest": "^2.13.0",
29
- "typescript": "^5.0.0",
30
- "vite": "^4.3.6",
31
- "@threlte/core": "7.0.12",
32
- "@threlte/extras": "8.2.0"
7
+ "@sveltejs/adapter-auto": "^3.1.1",
8
+ "@sveltejs/kit": "^2.4.3",
9
+ "@sveltejs/package": "^2.2.6",
10
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
11
+ "@types/node": "^20.11.6",
12
+ "@types/three": "^0.160.0",
13
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
14
+ "@typescript-eslint/parser": "^6.19.1",
15
+ "@yushijinhun/three-minifier-rollup": "^0.4.0",
16
+ "eslint": "^8.56.0",
17
+ "eslint-config-prettier": "^9.1.0",
18
+ "eslint-plugin-svelte": "^2.35.1",
19
+ "prettier": "^3.2.4",
20
+ "prettier-plugin-svelte": "^3.1.2",
21
+ "publint": "^0.2.7",
22
+ "rimraf": "^5.0.5",
23
+ "svelte": "^4.2.9",
24
+ "svelte-check": "^3.6.3",
25
+ "svelte-preprocess": "^5.1.3",
26
+ "svelte2tsx": "^0.7.0",
27
+ "three": "^0.160.1",
28
+ "tslib": "^2.6.2",
29
+ "type-fest": "^4.10.1",
30
+ "typescript": "^5.3.3",
31
+ "vite": "^5.0.12",
32
+ "@threlte/core": "8.0.0-next.0",
33
+ "@threlte/extras": "9.0.0-next.0"
33
34
  },
34
35
  "peerDependencies": {
35
36
  "svelte": ">=4",
36
- "three": ">=0.133",
37
- "@threlte/core": ">=6.0.3",
38
- "@threlte/extras": ">=5.1.0",
37
+ "three": ">=0.152",
38
+ "@threlte/core": ">=8.0.0-next.0",
39
+ "@threlte/extras": ">=9.0.0-next.0",
39
40
  "@theatre/core": ">=0.6",
40
41
  "@theatre/studio": ">=0.6"
41
42
  },