@tresjs/nuxt 1.0.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present, (alvarosabu) Alvaro Saburido and Tres contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ ![Repo banner](public/nuxt-tres-banner.png)
2
+
3
+ # @tresjs/nuxt
4
+
5
+ [![npm version][npm-version-src]][npm-version-href]
6
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
+ [![License][license-src]][license-href]
8
+ [![Nuxt][nuxt-src]][nuxt-href]
9
+
10
+ Official Nuxt module for TresJS. Build 3D scenes as they were Vue components.
11
+
12
+ - [✨  Release Notes](/CHANGELOG.md)
13
+ <!-- - [🏀 Online playground](https://stackblitz.com/github/@tresjs/nuxt?file=playground%2Fapp.vue) -->
14
+ <!-- - [📖 &nbsp;Documentation](https://example.com) -->
15
+
16
+ ## Features
17
+
18
+ - 🤓 Auto-import components and composables from the [TresJS ecosystem](https://github.com/orgs/Tresjs/repositories)
19
+ - `TresCanvas` client only, you don't need of adding `.client` to the component name or `<ClientOnly />`
20
+ - All the DX Magic that comes with Nuxt ✨
21
+
22
+ ## Quick Setup
23
+
24
+ 1. Add `@tresjs/nuxt` dependency to your project
25
+
26
+ ```bash
27
+ # Using pnpm
28
+ pnpm add -D @tresjs/nuxt
29
+
30
+ # Using yarn
31
+ yarn add --dev @tresjs/nuxt
32
+
33
+ # Using npm
34
+ npm install --save-dev @tresjs/nuxt
35
+ ```
36
+
37
+ 2. Add `@tresjs/nuxt` to the `modules` section of `nuxt.config.ts`
38
+
39
+ ```js
40
+ export default defineNuxtConfig({
41
+ modules: ["@tresjs/nuxt"],
42
+ });
43
+ ```
44
+
45
+ That's it! You can now use `@tresjs/nuxt` in your Nuxt app ✨
46
+
47
+ If you want to use the any package from the TresJS ecosystem, you can install the packages you want to use and they will be auto-imported by the module 🧙🏼‍♂️.
48
+
49
+ ```bash
50
+ # Using pnpm
51
+ pnpm add @tresjs/cientos @tresjs/post-processing
52
+ ```
53
+
54
+ ## Development
55
+
56
+ ```bash
57
+ # Install dependencies
58
+ npm install
59
+
60
+ # Generate type stubs
61
+ npm run dev:prepare
62
+
63
+ # Develop with the playground
64
+ npm run dev
65
+
66
+ # Build the playground
67
+ npm run dev:build
68
+
69
+ # Run ESLint
70
+ npm run lint
71
+
72
+ # Run Vitest
73
+ npm run test
74
+ npm run test:watch
75
+
76
+ # Release new version
77
+ npm run release
78
+ ```
79
+
80
+ <!-- Badges -->
81
+
82
+ [npm-version-src]: https://img.shields.io/npm/v/@tresjs/nuxt/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
83
+ [npm-version-href]: https://npmjs.com/package/@tresjs/nuxt
84
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@tresjs/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
85
+ [npm-downloads-href]: https://npmjs.com/package/@tresjs/nuxt
86
+ [license-src]: https://img.shields.io/npm/l/@tresjs/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
87
+ [license-href]: https://npmjs.com/package/@tresjs/nuxt
88
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
89
+ [nuxt-href]: https://nuxt.com
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,8 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface ModuleOptions {
4
+ modules: string[];
5
+ }
6
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
7
+
8
+ export { ModuleOptions, _default as default };
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@tresjs/nuxt",
3
+ "configKey": "tres",
4
+ "version": "1.0.0-alpha.0"
5
+ }
@@ -0,0 +1,69 @@
1
+ import { defineNuxtModule, createResolver, addComponent, addImports } from '@nuxt/kit';
2
+ import * as core from '@tresjs/core';
3
+ import { readPackageJSON } from 'pkg-types';
4
+
5
+ const module = defineNuxtModule({
6
+ meta: {
7
+ name: "@tresjs/nuxt",
8
+ configKey: "tres"
9
+ },
10
+ defaults: {
11
+ modules: []
12
+ },
13
+ async setup(options, nuxt) {
14
+ const resolver = createResolver(import.meta.url);
15
+ addComponent({
16
+ filePath: resolver.resolve("./runtime/components/TresCanvas.vue"),
17
+ name: "TresCanvas"
18
+ });
19
+ nuxt.options.build.transpile.push(/@tresjs/, "postprocessing");
20
+ for (const name in core) {
21
+ if (name.match(/^use/)) {
22
+ addImports({
23
+ from: "@tresjs/core",
24
+ name
25
+ });
26
+ }
27
+ }
28
+ addImports([
29
+ {
30
+ from: "@tresjs/core",
31
+ name: "extend",
32
+ as: "extendTres"
33
+ },
34
+ {
35
+ from: "@tresjs/core",
36
+ type: true,
37
+ name: "TresObject"
38
+ }
39
+ ]);
40
+ nuxt.hook("prepare:types", ({ references }) => {
41
+ references.push({ types: "@tresjs/core" });
42
+ });
43
+ const isCustomElement = nuxt.options.vue.compilerOptions.isCustomElement;
44
+ nuxt.options.vue.compilerOptions.isCustomElement = (tag) => {
45
+ return tag.startsWith("Tres") && tag !== "TresCanvas" || tag === "primitive" || isCustomElement?.(tag);
46
+ };
47
+ const pkg = await readPackageJSON(nuxt.options.rootDir);
48
+ const coreDeps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies }).filter((d) => d.startsWith("@tresjs/"));
49
+ for (const mod of /* @__PURE__ */ new Set([...options.modules, ...coreDeps])) {
50
+ const imports = await import(mod);
51
+ for (const name in imports) {
52
+ if (name.match(/^[a-z]/)) {
53
+ addImports({
54
+ from: mod,
55
+ name
56
+ });
57
+ } else {
58
+ addComponent({
59
+ name,
60
+ filePath: mod,
61
+ export: name
62
+ });
63
+ }
64
+ }
65
+ }
66
+ }
67
+ });
68
+
69
+ export { module as default };
@@ -0,0 +1,12 @@
1
+ <script setup lang="ts">
2
+ import { TresCanvas as TC, TresCanvasProps } from '@tresjs/core';
3
+ defineProps<TresCanvasProps>()
4
+ </script>
5
+
6
+ <template>
7
+ <ClientOnly>
8
+ <TC v-bind="$props">
9
+ <slot />
10
+ </TC>
11
+ </ClientOnly>
12
+ </template>
@@ -0,0 +1,15 @@
1
+
2
+ import { ModuleOptions } from './module'
3
+
4
+ declare module '@nuxt/schema' {
5
+ interface NuxtConfig { ['tres']?: Partial<ModuleOptions> }
6
+ interface NuxtOptions { ['tres']?: ModuleOptions }
7
+ }
8
+
9
+ declare module 'nuxt/schema' {
10
+ interface NuxtConfig { ['tres']?: Partial<ModuleOptions> }
11
+ interface NuxtOptions { ['tres']?: ModuleOptions }
12
+ }
13
+
14
+
15
+ export { ModuleOptions, default } from './module'
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@tresjs/nuxt",
3
+ "type": "module",
4
+ "packageManager": "pnpm@8.6.2",
5
+ "version": "1.0.0-alpha.0",
6
+ "description": "TresJS integration for Nuxt.",
7
+ "repository": "@tresjs/nuxt",
8
+ "author": "Daniel Roe (https://github.com/danielroe/)",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "license": "MIT",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/types.d.ts",
16
+ "import": "./dist/module.mjs",
17
+ "require": "./dist/module.cjs"
18
+ }
19
+ },
20
+ "main": "./dist/module.cjs",
21
+ "types": "./dist/types.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "scripts": {
26
+ "prepack": "nuxt-module-build",
27
+ "dev": "nuxi dev playground",
28
+ "dev:build": "nuxi build playground",
29
+ "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
30
+ "release": "release-it",
31
+ "lint": "eslint .",
32
+ "test": "vitest run",
33
+ "test:watch": "vitest watch"
34
+ },
35
+ "dependencies": {
36
+ "@nuxt/kit": "^3.5.2",
37
+ "@tresjs/cientos": "^2.1.3",
38
+ "@tresjs/core": "^2.1.2",
39
+ "@tresjs/post-processing": "^0.2.0",
40
+ "@types/three": "^0.152.1",
41
+ "pkg-types": "^1.0.3",
42
+ "three": "^0.153.0"
43
+ },
44
+ "devDependencies": {
45
+ "@nuxt/eslint-config": "^0.1.1",
46
+ "@nuxt/module-builder": "^0.4.0",
47
+ "@nuxt/schema": "^3.5.2",
48
+ "@nuxt/test-utils": "^3.5.1",
49
+ "@release-it/conventional-changelog": "^5.1.1",
50
+ "@types/node": "^18",
51
+ "changelogen": "^0.5.3",
52
+ "eslint": "^8.42.0",
53
+ "nuxt": "^3.5.1",
54
+ "playwright": "^1.35.0",
55
+ "release-it": "^15.11.0",
56
+ "vitest": "^0.31.4"
57
+ }
58
+ }