New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@threlte/core

Package Overview
Dependencies
Maintainers
0
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@threlte/core - npm Package Compare versions

Comparing version 8.0.0-next.21 to 8.0.0-next.22

dist/utilities/asyncWritable.d.ts

4

dist/components/T/utils/useAttach.js

@@ -6,5 +6,3 @@ import { onDestroy } from 'svelte';

import { createParentObject3DContext, useParentObject3D } from '../../../context/fragments/parentObject3D';
import { isInstanceOf } from '../../../lib/isInstanceOf';
import { watch } from '../../../lib/storeUtils';
import { resolvePropertyPath } from './resolvePropertyPath';
import { isInstanceOf, resolvePropertyPath, watch } from '../../../utilities';
const isObject = (ref) => {

@@ -11,0 +9,0 @@ return typeof ref === 'object' && ref !== null;

import { writable } from 'svelte/store';
import { useThrelte } from '../../../context/compounds/useThrelte';
import { watch } from '../../../lib/storeUtils';
import { isInstanceOf } from '../../../lib/isInstanceOf';
import { isInstanceOf, watch } from '../../../utilities';
const isPerspectiveOrOrthographicCamera = (value) => {

@@ -6,0 +5,0 @@ return isInstanceOf(value, 'PerspectiveCamera') || isInstanceOf(value, 'OrthographicCamera');

import { getContext, onDestroy, setContext } from 'svelte';
import { derived, get, writable } from 'svelte/store';
import { useDisposal } from '../../../context/fragments/disposal';
import { watch } from '../../../lib/storeUtils';
import { watch } from '../../../utilities';
const contextName = Symbol('threlte-disposable-object-context');

@@ -6,0 +6,0 @@ /**

import type { Plugin } from '../../../plugins/types';
export declare const usePlugins: (params: Parameters<Plugin>[0]) => {
updateRef: (ref: any) => void;
updateProps: (props: Record<string, any>) => void;
updateRestProps: (restProps: Record<string, any>) => void;
export declare const usePlugins: (args: () => Parameters<Plugin>[0]) => {
pluginsProps: string[];
} | undefined;

@@ -1,3 +0,3 @@

import { getContext, onDestroy } from 'svelte';
export const usePlugins = (params) => {
import { getContext } from 'svelte';
export const usePlugins = (args) => {
const pluginContextName = 'threlte-plugin-context';

@@ -7,36 +7,19 @@ const plugins = getContext(pluginContextName);

return;
const pluginsReturns = Object.values(plugins)
.map((plugin) => plugin(params))
.filter(Boolean);
const pluginsProps = pluginsReturns.flatMap((callback) => callback.pluginProps ?? []);
let refCleanupCallbacks = [];
onDestroy(() => {
refCleanupCallbacks.forEach((callback) => callback());
});
const updateRef = (ref) => {
refCleanupCallbacks.forEach((callback) => callback());
refCleanupCallbacks = [];
pluginsReturns.forEach((callback) => {
const cleanupCallback = callback.onRefChange?.(ref);
if (cleanupCallback) {
refCleanupCallbacks.push(cleanupCallback);
const pluginsProps = [];
const pluginsArray = Object.values(plugins);
if (pluginsArray.length) {
const pluginArgs = args();
// initalize plugins
for (let i = 0; i < pluginsArray.length; i++) {
const plugin = pluginsArray[i];
// initialize plugin
const p = plugin(pluginArgs);
if (p && p.pluginProps) {
pluginsProps.push(...p.pluginProps);
}
});
};
const updateProps = (props) => {
pluginsReturns.forEach((callback) => {
callback.onPropsChange?.(props);
});
};
const updateRestProps = (restProps) => {
pluginsReturns.forEach((callback) => {
callback.onRestPropsChange?.(restProps);
});
};
}
}
return {
updateRef,
updateProps,
updateRestProps,
pluginsProps
};
};
import { useThrelte } from '../../../context/compounds/useThrelte';
import { resolvePropertyPath } from './resolvePropertyPath';
import { resolvePropertyPath } from '../../../utilities';
const ignoredProps = new Set(['$$scope', '$$slots', 'type', 'args', 'attach', 'instance']);

@@ -4,0 +4,0 @@ const updateProjectionMatrixKeys = new Set([

@@ -0,5 +1,5 @@

import { Scene, type Camera, type ColorSpace, type ShadowMapType, type ToneMapping, type WebGLRenderer } from 'three';
import type { Scheduler, Stage, Task } from '../../frame-scheduling';
import type { CurrentReadable, CurrentWritable } from '../../lib/storeUtils';
import type { CurrentReadable, CurrentWritable } from '../../utilities';
import { type Size } from '../fragments/canvas';
import { Scene, type Camera, type ColorSpace, type ShadowMapType, type ToneMapping, type WebGLRenderer } from 'three';
/**

@@ -6,0 +6,0 @@ * ### `ThrelteContext`

import { type Camera } from 'three';
import { type CurrentWritable } from '../../lib/storeUtils';
import { type CurrentWritable } from '../../utilities';
type CameraContext = {

@@ -4,0 +4,0 @@ camera: CurrentWritable<Camera>;

import { getContext, setContext } from 'svelte';
import { PerspectiveCamera } from 'three';
import { currentWritable, watch } from '../../utilities';
import { useCanvas } from './canvas';
import { useScheduler } from './scheduler.svelte';
import { currentWritable, watch } from '../../lib/storeUtils';
export const createCameraContext = () => {

@@ -7,0 +7,0 @@ const { size } = useCanvas();

@@ -1,2 +0,2 @@

import { type CurrentReadable } from '../../lib/storeUtils';
import { type CurrentReadable } from '../../utilities';
export type Size = {

@@ -3,0 +3,0 @@ width: number;

import { getContext, onMount, setContext } from 'svelte';
import { currentWritable, toCurrentReadable } from '../../lib/storeUtils';
import { currentWritable, toCurrentReadable } from '../../utilities';
export const createCanvasContext = (options) => {

@@ -4,0 +4,0 @@ const wrapperRect = options.wrapper.getBoundingClientRect();

@@ -1,2 +0,2 @@

import { type CurrentWritable } from '../../lib/storeUtils';
import { type CurrentWritable } from '../../utilities';
type ParentContext = CurrentWritable<unknown>;

@@ -3,0 +3,0 @@ /**

import { getContext, setContext } from 'svelte';
import { currentWritable } from '../../lib/storeUtils';
import { currentWritable } from '../../utilities';
const parentContextKey = Symbol('threlte-parent-context');

@@ -4,0 +4,0 @@ /**

import { type ColorSpace, type Renderer, type ShadowMapType, type ToneMapping } from 'three';
import type { Task } from '../../frame-scheduling';
import { type CurrentWritable } from '../../lib/storeUtils';
import { type CurrentWritable } from '../../utilities';
type CreateRenderer<T extends Renderer> = (canvas: HTMLCanvasElement) => T;

@@ -5,0 +5,0 @@ type RendererContext = {

import { getContext, onDestroy, setContext } from 'svelte';
import { AgXToneMapping, ColorManagement, PCFSoftShadowMap, WebGLRenderer } from 'three';
import { useTask } from '../../hooks/useTask';
import { currentWritable, memoize, watch } from '../../lib/storeUtils';
import { currentWritable, watch } from '../../utilities';
import { useCamera } from './camera';

@@ -51,7 +51,6 @@ import { useCanvas } from './canvas';

// Resize the renderer when the size changes
const memoized = memoize(size);
const { start, stop } = useTask(() => {
if (!('xr' in renderer) || renderer.xr?.isPresenting)
return;
renderer.setSize(memoized.current.width, memoized.current.height);
renderer.setSize(size.current.width, size.current.height);
invalidate();

@@ -58,0 +57,0 @@ stop();

@@ -1,2 +0,2 @@

import { type CurrentWritable } from '../../lib/storeUtils';
import { type CurrentWritable } from '../../utilities';
import { Scheduler, type Stage } from '../../frame-scheduling';

@@ -3,0 +3,0 @@ export type SchedulerContext = {

import { getContext, onDestroy, setContext } from 'svelte';
import { currentWritable } from '../../lib/storeUtils';
import { currentWritable } from '../../utilities';
import { Scheduler } from '../../frame-scheduling';

@@ -4,0 +4,0 @@ export const createSchedulerContext = (options) => {

import { setContext } from 'svelte';
import { currentWritable } from '../../lib/storeUtils';
import { currentWritable } from '../../utilities';
export const createUserContext = () => {

@@ -4,0 +4,0 @@ const userCtx = currentWritable({});

@@ -1,2 +0,2 @@

import { type AsyncWritable } from '../lib/asyncWritable';
import { type AsyncWritable } from '../utilities';
type AsyncLoader = {

@@ -3,0 +3,0 @@ loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<any>;

import { useCache } from '../context/fragments/cache';
import { asyncWritable } from '../lib/asyncWritable';
import { asyncWritable } from '../utilities';
export function useLoader(Proto, options) {

@@ -4,0 +4,0 @@ const { remember, clear: clearCacheItem } = useCache();

import { onDestroy } from 'svelte';
import { readable, writable } from 'svelte/store';
import { DAG } from '../frame-scheduling';
import { browser } from '../lib/browser';
import { browser } from '../utilities';
import { useThrelte } from '../context/compounds/useThrelte';

@@ -6,0 +6,0 @@ import { useScheduler } from '../context/fragments/scheduler.svelte';

/// <reference types="svelte" />
import { type Readable } from 'svelte/store';
import type { CurrentWritable } from '../lib/storeUtils';
import type { CurrentWritable } from '../utilities';
export type ThrelteUserContext = CurrentWritable<Record<string | symbol, unknown>>;

@@ -5,0 +5,0 @@ type UserContextEntry = Record<string, any>;

@@ -5,5 +5,4 @@ export declare const VERSION = 8;

export type { Props } from './components/T/types';
export { createPlugin } from './plugins/createPlugin';
export { injectPlugin } from './plugins/injectPlugin';
export type { NamedPlugin, Plugin, PluginProps } from './plugins/types';
export type { Plugin } from './plugins/types';
export { useThrelte } from './context/compounds/useThrelte';

@@ -15,3 +14,2 @@ export { useStage } from './hooks/useStage';

export { useLoader, type UseLoaderLoadInput, type UseLoaderLoadResult, type UseLoaderOptions } from './hooks/useLoader';
export { asyncWritable, type AsyncWritable } from './lib/asyncWritable';
export { type ThrelteContext } from './context/compounds/useThrelte';

@@ -23,14 +21,8 @@ export { createThrelteContext } from './context/createThrelteContext.svelte';

export { createDisposalContext, useDisposal } from './context/fragments/disposal';
export { createParentContext, useParent } from './context/fragments/parent';
export { createParentObject3DContext, useParentObject3D } from './context/fragments/parentObject3D';
export { createRendererContext, useRenderer } from './context/fragments/renderer.svelte';
export { createSceneContext, useScene } from './context/fragments/scene';
export { createParentObject3DContext, useParentObject3D } from './context/fragments/parentObject3D';
export { createParentContext, useParent } from './context/fragments/parent';
export { createSchedulerContext, useScheduler } from './context/fragments/scheduler.svelte';
export type { Size } from './types';
export { resolvePropertyPath } from './components/T/utils/resolvePropertyPath';
export { createObjectStore } from './lib/createObjectStore';
export { revision } from './lib/revision';
export { currentWritable, memoize, watch, type CurrentWritable } from './lib/storeUtils';
export { isInstanceOf } from './lib/isInstanceOf';
export type { HierarchicalObjectProperties } from './internal/HierarchicalObject.svelte';
export type { SceneGraphObjectProperties } from './internal/SceneGraphObject.svelte';
export * from './utilities';

@@ -7,3 +7,2 @@ export const VERSION = 8;

// plugins
export { createPlugin } from './plugins/createPlugin';
export { injectPlugin } from './plugins/injectPlugin';

@@ -17,4 +16,2 @@ // hooks

export { useLoader } from './hooks/useLoader';
// AsyncWritable
export { asyncWritable } from './lib/asyncWritable';
export { createThrelteContext } from './context/createThrelteContext.svelte';

@@ -25,12 +22,8 @@ export { createCacheContext, useCache } from './context/fragments/cache';

export { createDisposalContext, useDisposal } from './context/fragments/disposal';
export { createParentContext, useParent } from './context/fragments/parent';
export { createParentObject3DContext, useParentObject3D } from './context/fragments/parentObject3D';
export { createRendererContext, useRenderer } from './context/fragments/renderer.svelte';
export { createSceneContext, useScene } from './context/fragments/scene';
export { createParentObject3DContext, useParentObject3D } from './context/fragments/parentObject3D';
export { createParentContext, useParent } from './context/fragments/parent';
export { createSchedulerContext, useScheduler } from './context/fragments/scheduler.svelte';
// utils
export { resolvePropertyPath } from './components/T/utils/resolvePropertyPath';
export { createObjectStore } from './lib/createObjectStore';
export { revision } from './lib/revision';
export { currentWritable, memoize, watch } from './lib/storeUtils';
export { isInstanceOf } from './lib/isInstanceOf';
export * from './utilities';

@@ -1,3 +0,2 @@

import type { AnyProps, NamedPlugin, Plugin } from './types';
export declare function injectPlugin<Props extends AnyProps = AnyProps>(namedPlugin: NamedPlugin<Props>): void;
import type { AnyProps, Plugin } from './types';
export declare function injectPlugin<Props extends AnyProps = AnyProps>(name: string, plugin: Plugin<Props>): void;
import { getContext, setContext } from 'svelte';
export function injectPlugin(nameOrNamedPlugin, maybePlugin) {
export function injectPlugin(name, plugin) {
const contextName = 'threlte-plugin-context';
if (Array.isArray(nameOrNamedPlugin)) {
const [name, plugin] = nameOrNamedPlugin;
setContext(contextName, {
...getContext(contextName),
[name]: plugin
});
}
else {
const name = nameOrNamedPlugin;
const plugin = maybePlugin;
if (!plugin)
return;
setContext(contextName, {
...getContext(contextName),
[name]: plugin
});
}
if (!plugin)
return;
setContext(contextName, {
...getContext(contextName),
[name]: plugin
});
}

@@ -0,14 +1,21 @@

import type { Object3D } from 'three';
export type BaseProps = {
ref: any;
args?: any[];
attach?: string | Object3D | ((args: {
ref: any;
parent: unknown;
parentObject3D: Object3D;
}) => void | (() => void)) | false;
manual?: boolean;
makeDefault?: boolean;
dispose?: boolean;
};
export type AnyProps = Record<string, any>;
export type Plugin<Props extends AnyProps = AnyProps> = (params: {
ref: any;
export type Plugin<Props extends AnyProps = AnyProps> = (args: BaseProps & {
props: Props & AnyProps;
}) => {
pluginProps?: (keyof Props)[] | string[];
onRefChange?: (ref: any) => void | (() => void);
onPropsChange?: (props: Props & AnyProps) => void;
onRestPropsChange?: (restProps: Props & AnyProps) => void;
} | void;
export type NamedPlugin<Props extends AnyProps = AnyProps> = [name: string, plugin: Plugin<Props>];
export type PluginContext = Record<string, Plugin<AnyProps>>;
export type PluginContextName = 'threlte-plugin-context';
export type PluginProps<P extends NamedPlugin<any> | Plugin<any>> = P extends NamedPlugin<infer Props> ? Props : P extends Plugin<infer Props> ? Props : never;
{
"name": "@threlte/core",
"version": "8.0.0-next.21",
"version": "8.0.0-next.22",
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc