@threlte/theatre 2.1.7 → 3.0.0-next.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.
@@ -1,4 +1,4 @@
1
- <script>import { globalProjects } from '../consts';
1
+ <script lang="ts">import { globalProjects } from '../consts';
2
2
  import { getProject } from '../theatre';
3
3
  import { setContext } from 'svelte';
4
4
  // PROPS
@@ -6,6 +6,11 @@ declare const __propDef: {
6
6
  config?: IProjectConfig | undefined;
7
7
  project?: import("@theatre/core").IProject | undefined;
8
8
  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;
9
14
  };
10
15
  events: {
11
16
  [evt: string]: CustomEvent<any>;
@@ -1,4 +1,4 @@
1
- <script>import { getContext, onDestroy, setContext } from 'svelte';
1
+ <script lang="ts">import { getContext, onDestroy, setContext } from 'svelte';
2
2
  // Parent context
3
3
  const { sequences } = getContext('theatre-sheet');
4
4
  // Props
@@ -25,6 +25,21 @@ 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: {
29
+ sequence: import("./SequenceController").SequenceController;
30
+ position: number;
31
+ playing: boolean;
32
+ play: (conf?: {
33
+ iterationCount?: number | undefined;
34
+ range?: [from: number, to: number] | undefined;
35
+ rate?: number | undefined;
36
+ direction?: ("reverse" | "alternate" | "normal" | "alternateReverse") | undefined;
37
+ rafDriver?: IRafDriver | undefined;
38
+ } | undefined) => Promise<boolean>;
39
+ pause: () => void;
40
+ }) => typeof import("svelte").SnippetReturn & {
41
+ _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
42
+ }) | undefined;
28
43
  };
29
44
  events: {
30
45
  [evt: string]: CustomEvent<any>;
@@ -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
- <script>import { getContext, setContext } from 'svelte';
1
+ <script lang="ts">import { getContext, setContext } from 'svelte';
2
2
  import { SequenceController } from '../sequence/SequenceController';
3
3
  import { globalSheets } from '../consts';
4
4
  // parent context
@@ -8,6 +8,11 @@ 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: {
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;
11
16
  };
12
17
  events: {
13
18
  [evt: string]: CustomEvent<any>;
@@ -5,8 +5,8 @@ export declare function createSheetObjectAction<Props extends UnknownShorthandCo
5
5
  props: Props;
6
6
  callback: (node: T, props: PropsValue<Props>) => void;
7
7
  options?: {
8
- reconfigure?: boolean | undefined;
9
- } | undefined;
8
+ reconfigure?: boolean;
9
+ };
10
10
  }) => {
11
11
  destroy(): void;
12
12
  };
@@ -3,28 +3,25 @@
3
3
  - Creating namespaces
4
4
  - Potentially Providing a sheet object
5
5
  -->
6
- <script>import { useStudio } from '../studio/useStudio';
7
- import { createRawEventDispatcher, currentWritable, watch, useThrelte } from '@threlte/core';
8
- import { getContext, onDestroy, onMount } from 'svelte';
6
+ <script lang="ts">import { useStudio } from '../studio/useStudio';
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 lang="ts">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
- <script>import { resolvePropertyPath, useParent, watch } from '@threlte/core';
2
- import { onDestroy } from 'svelte';
1
+ <script lang="ts">import { resolvePropertyPath, useParent, watch } from '@threlte/core';
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 = {};
@@ -1,7 +1,7 @@
1
- <script>import { types } from '../../theatre';
2
- import { T, watch } from '@threlte/core';
1
+ <script lang="ts">import { types } from '../../theatre';
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
6
  import { RAD2DEG } from 'three/src/math/MathUtils.js';
7
7
  import { useStudio } from '../../studio/useStudio';
@@ -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,5 +1,5 @@
1
1
  <script
2
-
2
+ lang="ts"
3
3
  context="module"
4
4
  >import Studio from '@theatre/studio';
5
5
  import { studio } from '../consts';
@@ -7,7 +7,7 @@ Studio.initialize();
7
7
  studio.set(Studio);
8
8
  </script>
9
9
 
10
- <script>import { watch } from '@threlte/core';
10
+ <script lang="ts">import { watch } from '@threlte/core';
11
11
  import { writable } from 'svelte/store';
12
12
  export let hide;
13
13
  const hideStore = writable(hide);
@@ -2,6 +2,9 @@ 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
8
  };
6
9
  events: {
7
10
  [evt: string]: CustomEvent<any>;
@@ -1,4 +1,4 @@
1
- <script>export let enabled = true;
1
+ <script lang="ts">export let enabled = true;
2
2
  export let hide = false;
3
3
  const browser = typeof window !== 'undefined';
4
4
  </script>
@@ -3,6 +3,9 @@ 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
9
  };
7
10
  events: {
8
11
  [evt: string]: CustomEvent<any>;
@@ -1,4 +1,4 @@
1
- <script>import { Project, Sheet, Studio } from '..';
1
+ <script lang="ts">import { Project, Sheet, Studio } from '..';
2
2
  export let studio = {};
3
3
  export let config = undefined;
4
4
  </script>
@@ -7,6 +7,9 @@ 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
13
  };
11
14
  events: {
12
15
  [evt: string]: CustomEvent<any>;
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
2
  "name": "@threlte/theatre",
3
- "version": "2.1.7",
3
+ "version": "3.0.0-next.1",
4
4
  "author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
5
5
  "license": "MIT",
6
6
  "devDependencies": {
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",
7
+ "@sveltejs/adapter-auto": "^3.2.0",
8
+ "@sveltejs/kit": "^2.5.5",
9
+ "@sveltejs/package": "^2.3.1",
10
+ "@sveltejs/vite-plugin-svelte": "^3.1.0",
11
+ "@types/node": "^20.12.7",
12
+ "@types/three": "^0.163.0",
13
+ "@typescript-eslint/eslint-plugin": "^7.6.0",
14
+ "@typescript-eslint/parser": "^7.6.0",
15
15
  "@yushijinhun/three-minifier-rollup": "^0.4.0",
16
- "eslint": "^8.56.0",
16
+ "eslint": "^9.0.0",
17
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",
18
+ "eslint-plugin-svelte": "^2.36.0",
19
+ "prettier": "^3.2.5",
20
+ "prettier-plugin-svelte": "^3.2.2",
21
21
  "publint": "^0.2.7",
22
22
  "rimraf": "^5.0.5",
23
- "svelte": "^4.2.9",
24
- "svelte-check": "^3.6.3",
23
+ "svelte": "^5.0.0-next.95",
24
+ "svelte-check": "^3.6.9",
25
25
  "svelte-preprocess": "^5.1.3",
26
- "svelte2tsx": "^0.7.0",
27
- "three": "^0.160.1",
26
+ "svelte2tsx": "^0.7.6",
27
+ "three": "^0.163.0",
28
28
  "tslib": "^2.6.2",
29
- "type-fest": "^4.10.1",
30
- "typescript": "^5.3.3",
31
- "vite": "^5.0.12",
32
- "@threlte/core": "7.2.1",
33
- "@threlte/extras": "8.10.1"
29
+ "type-fest": "^4.15.0",
30
+ "typescript": "^5.4.5",
31
+ "vite": "^5.2.8",
32
+ "@threlte/core": "8.0.0-next.2",
33
+ "@threlte/extras": "9.0.0-next.2"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "svelte": ">=4",
37
37
  "three": ">=0.152",
38
- "@threlte/core": ">=6.0.3",
39
- "@threlte/extras": ">=5.1.0",
38
+ "@threlte/core": ">=8.0.0-next.0",
39
+ "@threlte/extras": ">=9.0.0-next.0",
40
40
  "@theatre/core": ">=0.6",
41
41
  "@theatre/studio": ">=0.6"
42
42
  },