tresjs-nuxt 4.3.1 → 4.4.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/README.md CHANGED
@@ -5,12 +5,14 @@
5
5
  [![NPM downloads][badge-npm-downloads]][url-npm]
6
6
  [![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
7
7
 
8
- TresJS for Nuxt — a Nuxt module that auto-imports the TresJS core API, registers TresCanvas for client and server, and registers every installed @tresjs package's components and composables, with no devtools UI of its own.
8
+ A Nuxt module for TresJS that auto-imports the TresJS core API, registers TresCanvas for client and server, and registers every installed @tresjs package's components and composables, with no devtools UI of its own.
9
+
10
+ Design notes live in [the specs](https://github.com/Esposter/Esposter/tree/main/openspec/specs/tresjs-nuxt).
9
11
 
10
12
  ## Table of Contents
11
13
 
12
14
  - 🚀 [Getting Started](#getting-started)
13
- - 📖 [Documentation](#documentation)
15
+ - 🧩 [Key Exports](#key-exports)
14
16
  - ⚖️ [License](#license)
15
17
 
16
18
  ---
@@ -21,9 +23,21 @@ TresJS for Nuxt — a Nuxt module that auto-imports the TresJS core API, registe
21
23
  pnpm i tresjs-nuxt
22
24
  ```
23
25
 
24
- ## <a name="documentation">📖 Documentation</a>
26
+ ```ts
27
+ // nuxt.config.ts
28
+ export default defineNuxtConfig({
29
+ modules: ["tresjs-nuxt"],
30
+ // Loads the optional vite-plugin-glsl peer, which the app installs itself
31
+ tres: { glsl: true },
32
+ });
33
+ ```
34
+
35
+ ## <a name="key-exports">🧩 Key Exports</a>
25
36
 
26
- We highly recommend you take a look at the [documentation](https://github.com/Esposter/Esposter/tree/main/openspec/specs/tresjs-nuxt) to level up.
37
+ | Export | Kind | Purpose |
38
+ | :-------------- | :-------- | :------------------------------------------------------------------------------------------------------------------------- |
39
+ | `default` | const | The Nuxt module: auto-imports the TresJS core API, registers `TresCanvas` and each installed `@tresjs/*` package's exports |
40
+ | `ModuleOptions` | interface | The `tres` config key: `glsl` loads the `vite-plugin-glsl` peer, and `modules` names extra packages whose exports register |
27
41
 
28
42
  ## <a name="license">⚖️ License</a>
29
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tresjs-nuxt",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "TresJS for Nuxt — a Nuxt module that auto-imports the TresJS core API, registers TresCanvas for client and server, and registers every installed @tresjs package's components and composables, with no devtools UI of its own.",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -31,8 +31,6 @@
31
31
  },
32
32
  "exports": {
33
33
  ".": "./dist/index.js",
34
- "./runtime/TresCanvas.client": "./dist/runtime/TresCanvas.client.js",
35
- "./runtime/TresCanvas.server": "./dist/runtime/TresCanvas.server.js",
36
34
  "./package.json": "./package.json"
37
35
  },
38
36
  "publishConfig": {
@@ -43,7 +41,7 @@
43
41
  "lint": "eslint .",
44
42
  "lint:fix": "eslint --fix .",
45
43
  "test": "vitest",
46
- "typecheck": "tsc"
44
+ "typecheck": "tsrs --fast"
47
45
  },
48
46
  "dependencies": {
49
47
  "@nuxt/kit": "npm:@nuxt/kit-nightly@5x",
@@ -52,12 +50,12 @@
52
50
  "mlly": "^1.8.2"
53
51
  },
54
52
  "devDependencies": {
55
- "@esposter/configuration": "4.3.1",
56
- "tsdown": "^0.23.1",
53
+ "@esposter/configuration": "4.4.0",
54
+ "tsdown": "0.23.2",
57
55
  "vite-plugin-glsl": "^1.6.2"
58
56
  },
59
57
  "peerDependencies": {
60
- "@tresjs/core": "^5.9.3",
58
+ "@tresjs/core": "^5.10.1",
61
59
  "nuxt": "npm:nuxt-nightly@5x",
62
60
  "three": "^0.186.1",
63
61
  "vite-plugin-glsl": "^1.6.2",
@@ -68,5 +66,5 @@
68
66
  "optional": true
69
67
  }
70
68
  },
71
- "gitHead": "777a39636b789c13af33ed13370246ccf6dbaf31"
69
+ "gitHead": "e1a416c4b91da69cc2aa259b50a4d656f204d272"
72
70
  }
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { ModuleOptions } from "./models/ModuleOptions.js";
2
- import { NuxtModule } from "@nuxt/schema";
3
- //#region src/module.d.ts
4
- declare const tresjsModule: NuxtModule<ModuleOptions>;
5
- //#endregion
6
- export { type ModuleOptions, tresjsModule as default };
package/dist/index.js DELETED
@@ -1,78 +0,0 @@
1
- import { CORE_PACKAGE_NAME, GLSL_PACKAGE_NAME, THREE_PACKAGE_NAME, TRES_CANVAS_NAME } from "./services/constants.js";
2
- import { checkIsTresCustomElement } from "./services/checkIsTresCustomElement.js";
3
- import { getExportNames } from "./services/getExportNames.js";
4
- import { getTresPackageNames } from "./services/getTresPackageNames.js";
5
- import { addComponent, addImports, addVitePlugin, createResolver, defineNuxtModule, resolvePath } from "@nuxt/kit";
6
- import { defu } from "defu";
7
- //#region src/module.ts
8
- const LOWERCASE_NAME_REGEX = /^[a-z]/u;
9
- const tresjsModule = defineNuxtModule({
10
- defaults: {
11
- glsl: false,
12
- modules: []
13
- },
14
- meta: {
15
- compatibility: { nuxt: ">=5.0.0-0" },
16
- configKey: "tres",
17
- name: "tresjs-nuxt"
18
- },
19
- async setup(options, nuxt) {
20
- const { resolve } = createResolver(import.meta.url);
21
- nuxt.options.build.transpile.push(/@tresjs\//u);
22
- nuxt.options.vue.compilerOptions.isCustomElement = checkIsTresCustomElement;
23
- const coreExportNames = await getExportNames(await resolvePath(CORE_PACKAGE_NAME));
24
- addImports([
25
- ...coreExportNames.filter((name) => name.startsWith("use")).map((name) => ({
26
- from: CORE_PACKAGE_NAME,
27
- name
28
- })),
29
- {
30
- as: "extendTres",
31
- from: CORE_PACKAGE_NAME,
32
- name: "extend"
33
- },
34
- {
35
- from: CORE_PACKAGE_NAME,
36
- name: "TresObject",
37
- type: true
38
- }
39
- ]);
40
- nuxt.hook("prepare:types", ({ references }) => {
41
- references.push({ types: CORE_PACKAGE_NAME });
42
- });
43
- const packageNames = /* @__PURE__ */ new Set([...options.modules ?? [], ...await getTresPackageNames(nuxt.options.rootDir)]);
44
- const packageExports = await Promise.all(Array.from(packageNames, async (packageName) => {
45
- const entryPath = await resolvePath(packageName);
46
- if (entryPath === packageName) return [];
47
- return (await getExportNames(entryPath)).map((name) => ({
48
- name,
49
- packageName
50
- }));
51
- }));
52
- for (const { name, packageName } of packageExports.flat()) if (LOWERCASE_NAME_REGEX.test(name)) addImports({
53
- from: packageName,
54
- name
55
- });
56
- else addComponent({
57
- export: name,
58
- filePath: packageName,
59
- name
60
- });
61
- nuxt.options.vite.resolve = defu(nuxt.options.vite.resolve, { dedupe: [THREE_PACKAGE_NAME] });
62
- nuxt.options.vite.optimizeDeps = defu(nuxt.options.vite.optimizeDeps, { include: [THREE_PACKAGE_NAME] });
63
- addComponent({
64
- filePath: await resolvePath(resolve("./runtime/TresCanvas.client")),
65
- name: TRES_CANVAS_NAME
66
- });
67
- addComponent({
68
- filePath: await resolvePath(resolve("./runtime/TresCanvas.server")),
69
- name: TRES_CANVAS_NAME
70
- });
71
- if (options.glsl) {
72
- const { default: glsl } = await import(GLSL_PACKAGE_NAME);
73
- addVitePlugin(glsl());
74
- }
75
- }
76
- });
77
- //#endregion
78
- export { tresjsModule as default };
@@ -1,6 +0,0 @@
1
- //#region src/models/ModuleOptions.d.ts
2
- export interface ModuleOptions {
3
- glsl?: boolean;
4
- modules?: string[];
5
- }
6
- //#endregion
@@ -1,5 +0,0 @@
1
- import { Component } from "vue";
2
- //#region src/runtime/TresCanvas.client.d.ts
3
- declare const tresCanvasClient: Component;
4
- //#endregion
5
- export { tresCanvasClient as default };
@@ -1,12 +0,0 @@
1
- import { TresCanvas } from "@tresjs/core";
2
- import { defineComponent, h } from "vue";
3
- //#region src/runtime/TresCanvas.client.ts
4
- const tresCanvasClient = defineComponent({
5
- inheritAttrs: false,
6
- name: "TresCanvas",
7
- setup(_props, { attrs, slots }) {
8
- return () => h(TresCanvas, attrs, slots);
9
- }
10
- });
11
- //#endregion
12
- export { tresCanvasClient as default };
@@ -1,5 +0,0 @@
1
- import { Component } from "vue";
2
- //#region src/runtime/TresCanvas.server.d.ts
3
- declare const tresCanvasServer: Component;
4
- //#endregion
5
- export { tresCanvasServer as default };
@@ -1,8 +0,0 @@
1
- import { defineComponent, h } from "vue";
2
- //#region src/runtime/TresCanvas.server.ts
3
- const tresCanvasServer = defineComponent({
4
- name: "TresCanvas",
5
- setup: () => () => h("span")
6
- });
7
- //#endregion
8
- export { tresCanvasServer as default };
@@ -1,8 +0,0 @@
1
- import { TRES_CORE_COMPONENT_NAMES } from "./constants.js";
2
- //#region src/services/checkIsTresCustomElement.ts
3
- const PRIMITIVE_TAG_NAME = "primitive";
4
- const TRES_COMPONENT_NAME_REGEX = /^Tres[A-Z]/u;
5
- const TRES_ELEMENT_NAME_PREFIX = "tres-";
6
- const checkIsTresCustomElement = (tagName) => (TRES_COMPONENT_NAME_REGEX.test(tagName) || tagName.startsWith(TRES_ELEMENT_NAME_PREFIX)) && !TRES_CORE_COMPONENT_NAMES.includes(tagName) || tagName === PRIMITIVE_TAG_NAME;
7
- //#endregion
8
- export { checkIsTresCustomElement };
@@ -1,15 +0,0 @@
1
- //#region src/services/constants.ts
2
- const CORE_PACKAGE_NAME = "@tresjs/core";
3
- const GLSL_PACKAGE_NAME = "vite-plugin-glsl";
4
- const THREE_PACKAGE_NAME = "three";
5
- const TRES_CANVAS_NAME = "TresCanvas";
6
- const TRES_PACKAGE_SCOPE = "@tresjs/";
7
- const TRES_CORE_COMPONENT_NAMES = [
8
- "TresCanvas",
9
- "TresCanvasContext",
10
- "TresLeches",
11
- "TresPortal",
12
- "TresScene"
13
- ];
14
- //#endregion
15
- export { CORE_PACKAGE_NAME, GLSL_PACKAGE_NAME, THREE_PACKAGE_NAME, TRES_CANVAS_NAME, TRES_CORE_COMPONENT_NAMES, TRES_PACKAGE_SCOPE };
@@ -1,6 +0,0 @@
1
- import { findExportNames } from "mlly";
2
- import { readFile } from "node:fs/promises";
3
- //#region src/services/getExportNames.ts
4
- const getExportNames = async (entryPath) => findExportNames(await readFile(entryPath, "utf8"));
5
- //#endregion
6
- export { getExportNames };
@@ -1,17 +0,0 @@
1
- import "./constants.js";
2
- import { readFile } from "node:fs/promises";
3
- import { existsSync } from "node:fs";
4
- import { dirname, join } from "node:path";
5
- //#region src/services/getTresPackageNames.ts
6
- const getDependencyNames = async (directory) => {
7
- const manifest = JSON.parse(await readFile(join(directory, "package.json"), "utf8"));
8
- return [...Object.keys(manifest.dependencies ?? {}), ...Object.keys(manifest.devDependencies ?? {})];
9
- };
10
- const getTresPackageNames = async (rootDirectory) => {
11
- const parentDirectory = dirname(rootDirectory);
12
- const directories = existsSync(join(parentDirectory, "package.json")) ? [rootDirectory, parentDirectory] : [rootDirectory];
13
- const dependencyNames = (await Promise.all(directories.map((directory) => getDependencyNames(directory)))).flat();
14
- return [...new Set(dependencyNames)].filter((dependencyName) => dependencyName.startsWith("@tresjs/") && dependencyName !== "@tresjs/core");
15
- };
16
- //#endregion
17
- export { getTresPackageNames };