@ynor/ynor 1.0.1

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 ADDED
@@ -0,0 +1,16 @@
1
+ # ⚡ .ynor Framework
2
+
3
+ A lightweight, next-generation JavaScript extension framework inspired by Svelte. Build reactive web applications with a clean, intuitive syntax.
4
+
5
+ ## Features
6
+
7
+ - **🎯 Svelte-like Syntax**: Write components with script, template, and style sections
8
+ - **⚡ Reactive**: Built-in reactivity with `$:` statements
9
+ - **📦 Stores**: Global state management with stores
10
+ - **🧩 Components**: Modular, reusable components
11
+ - **🔄 HMR**: Hot Module Replacement for development
12
+ - **🎨 Scoped Styles**: Component-scoped CSS
13
+ - **📱 Lightweight**: Minimal runtime overhead
14
+ - **🌐 Cross-browser**: Works in all modern browsers
15
+
16
+ ## Project Structure
package/bin/ynor.js ADDED
@@ -0,0 +1,519 @@
1
+ #!/usr/bin/env node
2
+ // bin/ynor.js
3
+
4
+ import { program } from 'commander';
5
+ import chalk from 'chalk';
6
+ import fs from 'fs';
7
+ import path from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ import { createRequire } from 'module';
10
+ import { exec, spawn } from 'child_process';
11
+ import readline from 'readline';
12
+
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
+ const require = createRequire(import.meta.url);
15
+
16
+ // Try to load package.json
17
+ let pkg = { version: '1.0.0' };
18
+ try {
19
+ const pkgPath = path.resolve(__dirname, '../package.json');
20
+ if (fs.existsSync(pkgPath)) {
21
+ pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
22
+ }
23
+ } catch (e) {
24
+ // Use default version
25
+ }
26
+
27
+ // ============================================
28
+ // CLI PROGRAM
29
+ // ============================================
30
+ program
31
+ .name('ynor')
32
+ .description('⚡ YNOR Framework CLI - Next-gen JS extension framework')
33
+ .version(pkg.version || '1.0.0');
34
+
35
+ // ============================================
36
+ // CREATE COMMAND
37
+ // ============================================
38
+ program
39
+ .command('create <project-name>')
40
+ .description('Create a new .ynor project')
41
+ .option('-t, --template <template>', 'Project template (basic, minimal, full)')
42
+ .option('-y, --yes', 'Skip confirmation prompts')
43
+ .action(async (projectName, options) => {
44
+ console.log(chalk.blue(`\n ⚡ Creating .ynor project: ${projectName}`));
45
+ console.log(chalk.dim(' ──────────────────────────────\n'));
46
+
47
+ try {
48
+ const projectPath = path.join(process.cwd(), projectName);
49
+
50
+ // Check if directory exists
51
+ if (fs.existsSync(projectPath)) {
52
+ console.log(chalk.red(` ❌ Directory ${projectName} already exists!`));
53
+ process.exit(1);
54
+ }
55
+
56
+ // Create project structure
57
+ console.log(chalk.dim(' 📁 Creating project structure...'));
58
+ fs.mkdirSync(projectPath, { recursive: true });
59
+ fs.mkdirSync(path.join(projectPath, 'src'), { recursive: true });
60
+ fs.mkdirSync(path.join(projectPath, 'src', 'lib'), { recursive: true });
61
+ fs.mkdirSync(path.join(projectPath, 'src', 'lib', 'components'), { recursive: true });
62
+ fs.mkdirSync(path.join(projectPath, 'src', 'styles'), { recursive: true });
63
+ fs.mkdirSync(path.join(projectPath, 'static'), { recursive: true });
64
+
65
+ // Create package.json
66
+ console.log(chalk.dim(' 📦 Creating package.json...'));
67
+ const packageJson = {
68
+ name: projectName,
69
+ version: "1.0.0",
70
+ type: "module",
71
+ scripts: {
72
+ dev: "vite",
73
+ build: "vite build",
74
+ preview: "vite preview"
75
+ },
76
+ devDependencies: {
77
+ "ynor": "latest",
78
+ "vite": "^8.0.0"
79
+ }
80
+ };
81
+
82
+ fs.writeFileSync(
83
+ path.join(projectPath, 'package.json'),
84
+ JSON.stringify(packageJson, null, 2)
85
+ );
86
+ console.log(chalk.green(' ✅ package.json created'));
87
+
88
+ // Create index.html
89
+ console.log(chalk.dim(' 📄 Creating index.html...'));
90
+ const indexHtml = `<!DOCTYPE html>
91
+ <html lang="en">
92
+ <head>
93
+ <meta charset="UTF-8" />
94
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
95
+ <title>.ynor Framework</title>
96
+ <link rel="icon" href="/favicon.ico" />
97
+ <style>
98
+ * { box-sizing: border-box; margin: 0; padding: 0; }
99
+ body {
100
+ font-family: system-ui, -apple-system, sans-serif;
101
+ background: #f5f7fb;
102
+ color: #1e293b;
103
+ line-height: 1.6;
104
+ min-height: 100vh;
105
+ }
106
+ #app { min-height: 100vh; padding: 20px; }
107
+ </style>
108
+ </head>
109
+ <body>
110
+ <div id="app"></div>
111
+ <script type="module" src="/src/main.js"></script>
112
+ </body>
113
+ </html>`;
114
+ fs.writeFileSync(path.join(projectPath, 'index.html'), indexHtml);
115
+ console.log(chalk.green(' ✅ index.html created'));
116
+
117
+ // Create main.js
118
+ console.log(chalk.dim(' 📄 Creating src/main.js...'));
119
+ const mainJs = `import { runtime, mount, store } from 'ynor';
120
+ import App from './App.ynor';
121
+
122
+ console.log('🚀 Starting .ynor application...');
123
+
124
+ // Initialize stores
125
+ const todos = store('todos', [
126
+ { id: 1, text: 'Learn .ynor', done: false }
127
+ ]);
128
+
129
+ // Mount app
130
+ const app = mount(App, document.getElementById('app'), { todos });
131
+
132
+ console.log('⚡ .ynor framework initialized');
133
+ console.log('📁 Components loaded:', Array.from(runtime.components.keys()));
134
+
135
+ // HMR support
136
+ if (import.meta.hot) {
137
+ import.meta.hot.accept('./App.ynor', ({ default: NewApp }) => {
138
+ app.$destroy();
139
+ mount(NewApp, document.getElementById('app'), { todos });
140
+ });
141
+ }`;
142
+ fs.writeFileSync(path.join(projectPath, 'src', 'main.js'), mainJs);
143
+ console.log(chalk.green(' ✅ src/main.js created'));
144
+
145
+ // Create App.ynor
146
+ console.log(chalk.dim(' 📄 Creating src/App.ynor...'));
147
+ const appYnor = `<script>
148
+ let count = 0;
149
+
150
+ function increment() {
151
+ count++;
152
+ console.log('Count:', count);
153
+ this._update();
154
+ }
155
+ </script>
156
+
157
+ <style>
158
+ .app {
159
+ padding: 40px;
160
+ text-align: center;
161
+ font-family: system-ui, sans-serif;
162
+ background: white;
163
+ border-radius: 20px;
164
+ max-width: 600px;
165
+ margin: 20px auto;
166
+ box-shadow: 0 8px 30px rgba(0,0,0,0.08);
167
+ }
168
+ .app h1 {
169
+ color: #4f46e5;
170
+ font-size: 2.5rem;
171
+ margin-bottom: 10px;
172
+ }
173
+ .app p {
174
+ font-size: 1.2rem;
175
+ color: #1e293b;
176
+ }
177
+ .count {
178
+ font-size: 3rem;
179
+ font-weight: 700;
180
+ color: #4f46e5;
181
+ margin: 20px 0;
182
+ }
183
+ .app button {
184
+ padding: 10px 24px;
185
+ border: none;
186
+ border-radius: 40px;
187
+ background: #4f46e5;
188
+ color: white;
189
+ font-weight: 600;
190
+ cursor: pointer;
191
+ font-size: 16px;
192
+ transition: all 0.2s;
193
+ }
194
+ .app button:hover {
195
+ background: #4338ca;
196
+ transform: scale(1.02);
197
+ }
198
+ </style>
199
+
200
+ <template>
201
+ <div class="app">
202
+ <h1>⚡ .ynor</h1>
203
+ <p>Your .ynor app is ready!</p>
204
+ <div class="count">{count}</div>
205
+ <button on:click={increment}>Increment</button>
206
+ </div>
207
+ </template>`;
208
+ fs.writeFileSync(path.join(projectPath, 'src', 'App.ynor'), appYnor);
209
+ console.log(chalk.green(' ✅ src/App.ynor created'));
210
+
211
+ // Create vite.config.js
212
+ console.log(chalk.dim(' 📄 Creating vite.config.js...'));
213
+ const viteConfig = `import { defineConfig } from 'vite';
214
+ import { ynorPlugin } from 'ynor/plugin';
215
+
216
+ export default defineConfig({
217
+ plugins: [ynorPlugin()],
218
+ resolve: {
219
+ extensions: ['.ynor', '.js', '.jsx', '.ts', '.tsx']
220
+ },
221
+ server: {
222
+ port: 3000,
223
+ open: true
224
+ }
225
+ });`;
226
+ fs.writeFileSync(path.join(projectPath, 'vite.config.js'), viteConfig);
227
+ console.log(chalk.green(' ✅ vite.config.js created'));
228
+
229
+ // Create global.css
230
+ console.log(chalk.dim(' 📄 Creating src/styles/global.css...'));
231
+ const globalCss = `/* src/styles/global.css */
232
+ * {
233
+ box-sizing: border-box;
234
+ margin: 0;
235
+ padding: 0;
236
+ }
237
+
238
+ body {
239
+ font-family: system-ui, -apple-system, sans-serif;
240
+ background: #f5f7fb;
241
+ color: #1e293b;
242
+ line-height: 1.6;
243
+ min-height: 100vh;
244
+ }
245
+
246
+ #app {
247
+ min-height: 100vh;
248
+ padding: 20px;
249
+ }`;
250
+ fs.writeFileSync(path.join(projectPath, 'src', 'styles', 'global.css'), globalCss);
251
+ console.log(chalk.green(' ✅ src/styles/global.css created'));
252
+
253
+ // Create README.md
254
+ console.log(chalk.dim(' 📄 Creating README.md...'));
255
+ const readme = `# ${projectName}
256
+
257
+ ⚡ A .ynor framework project
258
+
259
+ ## Getting Started
260
+
261
+ \`\`\`bash
262
+ npm install
263
+ npm run dev
264
+ \`\`\`
265
+
266
+ ## Build
267
+
268
+ \`\`\`bash
269
+ npm run build
270
+ npm run preview
271
+ \`\`\`
272
+
273
+ ## Project Structure
274
+
275
+ \`\`\`
276
+ ${projectName}/
277
+ ├── src/
278
+ │ ├── lib/
279
+ │ │ └── components/ # .ynor components
280
+ │ ├── styles/
281
+ │ │ └── global.css # Global styles
282
+ │ ├── App.ynor # Main app component
283
+ │ └── main.js # Entry point
284
+ ├── static/ # Static assets
285
+ ├── index.html # HTML entry point
286
+ ├── vite.config.js # Vite configuration
287
+ └── package.json # Dependencies
288
+ \`\`\`
289
+
290
+ ## Learn More
291
+
292
+ Visit [ynor.dev](https://ynor.app) for documentation.
293
+ `;
294
+ fs.writeFileSync(path.join(projectPath, 'README.md'), readme);
295
+ console.log(chalk.green(' ✅ README.md created'));
296
+
297
+ // Create .gitignore
298
+ console.log(chalk.dim(' 📄 Creating .gitignore...'));
299
+ const gitignore = `# Dependencies
300
+ node_modules/
301
+ .pnpm-store/
302
+
303
+ # Build outputs
304
+ dist/
305
+ build/
306
+ .svelte-kit/
307
+
308
+ # Environment
309
+ .env
310
+ .env.local
311
+ .env.*.local
312
+
313
+ # IDE
314
+ .vscode/
315
+ .idea/
316
+ *.swp
317
+ *.swo
318
+
319
+ # OS
320
+ .DS_Store
321
+ Thumbs.db
322
+
323
+ # Logs
324
+ *.log
325
+ npm-debug.log*
326
+ yarn-debug.log*
327
+ yarn-error.log*
328
+
329
+ # Cache
330
+ .vite/
331
+ .cache/
332
+ `;
333
+ fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignore);
334
+ console.log(chalk.green(' ✅ .gitignore created'));
335
+
336
+ console.log(chalk.green(`\n ✅ Project ${projectName} created successfully!`));
337
+ console.log(chalk.dim(`\n 📁 cd ${projectName}`));
338
+ console.log(chalk.dim(` 📦 npm install`));
339
+ console.log(chalk.dim(` 🚀 npm run dev\n`));
340
+
341
+ // Ask if user wants to install dependencies
342
+ const rl = readline.createInterface({
343
+ input: process.stdin,
344
+ output: process.stdout
345
+ });
346
+
347
+ rl.question(chalk.yellow(' ❓ Install dependencies now? (y/n) '), (answer) => {
348
+ rl.close();
349
+ if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
350
+ console.log(chalk.blue('\n 📦 Installing dependencies...\n'));
351
+ const install = spawn('npm', ['install'], {
352
+ cwd: projectPath,
353
+ stdio: 'inherit',
354
+ shell: true
355
+ });
356
+
357
+ install.on('close', (code) => {
358
+ if (code === 0) {
359
+ console.log(chalk.green('\n ✅ Dependencies installed!\n'));
360
+ console.log(chalk.dim(` 🚀 cd ${projectName} && npm run dev\n`));
361
+ } else {
362
+ console.log(chalk.yellow(`\n ⚠️ Failed to install dependencies. Run "cd ${projectName} && npm install" manually.\n`));
363
+ }
364
+ });
365
+ } else {
366
+ console.log(chalk.dim(`\n 📦 Run "cd ${projectName} && npm install" to install dependencies.\n`));
367
+ }
368
+ });
369
+
370
+ } catch (error) {
371
+ console.log(chalk.red(` ❌ Error: ${error.message}`));
372
+ process.exit(1);
373
+ }
374
+ });
375
+
376
+ // ============================================
377
+ // DEV COMMAND
378
+ // ============================================
379
+ program
380
+ .command('dev')
381
+ .description('Start development server')
382
+ .option('-p, --port <port>', 'Port to run on', '3000')
383
+ .action((options) => {
384
+ console.log(chalk.blue('\n ⚡ Starting .ynor dev server...\n'));
385
+
386
+ // Check if vite is installed
387
+ const hasVite = fs.existsSync(path.join(process.cwd(), 'node_modules', '.bin', 'vite'));
388
+
389
+ if (!hasVite) {
390
+ console.log(chalk.yellow(' ⚠️ Vite not found. Installing...\n'));
391
+ const install = spawn('npm', ['install', '-D', 'vite'], {
392
+ stdio: 'inherit',
393
+ shell: true
394
+ });
395
+
396
+ install.on('close', (code) => {
397
+ if (code === 0) {
398
+ startDevServer(options.port);
399
+ } else {
400
+ console.log(chalk.red(' ❌ Failed to install Vite.'));
401
+ process.exit(1);
402
+ }
403
+ });
404
+ } else {
405
+ startDevServer(options.port);
406
+ }
407
+ });
408
+
409
+ function startDevServer(port) {
410
+ const vite = spawn('npx', ['vite', 'dev', '--port', port], {
411
+ stdio: 'inherit',
412
+ shell: true
413
+ });
414
+
415
+ vite.on('close', (code) => {
416
+ if (code !== 0) {
417
+ console.log(chalk.red(`\n ❌ Dev server stopped with code ${code}`));
418
+ }
419
+ });
420
+ }
421
+
422
+ // ============================================
423
+ // BUILD COMMAND
424
+ // ============================================
425
+ program
426
+ .command('build')
427
+ .description('Build project for production')
428
+ .option('-o, --out <dir>', 'Output directory', 'dist')
429
+ .action((options) => {
430
+ console.log(chalk.blue('\n ⚡ Building .ynor project...\n'));
431
+
432
+ const build = spawn('npx', ['vite', 'build', '--outDir', options.out], {
433
+ stdio: 'inherit',
434
+ shell: true
435
+ });
436
+
437
+ build.on('close', (code) => {
438
+ if (code === 0) {
439
+ console.log(chalk.green(`\n ✅ Build complete! Output: ${options.out}/\n`));
440
+ } else {
441
+ console.log(chalk.red(`\n ❌ Build failed with code ${code}\n`));
442
+ process.exit(code);
443
+ }
444
+ });
445
+ });
446
+
447
+ // ============================================
448
+ // PREVIEW COMMAND
449
+ // ============================================
450
+ program
451
+ .command('preview')
452
+ .description('Preview production build')
453
+ .option('-p, --port <port>', 'Port to run on', '4173')
454
+ .action((options) => {
455
+ console.log(chalk.blue('\n ⚡ Previewing .ynor project...\n'));
456
+
457
+ const preview = spawn('npx', ['vite', 'preview', '--port', options.port], {
458
+ stdio: 'inherit',
459
+ shell: true
460
+ });
461
+
462
+ preview.on('close', (code) => {
463
+ if (code !== 0) {
464
+ console.log(chalk.red(`\n ❌ Preview stopped with code ${code}`));
465
+ }
466
+ });
467
+ });
468
+
469
+ // ============================================
470
+ // INFO COMMAND
471
+ // ============================================
472
+ program
473
+ .command('info')
474
+ .description('Show information about .ynor framework')
475
+ .action(() => {
476
+ console.log(chalk.blue('\n ⚡ YNOR Framework Information\n'));
477
+ console.log(chalk.dim(' ──────────────────────────────\n'));
478
+
479
+ console.log(chalk.bold(' 📦 Version:'), pkg.version || '1.0.0');
480
+ console.log(chalk.bold(' 📁 Framework:'), '.ynor');
481
+ console.log(chalk.bold(' 🚀 Status:'), chalk.green('Ready'));
482
+
483
+ // Check if project has .ynor files
484
+ try {
485
+ const files = fs.readdirSync(process.cwd());
486
+ const yFiles = files.filter(f => f.endsWith('.ynor'));
487
+ if (yFiles.length > 0) {
488
+ console.log(chalk.bold(' 📄 .ynor files:'), chalk.green(`${yFiles.length} found`));
489
+ yFiles.forEach(f => console.log(` - ${f}`));
490
+ } else {
491
+ console.log(chalk.bold(' 📄 .ynor files:'), chalk.yellow('None found'));
492
+ }
493
+ } catch (e) {
494
+ // Ignore
495
+ }
496
+
497
+ console.log(chalk.dim('\n 📚 Documentation:'), 'https://ynor.app');
498
+ console.log(chalk.dim(' 🐛 Report issues:'), 'https://github.com/ynor-app/.ynor/issues\n');
499
+ });
500
+
501
+ // ============================================
502
+ // HELP COMMAND (default)
503
+ // ============================================
504
+ program
505
+ .command('help')
506
+ .description('Show help')
507
+ .action(() => {
508
+ program.help();
509
+ });
510
+
511
+ // ============================================
512
+ // PARSE ARGUMENTS
513
+ // ============================================
514
+ program.parse();
515
+
516
+ // If no arguments, show help
517
+ if (!process.argv.slice(2).length) {
518
+ program.help();
519
+ }
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@ynor/ynor",
3
+ "version": "1.0.1",
4
+ "description": "⚡ Lightweight next-gen JS extension framework like Svelte",
5
+ "type": "module",
6
+ "main": "./src/lib/core/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./src/lib/core/index.js",
10
+ "types": "./src/lib/core/index.d.ts"
11
+ },
12
+ "./compiler": {
13
+ "import": "./src/lib/core/compiler.js",
14
+ "types": "./src/lib/core/compiler.d.ts"
15
+ },
16
+ "./runtime": {
17
+ "import": "./src/lib/core/runtime.js",
18
+ "types": "./src/lib/core/runtime.d.ts"
19
+ },
20
+ "./plugin": {
21
+ "import": "./src/lib/core/plugin.js",
22
+ "types": "./src/lib/core/plugin.d.ts"
23
+ }
24
+ },
25
+ "bin": {
26
+ "ynor": "./bin/ynor.js"
27
+ },
28
+ "files": [
29
+ "src/lib/core/",
30
+ "bin/",
31
+ "README.md",
32
+ "LICENSE",
33
+ "CHANGELOG.md"
34
+ ],
35
+ "scripts": {
36
+ "dev": "vite dev",
37
+ "build": "vite build",
38
+ "preview": "vite preview",
39
+ "prepare": "svelte-kit sync || echo ''",
40
+ "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
41
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
42
+ "test": "node test/test.js",
43
+ "pub:patch": "npm version patch && npm publish --access public",
44
+ "pub:minor": "npm version minor && npm publish --access public",
45
+ "pub:major": "npm version major && npm publish --access public"
46
+ },
47
+ "dependencies": {
48
+ "acorn": "^8.17.0",
49
+ "chalk": "^5.6.2",
50
+ "commander": "^15.0.0",
51
+ "magic-string": "^0.30.21"
52
+ },
53
+ "devDependencies": {
54
+ "@sveltejs/adapter-auto": "^7.0.1",
55
+ "@sveltejs/kit": "^2.63.0",
56
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
57
+ "svelte": "^5.56.1",
58
+ "svelte-check": "^4.6.0",
59
+ "typescript": "^6.0.3",
60
+ "vite": "^8.0.16"
61
+ },
62
+ "peerDependencies": {
63
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
64
+ },
65
+ "keywords": [
66
+ "ynor",
67
+ "framework",
68
+ "svelte-like",
69
+ "reactive",
70
+ "components",
71
+ "vite-plugin",
72
+ "compiler",
73
+ "next-gen",
74
+ "lightweight"
75
+ ],
76
+ "author": "Rony MAN",
77
+ "license": "MIT",
78
+ "repository": {
79
+ "type": "git",
80
+ "url": "https://github.com/ynor-app/.ynor"
81
+ },
82
+ "bugs": {
83
+ "url": "https://github.com/ynor-app/.ynor/issues"
84
+ },
85
+ "homepage": "https://ynor.app",
86
+ "engines": {
87
+ "node": ">=18.0.0"
88
+ },
89
+ "funding": {
90
+ "type": "github",
91
+ "url": "https://github.com/ynor-app/.ynor/sponsors/ynor"
92
+ }
93
+ }