pni 1.0.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.
Files changed (50) hide show
  1. package/dist/add-three-app.d.ts +6 -0
  2. package/dist/add-three-app.js +111 -0
  3. package/dist/app.d.ts +11 -0
  4. package/dist/app.js +143 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +71 -0
  7. package/dist/components/FeatureSelector.d.ts +21 -0
  8. package/dist/components/FeatureSelector.js +175 -0
  9. package/dist/components/ProgressIndicator.d.ts +7 -0
  10. package/dist/components/ProgressIndicator.js +46 -0
  11. package/dist/components/Summary.d.ts +8 -0
  12. package/dist/components/Summary.js +51 -0
  13. package/dist/components/WelcomeHeader.d.ts +2 -0
  14. package/dist/components/WelcomeHeader.js +8 -0
  15. package/dist/template_code/three/README.md +146 -0
  16. package/dist/template_code/three/World.js +133 -0
  17. package/dist/template_code/three/camera.js +30 -0
  18. package/dist/template_code/three/components/GlobeSphere.js +608 -0
  19. package/dist/template_code/three/components/cube.js +27 -0
  20. package/dist/template_code/three/components/lights.js +16 -0
  21. package/dist/template_code/three/components/sphere.js +26 -0
  22. package/dist/template_code/three/components/torus.js +25 -0
  23. package/dist/template_code/three/scene.js +28 -0
  24. package/dist/template_code/three/systems/Loop.js +43 -0
  25. package/dist/template_code/three/systems/Resizer.js +26 -0
  26. package/dist/template_code/three/systems/controls.js +19 -0
  27. package/dist/template_code/three/systems/post-processing.js +50 -0
  28. package/dist/template_code/three/systems/renderer.js +17 -0
  29. package/dist/template_code/three/utils/deviceDetector.js +141 -0
  30. package/dist/template_code/three/utils/gltfLoader.js +14 -0
  31. package/dist/template_code/three/utils/loadKTX2Texture.js +42 -0
  32. package/dist/template_code/three/utils/textureLoader.js +21 -0
  33. package/dist/utils/add-three.d.ts +7 -0
  34. package/dist/utils/add-three.js +288 -0
  35. package/dist/utils/app-creation.d.ts +4 -0
  36. package/dist/utils/app-creation.js +35 -0
  37. package/dist/utils/config-generator.d.ts +6 -0
  38. package/dist/utils/config-generator.js +508 -0
  39. package/dist/utils/css-variables.d.ts +4 -0
  40. package/dist/utils/css-variables.js +316 -0
  41. package/dist/utils/dependencies.d.ts +11 -0
  42. package/dist/utils/dependencies.js +68 -0
  43. package/dist/utils/package-manager.d.ts +4 -0
  44. package/dist/utils/package-manager.js +56 -0
  45. package/dist/utils/project-detection.d.ts +2 -0
  46. package/dist/utils/project-detection.js +60 -0
  47. package/dist/utils/shadcn-setup.d.ts +2 -0
  48. package/dist/utils/shadcn-setup.js +46 -0
  49. package/package.json +81 -0
  50. package/readme.md +119 -0
@@ -0,0 +1,508 @@
1
+ import { readFileSync, writeFileSync, existsSync } from 'fs';
2
+ import { join } from 'path';
3
+ export async function generateNuxtConfig(projectPath,
4
+ //@ts-ignore
5
+ threejs, cssVars) {
6
+ const configPath = join(projectPath, 'nuxt.config.ts');
7
+ let configContent = '';
8
+ if (existsSync(configPath)) {
9
+ configContent = readFileSync(configPath, 'utf-8');
10
+ }
11
+ else {
12
+ // Generate full config template
13
+ const modules = [
14
+ 'shadcn-nuxt',
15
+ '@nuxtjs/seo',
16
+ '@nuxt/image',
17
+ '@nuxtjs/device',
18
+ ];
19
+ // Use assets/css/tailwind.css for Nuxt projects
20
+ const cssImport = '~/assets/css/tailwind.css';
21
+ const tailwindImport = cssVars
22
+ ? "import tailwindcss from '@tailwindcss/vite'\n\n"
23
+ : '';
24
+ configContent = `${tailwindImport}// https://nuxt.com/docs/api/configuration/nuxt-config
25
+ export default defineNuxtConfig({
26
+ // 1. Updated to a realistic 2024/2025 date for Nuxt 4 features
27
+ compatibilityDate: '2024-11-01',
28
+ devtools: { enabled: true },
29
+
30
+ ${cssVars ? ` css: ['${cssImport}'],\n\n` : ''} ssr: true,
31
+
32
+
33
+ // SEO: Centralizing data
34
+ site: {
35
+ name: 'New Setup',
36
+ url: 'https://newsetup.com',
37
+ description: 'A new setup for your project',
38
+ defaultLocale: 'en',
39
+ },
40
+
41
+ // App Config for UI-wide settings
42
+ app: {
43
+ head: {
44
+ charset: 'utf-8',
45
+ viewport: 'width=device-width, initial-scale=1',
46
+ meta: [
47
+ { name: 'description', content: 'A new setup for your project' },
48
+ { name: 'author', content: 'New Setup' },
49
+ { property: 'og:type', content: 'website' },
50
+ { name: 'msapplication-TileColor', content: '#000000' },
51
+ { name: 'theme-color', content: '#000000' },
52
+ ],
53
+ link: [
54
+ // { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
55
+ // { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon-180x180.png' },
56
+ // { rel: 'manifest', href: '/manifest.webmanifest' },
57
+ ],
58
+ },
59
+ },
60
+
61
+ ${cssVars
62
+ ? ` vite: {
63
+ plugins: [tailwindcss()],
64
+ esbuild: {
65
+ drop: process.env.NODE_ENV === 'production' ? ['console', 'debugger'] : [],
66
+ },
67
+ build: {
68
+ // Ensures CSS is also minified correctly by lightningcss (default in Vite 6)
69
+ cssMinify: 'lightningcss'
70
+ }
71
+ },
72
+
73
+ `
74
+ : ''} nitro: {
75
+ compressPublicAssets: {
76
+ brotli: true,
77
+ gzip: true,
78
+ },
79
+ // Enable crawling for SEO module compatibility
80
+ prerender: {
81
+ // set to true for production
82
+ crawlLinks: false,
83
+ routes: ['/']
84
+ }
85
+ },
86
+
87
+ modules: [${modules.map(m => `'${m}'`).join(', ')}],
88
+
89
+
90
+ // Image Optimization
91
+ image: {
92
+ quality: 95,
93
+ format: ['webp'],
94
+ screens: {
95
+ xs: 320,
96
+ sm: 640,
97
+ md: 768,
98
+ lg: 1200,
99
+ xl: 1400,
100
+ xxl: 1800,
101
+ '2xl': 2000,
102
+ },
103
+ },
104
+
105
+ // UI Framework: Shadcn
106
+ ${cssVars
107
+ ? ` shadcn: {
108
+ prefix: '',
109
+ componentDir: '@/components/ui',
110
+ },
111
+
112
+
113
+ `
114
+ : ''} ogImage: {
115
+ defaults: {
116
+ component: 'OgImageTemplate',
117
+ props: {
118
+ title: 'New Setup',
119
+ description: 'A new setup for your project',
120
+ image: 'https://newsetup.com/og-image.png',
121
+ },
122
+ }
123
+ },
124
+ robots: {
125
+ disallow: ['/api',],
126
+ },
127
+
128
+
129
+
130
+ sitemap: {
131
+ // sources: ['/api/__sitemap__/urls'] // Fetch from API
132
+ },
133
+ })
134
+ `;
135
+ writeFileSync(configPath, configContent, 'utf-8');
136
+ return;
137
+ }
138
+ // If config exists, merge new modules and settings
139
+ const modules = [];
140
+ if (cssVars && !configContent.includes('shadcn-nuxt')) {
141
+ modules.push('shadcn-nuxt');
142
+ }
143
+ if (!configContent.includes('@nuxtjs/seo')) {
144
+ modules.push('@nuxtjs/seo');
145
+ }
146
+ if (!configContent.includes('@nuxt/image')) {
147
+ modules.push('@nuxt/image');
148
+ }
149
+ if (!configContent.includes('@nuxtjs/device')) {
150
+ modules.push('@nuxtjs/device');
151
+ }
152
+ // Add compatibilityDate if not present
153
+ if (!configContent.includes('compatibilityDate')) {
154
+ configContent = configContent.replace(/export default defineNuxtConfig\(\{/, `export default defineNuxtConfig({
155
+ // 1. Updated to a realistic 2024/2025 date for Nuxt 4 features
156
+ compatibilityDate: '2024-11-01',`);
157
+ }
158
+ // Add ssr if not present
159
+ if (!configContent.includes('ssr:')) {
160
+ configContent = configContent.replace(/compatibilityDate:\s*'[^']*',/, `$&\n ssr: true,`);
161
+ }
162
+ // Add CSS import if cssVars is true
163
+ if (cssVars) {
164
+ // Use assets/css/tailwind.css for Nuxt projects
165
+ const cssImport = '~/assets/css/tailwind.css';
166
+ if (!configContent.includes('import tailwindcss')) {
167
+ configContent = `import tailwindcss from '@tailwindcss/vite'\n\n${configContent}`;
168
+ }
169
+ if (!configContent.includes('css:')) {
170
+ configContent = configContent.replace(/devtools:\s*\{[^}]*\},/, `$&\n\n css: ['${cssImport}'],`);
171
+ }
172
+ else if (!configContent.includes(cssImport)) {
173
+ configContent = configContent.replace(/css:\s*\[/, `css: ['${cssImport}',`);
174
+ }
175
+ }
176
+ // Add vite plugins for Tailwind if cssVars is true
177
+ if (cssVars && !configContent.includes('@tailwindcss/vite')) {
178
+ if (!configContent.includes('vite:')) {
179
+ configContent = configContent.replace(/ssr:\s*true,/, `$&\n\n vite: {
180
+ plugins: [tailwindcss()],
181
+ esbuild: {
182
+ drop: process.env.NODE_ENV === 'production' ? ['console', 'debugger'] : [],
183
+ },
184
+ build: {
185
+ // Ensures CSS is also minified correctly by lightningcss (default in Vite 6)
186
+ cssMinify: 'lightningcss'
187
+ }
188
+ },`);
189
+ }
190
+ else if (!configContent.includes('tailwindcss()')) {
191
+ configContent = configContent.replace(/vite:\s*\{/, `vite: {
192
+ plugins: [tailwindcss()],`);
193
+ }
194
+ }
195
+ // Add modules
196
+ if (modules.length > 0) {
197
+ if (configContent.includes('modules:')) {
198
+ // Add to existing modules array
199
+ const existingModules = configContent.match(/modules:\s*\[([^\]]*)\]/);
200
+ if (existingModules && existingModules[1]) {
201
+ const existingModuleList = existingModules[1].trim();
202
+ const allModules = [...modules];
203
+ if (existingModuleList) {
204
+ const existing = existingModuleList
205
+ .split(',')
206
+ .map(m => m.trim().replace(/['"]/g, ''));
207
+ allModules.push(...existing);
208
+ }
209
+ const uniqueModules = [...new Set(allModules)];
210
+ configContent = configContent.replace(/modules:\s*\[[^\]]*\]/, `modules: [${uniqueModules.map(m => `'${m}'`).join(', ')}]`);
211
+ }
212
+ }
213
+ else {
214
+ // Add new modules array
215
+ configContent = configContent.replace(/ssr:\s*true,/, `$&\n\n modules: [${modules.map(m => `'${m}'`).join(', ')}],`);
216
+ }
217
+ }
218
+ // Add app.head config if not present
219
+ if (!configContent.includes('app:')) {
220
+ configContent = configContent.replace(/site:\s*\{[^}]*\},/, `$&\n\n // App Config for UI-wide settings
221
+ app: {
222
+ head: {
223
+ charset: 'utf-8',
224
+ viewport: 'width=device-width, initial-scale=1',
225
+ meta: [
226
+ { name: 'description', content: 'A new setup for your project' },
227
+ { name: 'author', content: 'New Setup' },
228
+ { property: 'og:type', content: 'website' },
229
+ { name: 'msapplication-TileColor', content: '#000000' },
230
+ { name: 'theme-color', content: '#000000' },
231
+ ],
232
+ link: [
233
+ // { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
234
+ // { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon-180x180.png' },
235
+ // { rel: 'manifest', href: '/manifest.webmanifest' },
236
+ ],
237
+ },
238
+ },`);
239
+ }
240
+ // Add nitro config if not present
241
+ if (!configContent.includes('nitro:')) {
242
+ configContent = configContent.replace(/vite:\s*\{[^}]*\},/, `$&\n\n nitro: {
243
+ compressPublicAssets: {
244
+ brotli: true,
245
+ gzip: true,
246
+ },
247
+ // Enable crawling for SEO module compatibility
248
+ prerender: {
249
+ // set to true for production
250
+ crawlLinks: false,
251
+ routes: ['/']
252
+ }
253
+ },`);
254
+ }
255
+ // Add image config if not present
256
+ if (!configContent.includes('image:')) {
257
+ configContent = configContent.replace(/modules:\s*\[[^\]]*\],/, `$&\n\n // Image Optimization
258
+ image: {
259
+ quality: 95,
260
+ format: ['webp'],
261
+ screens: {
262
+ xs: 320,
263
+ sm: 640,
264
+ md: 768,
265
+ lg: 1200,
266
+ xl: 1400,
267
+ xxl: 1800,
268
+ '2xl': 2000,
269
+ },
270
+ },`);
271
+ }
272
+ // Add shadcn config if cssVars is true
273
+ if (cssVars && !configContent.includes('shadcn:')) {
274
+ configContent = configContent.replace(/image:\s*\{[^}]*\},/, `$&\n\n // UI Framework: Shadcn
275
+ shadcn: {
276
+ prefix: '',
277
+ componentDir: '@/components/ui',
278
+ },`);
279
+ }
280
+ // Update site config if not present
281
+ if (!configContent.includes('site:')) {
282
+ configContent = configContent.replace(/compatibilityDate:\s*'[^']*',/, `$&\n\n // SEO: Centralizing data
283
+ site: {
284
+ name: 'New Setup',
285
+ url: 'https://newsetup.com',
286
+ description: 'A new setup for your project',
287
+ defaultLocale: 'en',
288
+ },`);
289
+ }
290
+ // Update ogImage config if not present
291
+ if (!configContent.includes('ogImage:')) {
292
+ configContent = configContent.replace(/sitemap:\s*\{[^}]*\},/, `$&\n ogImage: {
293
+ defaults: {
294
+ component: 'OgImageTemplate',
295
+ props: {
296
+ title: 'New Setup',
297
+ description: 'A new setup for your project',
298
+ image: 'https://newsetup.com/og-image.png',
299
+ },
300
+ }
301
+ },`);
302
+ }
303
+ // Update robots config if not present
304
+ if (!configContent.includes('robots:')) {
305
+ configContent = configContent.replace(/ogImage:\s*\{[^}]*\},/, `$&\n robots: {
306
+ disallow: ['/api',],
307
+ },`);
308
+ }
309
+ writeFileSync(configPath, configContent, 'utf-8');
310
+ }
311
+ export async function generateViteConfig(projectPath,
312
+ //@ts-ignore
313
+ threejs, cssVars = false) {
314
+ const configPath = join(projectPath, 'vite.config.ts');
315
+ let configContent = '';
316
+ if (existsSync(configPath)) {
317
+ configContent = readFileSync(configPath, 'utf-8');
318
+ // If cssVars is enabled and tailwindcss plugin is not present, add it
319
+ if (cssVars && !configContent.includes('@tailwindcss/vite')) {
320
+ // Add import
321
+ if (!configContent.includes("import tailwindcss from '@tailwindcss/vite'")) {
322
+ configContent = configContent.replace(/import { defineConfig } from 'vite'/, "import { defineConfig } from 'vite'\nimport tailwindcss from '@tailwindcss/vite'");
323
+ }
324
+ // Add to plugins array
325
+ if (configContent.includes('plugins: [')) {
326
+ configContent = configContent.replace(/plugins:\s*\[/, 'plugins: [\n tailwindcss(),');
327
+ }
328
+ }
329
+ }
330
+ else {
331
+ const threejsChunk = threejs
332
+ ? ` // If you use heavy libs (like Three.js), split them too
333
+ if (id.includes('three')) return 'three-vendor';`
334
+ : '';
335
+ const tailwindImport = cssVars
336
+ ? "import tailwindcss from '@tailwindcss/vite'\n"
337
+ : '';
338
+ const tailwindPlugin = cssVars ? ' tailwindcss(),\n' : '';
339
+ configContent = `import { fileURLToPath, URL } from 'node:url'
340
+ ${tailwindImport}import { defineConfig } from 'vite'
341
+ import vue from '@vitejs/plugin-vue'
342
+ import vueDevTools from 'vite-plugin-vue-devtools'
343
+ import viteCompression from 'vite-plugin-compression'
344
+ import Sitemap from 'vite-plugin-sitemap'
345
+ import { ViteImageOptimizer } from 'vite-plugin-image-optimizer'
346
+
347
+ export default defineConfig(({ mode }) => {
348
+ const isProd = mode === 'production'
349
+
350
+ return {
351
+ plugins: [
352
+ vue(),
353
+ ${tailwindPlugin} // 1. Only load DevTools in development
354
+ !isProd && vueDevTools(),
355
+
356
+ ViteImageOptimizer({
357
+ test: /\\.(jpe?g|png|gif|tiff|webp|svg|avif)$/i,
358
+ includePublic: true,
359
+ logStats: true,
360
+ png: { quality: 75 },
361
+ jpeg: { quality: 75 },
362
+ jpg: { quality: 75 },
363
+ webp: { lossless: false, quality: 75 },
364
+ avif: { quality: 70 },
365
+ }),
366
+
367
+ Sitemap({
368
+ hostname: 'https://newsetup.com', // Don't forget to update this!
369
+ dynamicRoutes: [],
370
+ }),
371
+
372
+ // 2. Gzip Compression (Universal Fallback)
373
+ viteCompression({
374
+ algorithm: 'gzip',
375
+ ext: '.gz',
376
+ threshold: 10240,
377
+ deleteOriginFile: false,
378
+ }),
379
+
380
+ // 3. Brotli Compression (Modern Performance)
381
+ viteCompression({
382
+ algorithm: 'brotliCompress',
383
+ ext: '.br',
384
+ threshold: 10240,
385
+ deleteOriginFile: false,
386
+ }),
387
+ ],
388
+
389
+ resolve: {
390
+ alias: {
391
+ '@': fileURLToPath(new URL('./src', import.meta.url))
392
+ },
393
+ },
394
+
395
+ build: {
396
+ cssMinify: 'lightningcss', // Ensure 'lightningcss' is in package.json
397
+ // 4. Split Chunks for better Browser Caching
398
+ rollupOptions: {
399
+ output: {
400
+ manualChunks(id) {
401
+ if (id.includes('node_modules')) {
402
+ // Split standard Vue dependencies into their own chunk
403
+ if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
404
+ return 'vue-vendor';
405
+ }
406
+ ${threejsChunk}
407
+
408
+ return 'vendor';
409
+ }
410
+ },
411
+ },
412
+ },
413
+ },
414
+
415
+ esbuild: {
416
+ drop: isProd ? ['console', 'debugger'] : [],
417
+ },
418
+ }
419
+ })
420
+ `;
421
+ }
422
+ writeFileSync(configPath, configContent, 'utf-8');
423
+ }
424
+ export async function generateTailwindConfig(projectPath, projectType) {
425
+ const configPath = join(projectPath, 'tailwind.config.js');
426
+ const configContent = `/** @type {import('tailwindcss').Config} */
427
+ export default {
428
+ content: [
429
+ ${projectType === 'nuxt'
430
+ ? "'./components/**/*.{js,vue,ts}',"
431
+ : "'./index.html',"}
432
+ ${projectType === 'nuxt'
433
+ ? "'./layouts/**/*.vue',"
434
+ : "'./src/**/*.{vue,js,ts,jsx,tsx}',"}
435
+ ${projectType === 'nuxt' ? "'./pages/**/*.vue'," : ''}
436
+ ${projectType === 'nuxt' ? "'./plugins/**/*.{js,ts}'," : ''}
437
+ ${projectType === 'nuxt' ? "'./app.vue'," : ''}
438
+ ${projectType === 'nuxt' ? "'./error.vue'," : ''}
439
+ ],
440
+ theme: {
441
+ extend: {
442
+ colors: {
443
+ background: 'hsl(var(--background))',
444
+ foreground: 'hsl(var(--foreground))',
445
+ card: {
446
+ DEFAULT: 'hsl(var(--card))',
447
+ foreground: 'hsl(var(--card-foreground))',
448
+ },
449
+ popover: {
450
+ DEFAULT: 'hsl(var(--popover))',
451
+ foreground: 'hsl(var(--popover-foreground))',
452
+ },
453
+ primary: {
454
+ DEFAULT: 'hsl(var(--primary))',
455
+ foreground: 'hsl(var(--primary-foreground))',
456
+ },
457
+ secondary: {
458
+ DEFAULT: 'hsl(var(--secondary))',
459
+ foreground: 'hsl(var(--secondary-foreground))',
460
+ },
461
+ muted: {
462
+ DEFAULT: 'hsl(var(--muted))',
463
+ foreground: 'hsl(var(--muted-foreground))',
464
+ },
465
+ accent: {
466
+ DEFAULT: 'hsl(var(--accent))',
467
+ foreground: 'hsl(var(--accent-foreground))',
468
+ },
469
+ destructive: {
470
+ DEFAULT: 'hsl(var(--destructive))',
471
+ foreground: 'hsl(var(--destructive-foreground))',
472
+ },
473
+ border: 'hsl(var(--border))',
474
+ input: 'hsl(var(--input))',
475
+ ring: 'hsl(var(--ring))',
476
+ },
477
+ borderRadius: {
478
+ lg: 'var(--radius)',
479
+ md: 'calc(var(--radius) - 2px)',
480
+ sm: 'calc(var(--radius) - 4px)',
481
+ },
482
+ },
483
+ },
484
+ plugins: [],
485
+ }
486
+ `;
487
+ writeFileSync(configPath, configContent, 'utf-8');
488
+ }
489
+ export async function generatePostCSSConfig(projectPath) {
490
+ const configPath = join(projectPath, 'postcss.config.js');
491
+ const configContent = `export default {
492
+ plugins: {
493
+ tailwindcss: {},
494
+ autoprefixer: {},
495
+ },
496
+ }
497
+ `;
498
+ writeFileSync(configPath, configContent, 'utf-8');
499
+ }
500
+ export async function generateConfigFiles(projectType, projectPath, threejs, cssVars) {
501
+ if (projectType === 'nuxt') {
502
+ await generateNuxtConfig(projectPath, threejs, cssVars);
503
+ }
504
+ else if (projectType === 'vue') {
505
+ await generateViteConfig(projectPath, threejs, cssVars);
506
+ }
507
+ // Note: Vue projects with @tailwindcss/vite don't need tailwind.config.js or postcss.config.js
508
+ }
@@ -0,0 +1,4 @@
1
+ import type { ProjectType } from './project-detection.js';
2
+ export declare function generateCSSVariables(projectType: ProjectType, projectPath: string, initialSetup?: boolean): Promise<void>;
3
+ export declare function updateIndexHtml(projectPath: string): Promise<void>;
4
+ export declare function createTypographyPage(projectPath: string): Promise<void>;