lunchboxjs 2.0.0-beta.2 → 2.0.0-beta.3
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/cypress/e2e/camera.cy.d.ts +1 -0
- package/dist/cypress/e2e/core-events.cy.d.ts +1 -0
- package/dist/cypress/e2e/core.cy.d.ts +1 -0
- package/dist/cypress/e2e/disposal.cy.d.ts +1 -0
- package/dist/cypress/e2e/docs-examples.cy.d.ts +0 -0
- package/dist/cypress/e2e/extend.cy.d.ts +1 -0
- package/dist/cypress/e2e/vue.cy.d.ts +1 -0
- package/dist/cypress/support/commands.d.ts +0 -0
- package/dist/cypress/support/e2e.d.ts +1 -0
- package/dist/cypress.config.d.ts +3 -0
- package/dist/demo.d.ts +1 -0
- package/dist/src/auto-components.d.ts +3 -0
- package/dist/src/index.d.ts +66 -0
- package/dist/src/parseAttributeValue.d.ts +1 -0
- package/dist/src/setThreeProperty.d.ts +1 -0
- package/dist/src/three-lunchbox.d.ts +42 -0
- package/dist/src/utils.d.ts +12 -0
- package/dist/types.d.ts +14 -0
- package/dist/vite.config.d.ts +2 -0
- package/package.json +10 -9
- package/dist/lunchboxjs.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/demo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { autoComponents } from './auto-components';
|
|
2
|
+
import { IsClass } from './utils';
|
|
3
|
+
|
|
4
|
+
import * as THREE from '../node_modules/@types/three';
|
|
5
|
+
export * from './three-lunchbox';
|
|
6
|
+
/** Every component in a Lunchbox scene is of the Lunchbox type - it contains its ThreeJS instance
|
|
7
|
+
* as a property called `instance`.
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* ## Basic example
|
|
11
|
+
*
|
|
12
|
+
* HTML:
|
|
13
|
+
*
|
|
14
|
+
* ```html
|
|
15
|
+
* <three-mesh></three-mesh>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* TS:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const mesh = document.querySelector<Lunchbox<THREE.Mesh>>('three-mesh');
|
|
22
|
+
* mesh?.instance; // this is typed as a THREE.Mesh, so you can do things like move it up:
|
|
23
|
+
* mesh?.instance.position.set(0, 1, 0); // - or anything else you can do with a mesh
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type Lunchbox<T> = Element & {
|
|
27
|
+
instance: T;
|
|
28
|
+
};
|
|
29
|
+
/** Options for initializing Lunchbox. */
|
|
30
|
+
interface LunchboxOptions {
|
|
31
|
+
/** Add THREE class names that should be registered first here. */
|
|
32
|
+
prependList?: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Initialize Lunchbox. Required to register Lunchbox components. */
|
|
35
|
+
export declare const initLunchbox: ({ prependList, }?: LunchboxOptions) => void;
|
|
36
|
+
/** Create and register a custom Lunchbox component. For example:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { CustomGeometry } from 'your-custom-geometry-source';
|
|
40
|
+
* import { extend } from 'lunchboxjs';
|
|
41
|
+
*
|
|
42
|
+
* extend('custom-geometry', CustomGeometry);
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Now in your HTML, you can do:
|
|
46
|
+
*
|
|
47
|
+
* ```html
|
|
48
|
+
* <three-lunchbox>
|
|
49
|
+
* <custom-geometry args="[0, 1, 2]"></custom-geometry>
|
|
50
|
+
* </three-lunchbox>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const extend: (name: string, classDefinition: IsClass, targetWindow?: Window & typeof globalThis) => void;
|
|
54
|
+
export declare const THREE_POINTER_MOVE_EVENT_NAME = "threepointermove";
|
|
55
|
+
export declare const THREE_MOUSE_MOVE_EVENT_NAME = "threemousemove";
|
|
56
|
+
export declare const THREE_CLICK_EVENT_NAME = "threeclick";
|
|
57
|
+
export type ThreeIntersectEvent = {
|
|
58
|
+
intersect: THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
59
|
+
element: Element | null;
|
|
60
|
+
};
|
|
61
|
+
export interface InstanceEvent<T = unknown> {
|
|
62
|
+
instance: T;
|
|
63
|
+
}
|
|
64
|
+
export { autoComponents };
|
|
65
|
+
/** The kebab-cased name of the ThreeJS web components automatically registered in Lunchbox. */
|
|
66
|
+
export declare const webComponentNames: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseAttributeValue: (targetValue: unknown, element: HTMLElement) => unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setThreeProperty: <T extends object>(target: T, split: string[], parsedValue: unknown) => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
/** Wrapper element for ThreeLunchbox. */
|
|
5
|
+
export declare class ThreeLunchbox extends LitElement {
|
|
6
|
+
private scratchV2;
|
|
7
|
+
three: {
|
|
8
|
+
scene: THREE.Scene;
|
|
9
|
+
camera: THREE.Camera | null;
|
|
10
|
+
renderer: THREE.WebGLRenderer;
|
|
11
|
+
};
|
|
12
|
+
background: THREE.ColorRepresentation | null;
|
|
13
|
+
dpr: number;
|
|
14
|
+
/** ResizeObserver to handle container sizing */
|
|
15
|
+
resizeObserver: ResizeObserver;
|
|
16
|
+
constructor();
|
|
17
|
+
/** To run on start. */
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
disconnectedCallback(): void;
|
|
20
|
+
handleDefaultSlotChange(evt: {
|
|
21
|
+
target: HTMLSlotElement;
|
|
22
|
+
}): void;
|
|
23
|
+
raycaster: THREE.Raycaster;
|
|
24
|
+
raycastPool: THREE.Object3D[];
|
|
25
|
+
runRaycast(evt: {
|
|
26
|
+
clientX: number;
|
|
27
|
+
clientY: number;
|
|
28
|
+
}): {
|
|
29
|
+
intersect: THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
30
|
+
element: Element | null;
|
|
31
|
+
}[];
|
|
32
|
+
onPointerMove(evt: PointerEvent | MouseEvent): void;
|
|
33
|
+
onClick(evt: TouchEvent | MouseEvent): void;
|
|
34
|
+
/** Container styles */
|
|
35
|
+
static styles: import('lit').CSSResult;
|
|
36
|
+
/** Render loop */
|
|
37
|
+
frame: number;
|
|
38
|
+
updateLoop(): void;
|
|
39
|
+
/** Render the 3D scene */
|
|
40
|
+
renderThree(): void;
|
|
41
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Get potentially nested property in object */
|
|
2
|
+
export declare const get: <T = unknown>(obj: any, path: string | string[], defValue?: T) => T | Record<string, any> | undefined;
|
|
3
|
+
/** Check if `obj` contains a constructor */
|
|
4
|
+
export declare function isClass(obj: any): obj is IsClass;
|
|
5
|
+
export type IsClass<T = unknown> = {
|
|
6
|
+
new (...args: any[]): T;
|
|
7
|
+
};
|
|
8
|
+
/** Check if a given value is a number */
|
|
9
|
+
export declare const isNumber: (value: any) => value is number;
|
|
10
|
+
/** Set a potentially-nested property to a given value */
|
|
11
|
+
export declare const set: (obj: Record<string, any>, path: string | string[], value: unknown) => void;
|
|
12
|
+
export declare const THREE_UUID_ATTRIBUTE_NAME = "data-three-uuid";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InstanceEvent, ThreeIntersectEvent } from './src/index';
|
|
2
|
+
|
|
3
|
+
interface ElementEventMap {
|
|
4
|
+
'instancecreated': CustomEvent<InstanceEvent>;
|
|
5
|
+
'threepointermove': CustomEvent<ThreeIntersectEvent>;
|
|
6
|
+
'threeclick': CustomEvent<ThreeIntersectEvent>;
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElement {
|
|
10
|
+
addEventListener<K extends keyof ElementEventMap>(type: K, listener: (this: Document, ev: ElementEventMap[K]) => void): void;
|
|
11
|
+
dispatchEvent<K extends keyof ElementEventMap>(ev: ElementEventMap[K]): void;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -8,31 +8,32 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/lunchboxjs.js",
|
|
11
|
-
"require": "./dist/lunchboxjs.umd.cjs"
|
|
11
|
+
"require": "./dist/lunchboxjs.umd.cjs",
|
|
12
|
+
"types": "./dist/src/index.d.ts"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
"version": "2.0.0-beta.
|
|
15
|
+
"version": "2.0.0-beta.3",
|
|
15
16
|
"type": "module",
|
|
16
|
-
"types": "./
|
|
17
|
+
"types": "./dist/src/index.d.ts",
|
|
17
18
|
"scripts": {
|
|
18
19
|
"dev": "vite",
|
|
19
|
-
"build": "tsc && vite build
|
|
20
|
-
"dts": "echo \"export * from '../src/';\" > ./dist/lunchboxjs.d.ts",
|
|
20
|
+
"build": "tsc && vite build",
|
|
21
21
|
"preview": "vite preview",
|
|
22
22
|
"cy:open": "cypress open",
|
|
23
23
|
"test": "cypress run"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"json5": "^2.2.3",
|
|
27
|
-
"lit": "^3.1.2"
|
|
28
|
-
"three": "^0.164.1"
|
|
27
|
+
"lit": "^3.1.2"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"@types/mocha": "^10.0.6",
|
|
32
31
|
"@types/node": "^20.12.7",
|
|
33
32
|
"@types/three": "^0.164.0",
|
|
34
33
|
"cypress": "^13.9.0",
|
|
34
|
+
"three": "^0.164.1",
|
|
35
35
|
"typescript": "^5.2.2",
|
|
36
|
-
"vite": "^5.2.0"
|
|
36
|
+
"vite": "^5.2.0",
|
|
37
|
+
"vite-plugin-dts": "^3.9.1"
|
|
37
38
|
}
|
|
38
|
-
}
|
|
39
|
+
}
|
package/dist/lunchboxjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../src/';
|