zylaris 1.0.2

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 (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +558 -0
  3. package/Zylaris.js.png +0 -0
  4. package/examples/default/index.html +13 -0
  5. package/examples/default/package.json +23 -0
  6. package/examples/default/src/app/about/page.tsx +18 -0
  7. package/examples/default/src/app/counter/page.tsx +22 -0
  8. package/examples/default/src/app/global.css +225 -0
  9. package/examples/default/src/app/layout.tsx +33 -0
  10. package/examples/default/src/app/page.tsx +14 -0
  11. package/examples/default/src/entry-client.tsx +87 -0
  12. package/examples/default/src/entry-server.tsx +52 -0
  13. package/examples/default/src/router.ts +60 -0
  14. package/examples/default/tsconfig.json +28 -0
  15. package/examples/default/zylaris.config.ts +24 -0
  16. package/package.json +34 -0
  17. package/packages/adapter/package.json +59 -0
  18. package/packages/adapter/src/adapters/bun.ts +215 -0
  19. package/packages/adapter/src/adapters/cloudflare.ts +278 -0
  20. package/packages/adapter/src/adapters/deno.ts +219 -0
  21. package/packages/adapter/src/adapters/netlify.ts +274 -0
  22. package/packages/adapter/src/adapters/node.ts +155 -0
  23. package/packages/adapter/src/adapters/static.ts +134 -0
  24. package/packages/adapter/src/adapters/vercel.ts +239 -0
  25. package/packages/adapter/src/index.ts +115 -0
  26. package/packages/adapter/src/lib/builder.ts +361 -0
  27. package/packages/adapter/src/types.ts +191 -0
  28. package/packages/adapter/tsconfig.json +8 -0
  29. package/packages/cli/package.json +43 -0
  30. package/packages/cli/src/bin.ts +107 -0
  31. package/packages/cli/src/commands/build.ts +197 -0
  32. package/packages/cli/src/commands/create.ts +222 -0
  33. package/packages/cli/src/commands/deploy.ts +90 -0
  34. package/packages/cli/src/commands/dev.ts +108 -0
  35. package/packages/cli/src/index.ts +6 -0
  36. package/packages/cli/tsconfig.json +9 -0
  37. package/packages/compiler/package.json +39 -0
  38. package/packages/compiler/src/index.ts +210 -0
  39. package/packages/compiler/src/jit.ts +187 -0
  40. package/packages/compiler/tsconfig.json +9 -0
  41. package/packages/core/package.json +55 -0
  42. package/packages/core/src/components.test.ts +125 -0
  43. package/packages/core/src/components.ts +181 -0
  44. package/packages/core/src/config.ts +204 -0
  45. package/packages/core/src/hooks.ts +142 -0
  46. package/packages/core/src/index.ts +59 -0
  47. package/packages/core/src/jsx-runtime.ts +46 -0
  48. package/packages/core/tsconfig.json +16 -0
  49. package/packages/dev-server/package.json +51 -0
  50. package/packages/dev-server/src/index.ts +306 -0
  51. package/packages/dev-server/src/jit-middleware.ts +78 -0
  52. package/packages/dev-server/tsconfig.json +9 -0
  53. package/packages/plugins/package.json +44 -0
  54. package/packages/plugins/src/cdn/loader.ts +275 -0
  55. package/packages/plugins/src/index.ts +238 -0
  56. package/packages/plugins/src/loaders/auto-import.ts +219 -0
  57. package/packages/plugins/src/loaders/external.ts +332 -0
  58. package/packages/plugins/src/transforms/index.ts +407 -0
  59. package/packages/plugins/src/types.ts +296 -0
  60. package/packages/plugins/tsconfig.json +8 -0
  61. package/packages/reactivity/package.json +36 -0
  62. package/packages/reactivity/src/computed.d.ts +3 -0
  63. package/packages/reactivity/src/computed.d.ts.map +1 -0
  64. package/packages/reactivity/src/computed.js +64 -0
  65. package/packages/reactivity/src/computed.js.map +1 -0
  66. package/packages/reactivity/src/computed.test.ts +83 -0
  67. package/packages/reactivity/src/computed.ts +69 -0
  68. package/packages/reactivity/src/index.d.ts +6 -0
  69. package/packages/reactivity/src/index.d.ts.map +1 -0
  70. package/packages/reactivity/src/index.js +7 -0
  71. package/packages/reactivity/src/index.js.map +1 -0
  72. package/packages/reactivity/src/index.ts +18 -0
  73. package/packages/reactivity/src/resource.d.ts +6 -0
  74. package/packages/reactivity/src/resource.d.ts.map +1 -0
  75. package/packages/reactivity/src/resource.js +43 -0
  76. package/packages/reactivity/src/resource.js.map +1 -0
  77. package/packages/reactivity/src/resource.test.ts +70 -0
  78. package/packages/reactivity/src/resource.ts +59 -0
  79. package/packages/reactivity/src/signal.d.ts +7 -0
  80. package/packages/reactivity/src/signal.d.ts.map +1 -0
  81. package/packages/reactivity/src/signal.js +145 -0
  82. package/packages/reactivity/src/signal.js.map +1 -0
  83. package/packages/reactivity/src/signal.test.ts +130 -0
  84. package/packages/reactivity/src/signal.ts +207 -0
  85. package/packages/reactivity/src/store.d.ts +4 -0
  86. package/packages/reactivity/src/store.d.ts.map +1 -0
  87. package/packages/reactivity/src/store.js +62 -0
  88. package/packages/reactivity/src/store.js.map +1 -0
  89. package/packages/reactivity/src/store.test.ts +38 -0
  90. package/packages/reactivity/src/store.ts +111 -0
  91. package/packages/reactivity/src/types.d.ts +43 -0
  92. package/packages/reactivity/src/types.d.ts.map +1 -0
  93. package/packages/reactivity/src/types.js +3 -0
  94. package/packages/reactivity/src/types.js.map +1 -0
  95. package/packages/reactivity/src/types.ts +43 -0
  96. package/packages/reactivity/tsconfig.json +9 -0
  97. package/packages/router/package.json +44 -0
  98. package/packages/router/src/components.tsx +150 -0
  99. package/packages/router/src/fs-router.ts +163 -0
  100. package/packages/router/src/index.ts +22 -0
  101. package/packages/router/src/router.test.ts +111 -0
  102. package/packages/router/src/router.ts +112 -0
  103. package/packages/router/src/types.ts +69 -0
  104. package/packages/router/tsconfig.json +10 -0
  105. package/packages/server/package.json +41 -0
  106. package/packages/server/src/action.test.ts +102 -0
  107. package/packages/server/src/action.ts +201 -0
  108. package/packages/server/src/api.ts +143 -0
  109. package/packages/server/src/index.ts +18 -0
  110. package/packages/server/src/types.ts +72 -0
  111. package/packages/server/tsconfig.json +9 -0
  112. package/pnpm-workspace.yaml +4 -0
  113. package/scripts/publish.ps1 +138 -0
  114. package/scripts/publish.sh +142 -0
  115. package/tsconfig.json +28 -0
  116. package/turbo.json +24 -0
@@ -0,0 +1,204 @@
1
+ // Configuration types and helper for Zylaris
2
+
3
+ /** Deployment target platforms */
4
+ export type DeploymentTarget =
5
+ | 'static' // GitHub Pages, Surge.sh, etc.
6
+ | 'node' // Node.js server
7
+ | 'vercel' // Vercel (Serverless + Edge)
8
+ | 'netlify' // Netlify (Functions + Edge)
9
+ | 'cloudflare' // Cloudflare Pages/Workers
10
+ | 'deno' // Deno Deploy
11
+ | 'bun'; // Bun runtime
12
+
13
+ /** Serverless/Edge function config */
14
+ export interface FunctionConfig {
15
+ /** Function name */
16
+ name?: string;
17
+ /** Route pattern */
18
+ route?: string;
19
+ /** Memory allocation (MB) */
20
+ memory?: number;
21
+ /** Timeout (seconds) */
22
+ timeout?: number;
23
+ /** Regions to deploy */
24
+ regions?: string[];
25
+ /** Edge function flag */
26
+ edge?: boolean;
27
+ }
28
+
29
+ /** Static generation options */
30
+ export interface StaticOptions {
31
+ /** Routes to pre-render */
32
+ routes?: string[];
33
+ /** 404 page path */
34
+ fallback?: string;
35
+ /** Crawl dynamic routes */
36
+ crawl?: boolean;
37
+ /** Base path for assets */
38
+ base?: string;
39
+ }
40
+
41
+ /** Adapter configuration */
42
+ export interface AdapterConfig {
43
+ /** Target platform */
44
+ target: DeploymentTarget;
45
+ /** Entry point */
46
+ entry?: string;
47
+ /** Output directory */
48
+ outDir?: string;
49
+ /** Static generation options */
50
+ static?: StaticOptions;
51
+ /** Serverless function config */
52
+ function?: FunctionConfig;
53
+ /** Environment variables to include */
54
+ env?: Record<string, string>;
55
+ /** Headers for HTTP responses */
56
+ headers?: Record<string, string>;
57
+ /** Redirects configuration */
58
+ redirects?: Array<{ from: string; to: string; status?: number }>;
59
+ /** Rewrites configuration */
60
+ rewrites?: Array<{ from: string; to: string }>;
61
+ /** Trailing slash handling */
62
+ trailingSlash?: 'always' | 'never' | 'ignore';
63
+ /** Clean URLs (no .html extension) */
64
+ cleanUrls?: boolean;
65
+ }
66
+
67
+ export interface ZylarisConfig {
68
+ /** Deployment target */
69
+ adapter?: DeploymentTarget | AdapterConfig;
70
+ /** Runtime environment */
71
+ runtime?: 'node' | 'edge' | 'deno' | 'bun';
72
+ /** Rendering configuration */
73
+ rendering?: {
74
+ default?: 'ssr' | 'csr' | 'ssg';
75
+ dynamicRoutes?: string[];
76
+ staticPaths?: string[];
77
+ };
78
+ /** Islands architecture */
79
+ islands?: {
80
+ mode?: 'auto' | 'manual' | 'off';
81
+ components?: string[];
82
+ };
83
+ /** Compiler options */
84
+ compiler?: {
85
+ target?: 'es2020' | 'es2022' | 'esnext';
86
+ minify?: boolean;
87
+ sourceMap?: boolean;
88
+ };
89
+ /** Server configuration */
90
+ server?: {
91
+ port?: number;
92
+ host?: string;
93
+ };
94
+ /** Styling options */
95
+ styling?: {
96
+ tailwind?: boolean;
97
+ cssModules?: boolean;
98
+ };
99
+ /** TypeScript options */
100
+ typescript?: {
101
+ strict?: boolean;
102
+ };
103
+ /** Build output */
104
+ build?: {
105
+ outDir?: string;
106
+ analyze?: boolean;
107
+ };
108
+ /** Deployment configuration */
109
+ deploy?: {
110
+ function?: FunctionConfig;
111
+ headers?: Record<string, string>;
112
+ redirects?: Array<{ from: string; to: string; status?: number }>;
113
+ rewrites?: Array<{ from: string; to: string }>;
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Define Zylaris configuration with type checking
119
+ */
120
+ export function defineConfig(config: ZylarisConfig): ZylarisConfig {
121
+ return config;
122
+ }
123
+
124
+ /** Preset configurations for common setups */
125
+ export const presets = {
126
+ /** Static site (GitHub Pages, Netlify Static, etc.) */
127
+ static: defineConfig({
128
+ adapter: 'static',
129
+ rendering: { default: 'ssg' },
130
+ islands: { mode: 'off' },
131
+ }),
132
+
133
+ /** Node.js server */
134
+ node: defineConfig({
135
+ adapter: 'node',
136
+ runtime: 'node',
137
+ rendering: { default: 'ssr' },
138
+ islands: { mode: 'auto' },
139
+ }),
140
+
141
+ /** Vercel Serverless */
142
+ vercel: defineConfig({
143
+ adapter: 'vercel',
144
+ runtime: 'edge',
145
+ rendering: { default: 'ssr' },
146
+ islands: { mode: 'auto' },
147
+ }),
148
+
149
+ /** Vercel Edge */
150
+ vercelEdge: defineConfig({
151
+ adapter: {
152
+ target: 'vercel',
153
+ function: { edge: true },
154
+ },
155
+ runtime: 'edge',
156
+ rendering: { default: 'ssr' },
157
+ islands: { mode: 'auto' },
158
+ }),
159
+
160
+ /** Netlify Functions */
161
+ netlify: defineConfig({
162
+ adapter: 'netlify',
163
+ runtime: 'node',
164
+ rendering: { default: 'ssr' },
165
+ islands: { mode: 'auto' },
166
+ }),
167
+
168
+ /** Netlify Edge */
169
+ netlifyEdge: defineConfig({
170
+ adapter: {
171
+ target: 'netlify',
172
+ function: { edge: true },
173
+ },
174
+ runtime: 'edge',
175
+ rendering: { default: 'ssr' },
176
+ islands: { mode: 'auto' },
177
+ }),
178
+
179
+ /** Cloudflare Pages */
180
+ cloudflare: defineConfig({
181
+ adapter: 'cloudflare',
182
+ runtime: 'edge',
183
+ rendering: { default: 'ssr' },
184
+ islands: { mode: 'auto' },
185
+ }),
186
+
187
+ /** Deno Deploy */
188
+ deno: defineConfig({
189
+ adapter: 'deno',
190
+ runtime: 'deno',
191
+ rendering: { default: 'ssr' },
192
+ islands: { mode: 'auto' },
193
+ }),
194
+
195
+ /** Bun runtime */
196
+ bun: defineConfig({
197
+ adapter: 'bun',
198
+ runtime: 'bun',
199
+ rendering: { default: 'ssr' },
200
+ islands: { mode: 'auto' },
201
+ }),
202
+ };
203
+
204
+ export default defineConfig;
@@ -0,0 +1,142 @@
1
+ // React-compatible hooks that use Zylaris signals under the hood
2
+
3
+ import { useState, useEffect, useCallback, useRef } from 'react';
4
+ import { signal, computed, resource as createResource } from '@zylaris/reactivity';
5
+ import type { Signal } from '@zylaris/reactivity';
6
+
7
+ // useSignal - Bridge React state with Zylaris signals
8
+ export function useSignal<T>(initialValue: T): Signal<T> {
9
+ const [sig] = useState(() => signal(initialValue));
10
+ return sig;
11
+ }
12
+
13
+ // useComputed - Computed signal in React component
14
+ export function useComputed<T>(fn: () => T): T {
15
+ const [comp] = useState(() => computed(fn));
16
+ const [value, setValue] = useState(comp.peek());
17
+
18
+ useEffect(() => {
19
+ const unsubscribe = comp.subscribe(setValue);
20
+ return unsubscribe;
21
+ }, [comp]);
22
+
23
+ return value;
24
+ }
25
+
26
+ // useResource - Async data fetching
27
+ export function useResource<T>(fetcher: () => Promise<T>) {
28
+ const [res] = useState(() => createResource(fetcher));
29
+ const [state, setState] = useState(res.peek());
30
+
31
+ useEffect(() => {
32
+ const unsubscribe = res.subscribe(setState);
33
+ return unsubscribe;
34
+ }, [res]);
35
+
36
+ return {
37
+ ...state,
38
+ refetch: res.refetch,
39
+ mutate: res.mutate,
40
+ };
41
+ }
42
+
43
+ // useStore - Subscribe to store changes
44
+ export function useStore<T extends object>(store: T): T {
45
+ const [, _forceUpdate] = useState({});
46
+
47
+ useEffect(() => {
48
+ // In real implementation, subscribe to store changes
49
+ return () => {};
50
+ }, [store]);
51
+
52
+ return store;
53
+ }
54
+
55
+ // useIsomorphicLayoutEffect - Works on server and client
56
+ export const useIsomorphicLayoutEffect =
57
+ typeof window !== 'undefined' ? useEffect : () => {};
58
+
59
+ // useEventListener - Attach event listeners
60
+ export function useEventListener(
61
+ eventName: string,
62
+ handler: (event: Event) => void,
63
+ element: HTMLElement | Window = window
64
+ ) {
65
+ const savedHandler = useRef(handler);
66
+
67
+ useEffect(() => {
68
+ savedHandler.current = handler;
69
+ }, [handler]);
70
+
71
+ useEffect(() => {
72
+ const isSupported = element && element.addEventListener;
73
+ if (!isSupported) return;
74
+
75
+ const eventListener = (event: Event) => savedHandler.current(event);
76
+ element.addEventListener(eventName, eventListener);
77
+
78
+ return () => {
79
+ element.removeEventListener(eventName, eventListener);
80
+ };
81
+ }, [eventName, element]);
82
+ }
83
+
84
+ // useLocalStorage - Persist state to localStorage
85
+ export function useLocalStorage<T>(key: string, initialValue: T): [T, (value: T) => void] {
86
+ const [storedValue, setStoredValue] = useState<T>(() => {
87
+ if (typeof window === 'undefined') return initialValue;
88
+ try {
89
+ const item = window.localStorage.getItem(key);
90
+ return item ? JSON.parse(item) : initialValue;
91
+ } catch {
92
+ return initialValue;
93
+ }
94
+ });
95
+
96
+ const setValue = useCallback((value: T) => {
97
+ try {
98
+ setStoredValue(value);
99
+ if (typeof window !== 'undefined') {
100
+ window.localStorage.setItem(key, JSON.stringify(value));
101
+ }
102
+ } catch (error) {
103
+ console.error('Error saving to localStorage:', error);
104
+ }
105
+ }, [key]);
106
+
107
+ return [storedValue, setValue];
108
+ }
109
+
110
+ // useDebounce - Debounce a value
111
+ export function useDebounce<T>(value: T, delay: number): T {
112
+ const [debouncedValue, setDebouncedValue] = useState(value);
113
+
114
+ useEffect(() => {
115
+ const timer = setTimeout(() => {
116
+ setDebouncedValue(value);
117
+ }, delay);
118
+
119
+ return () => clearTimeout(timer);
120
+ }, [value, delay]);
121
+
122
+ return debouncedValue;
123
+ }
124
+
125
+ // useThrottle - Throttle a function
126
+ export function useThrottle<T extends (...args: unknown[]) => unknown>(
127
+ fn: T,
128
+ limit: number
129
+ ): T {
130
+ const lastRun = useRef<number>(0);
131
+
132
+ return useCallback(
133
+ (...args: Parameters<T>) => {
134
+ const now = Date.now();
135
+ if (now - lastRun.current >= limit) {
136
+ lastRun.current = now;
137
+ return fn(...args);
138
+ }
139
+ },
140
+ [fn, limit]
141
+ ) as T;
142
+ }
@@ -0,0 +1,59 @@
1
+ // Zylaris Core - The Universal Web Framework
2
+
3
+ // Re-export reactivity system
4
+ export {
5
+ signal,
6
+ computed,
7
+ resource,
8
+ createEffect,
9
+ batch,
10
+ createStore,
11
+ onMount,
12
+ onCleanup,
13
+ isStore,
14
+ } from '@zylaris/reactivity';
15
+
16
+ export type {
17
+ Signal,
18
+ Computed,
19
+ Resource,
20
+ ResourceState,
21
+ Store,
22
+ } from '@zylaris/reactivity';
23
+
24
+ // Export components
25
+ export {
26
+ Show,
27
+ For,
28
+ Switch,
29
+ Match,
30
+ Suspense,
31
+ Dynamic,
32
+ Portal,
33
+ ErrorBoundary,
34
+ lazy,
35
+ } from './components.js';
36
+
37
+ // Export hooks
38
+ export {
39
+ useSignal,
40
+ useComputed,
41
+ useResource,
42
+ useStore,
43
+ useIsomorphicLayoutEffect,
44
+ useEventListener,
45
+ useLocalStorage,
46
+ useDebounce,
47
+ useThrottle,
48
+ } from './hooks.js';
49
+
50
+ // Export JSX runtime
51
+ export { jsx, jsxs, jsxDEV, Fragment, isSignal } from './jsx-runtime.js';
52
+ export type { JSXElement, JSXNode } from './jsx-runtime.js';
53
+
54
+ // Export config
55
+ export { defineConfig } from './config.js';
56
+ export type { ZylarisConfig } from './config.js';
57
+
58
+ // Version
59
+ export const version = '1.0.0';
@@ -0,0 +1,46 @@
1
+ // JSX Runtime for Zylaris
2
+ // Transforms JSX to DOM operations
3
+
4
+ import type { Signal } from '@zylaris/reactivity';
5
+
6
+ export type JSXElement = {
7
+ type: string | Function;
8
+ props: Record<string, unknown>;
9
+ key?: string | number;
10
+ };
11
+
12
+ export type JSXNode = JSXElement | string | number | null | undefined | Signal<unknown>;
13
+
14
+ export function jsx(
15
+ type: string | Function,
16
+ props: Record<string, unknown>,
17
+ key?: string | number
18
+ ): JSXElement {
19
+ return { type, props: props || {}, key };
20
+ }
21
+
22
+ export function jsxs(
23
+ type: string | Function,
24
+ props: Record<string, unknown>,
25
+ key?: string | number
26
+ ): JSXElement {
27
+ return jsx(type, props, key);
28
+ }
29
+
30
+ export function jsxDEV(
31
+ type: string | Function,
32
+ props: Record<string, unknown>,
33
+ key?: string | number,
34
+ _isStaticChildren?: boolean,
35
+ _source?: object,
36
+ _self?: object
37
+ ): JSXElement {
38
+ return jsx(type, props, key);
39
+ }
40
+
41
+ export const Fragment = Symbol('zylaris.fragment');
42
+
43
+ // Helper to check if value is a signal
44
+ export function isSignal<T>(value: unknown): value is Signal<T> {
45
+ return typeof value === 'function' && 'set' in (value as object);
46
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "."
8
+ },
9
+ "include": [
10
+ "src/**/*"
11
+ ],
12
+ "exclude": [
13
+ "dist",
14
+ "node_modules"
15
+ ]
16
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@zylaris/dev-server",
3
+ "version": "1.0.0",
4
+ "description": "Development server for Zylaris",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./jit": {
15
+ "types": "./dist/jit-middleware.d.ts",
16
+ "import": "./dist/jit-middleware.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "dev": "tsc --watch",
25
+ "typecheck": "tsc --noEmit",
26
+ "clean": "rm -rf dist"
27
+ },
28
+ "dependencies": {
29
+ "@zylaris/router": "workspace:*",
30
+ "@zylaris/compiler": "workspace:*",
31
+ "connect": "^3.7.0",
32
+ "http-proxy-middleware": "^2.0.6",
33
+ "mime-types": "^2.1.35",
34
+ "ws": "^8.16.0",
35
+ "chokidar": "^3.5.3",
36
+ "vite": "^5.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/connect": "^3.4.38",
40
+ "@types/mime-types": "^2.1.4",
41
+ "@types/node": "^20.0.0",
42
+ "@types/ws": "^8.5.10",
43
+ "typescript": "^5.3.3"
44
+ },
45
+ "keywords": [
46
+ "dev-server",
47
+ "hmr",
48
+ "zylaris"
49
+ ],
50
+ "license": "MIT"
51
+ }