@stacksjs/stx 0.0.9 → 0.1.6

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/README.md +69 -21
  2. package/dist/a11y.d.ts +40 -0
  3. package/dist/analyzer.d.ts +64 -0
  4. package/dist/animation.d.ts +64 -0
  5. package/dist/assets.d.ts +19 -0
  6. package/dist/auth.d.ts +11 -0
  7. package/dist/bin/cli.js +2821 -154
  8. package/dist/caching.d.ts +18 -6
  9. package/dist/chunk-2ndtnc0t.js +9822 -0
  10. package/dist/{chunk-ywm063e4.js → chunk-e11q5a3p.js} +2 -2
  11. package/dist/chunk-vsbm352h.js +670 -0
  12. package/dist/client.d.ts +19 -35
  13. package/dist/components.d.ts +6 -0
  14. package/dist/conditionals.d.ts +17 -1
  15. package/dist/config.d.ts +6 -2
  16. package/dist/csrf.d.ts +28 -0
  17. package/dist/custom-directives.d.ts +5 -6
  18. package/dist/dev-server.d.ts +21 -0
  19. package/dist/docs.d.ts +39 -3
  20. package/dist/error-handling.d.ts +101 -0
  21. package/dist/expressions.d.ts +43 -4
  22. package/dist/formatter.d.ts +16 -0
  23. package/dist/forms.d.ts +15 -25
  24. package/dist/i18n.d.ts +17 -20
  25. package/dist/includes.d.ts +21 -18
  26. package/dist/index.d.ts +30 -24
  27. package/dist/init.d.ts +9 -0
  28. package/dist/js-ts.d.ts +10 -0
  29. package/dist/loops.d.ts +4 -3
  30. package/dist/markdown.d.ts +8 -0
  31. package/dist/method-spoofing.d.ts +13 -0
  32. package/dist/middleware.d.ts +9 -1
  33. package/dist/performance-utils.d.ts +58 -0
  34. package/dist/plugin.d.ts +2 -0
  35. package/dist/process.d.ts +9 -7
  36. package/dist/release.d.ts +1 -0
  37. package/dist/routes.d.ts +36 -0
  38. package/dist/safe-evaluator.d.ts +16 -0
  39. package/dist/seo.d.ts +33 -0
  40. package/dist/serve.d.ts +35 -0
  41. package/dist/src/index.js +2893 -135
  42. package/dist/streaming.d.ts +30 -14
  43. package/dist/types.d.ts +214 -48
  44. package/dist/utils.d.ts +21 -3
  45. package/dist/view-composers.d.ts +26 -0
  46. package/dist/web-components.d.ts +7 -14
  47. package/package.json +18 -9
  48. package/dist/chunk-04bqmpzb.js +0 -7069
  49. package/dist/chunk-8ehp5m3y.js +0 -4279
  50. package/dist/chunk-9ynf73q9.js +0 -2502
@@ -1,14 +1,30 @@
1
- import type { CustomDirective, StreamRenderer, StreamingConfig, StxOptions } from './types';
2
-
3
- declare const defaultStreamingConfig: StreamingConfig;
4
- export declare function streamTemplate(templatePath: string,
5
- data: Record<string, any> = {},
6
- options: StxOptions = {},): Promise<ReadableStream<string>>;
7
- export declare function createStreamRenderer(templatePath: string,
8
- options: StxOptions = {},): Promise<StreamRenderer>;
9
- export declare const islandDirective: CustomDirective;
10
- export declare function registerStreamingDirectives(options: StxOptions = {}): CustomDirective[];
11
- export declare function processSectionDirectives(content: string,
12
- context: Record<string, any>,
13
- filePath: string,
14
- options: StxOptions = {},): Promise<string>;
1
+ import type { CustomDirective, StreamRenderer, StxOptions } from './types';
2
+ /**
3
+ * Stream a template with data
4
+ * @param templatePath Path to the template
5
+ * @param data Data to render with the template
6
+ * @param options stx options
7
+ */
8
+ export declare function streamTemplate(templatePath: string, data?: Record<string, any>, options?: StxOptions): Promise<ReadableStream<string>>;
9
+ /**
10
+ * Create a stream renderer for progressive loading
11
+ * @param templatePath Path to the template
12
+ * @param options stx options
13
+ */
14
+ export declare function createStreamRenderer(templatePath: string, options?: StxOptions): Promise<StreamRenderer>;
15
+ /**
16
+ * Register streaming and hydration directives
17
+ */
18
+ export declare function registerStreamingDirectives(options?: StxOptions): CustomDirective[];
19
+ /**
20
+ * Process section directives
21
+ * @param content Template content
22
+ * @param context Data context
23
+ * @param filePath Template file path
24
+ * @param _options stx options
25
+ */
26
+ export declare function processSectionDirectives(content: string, context: Record<string, any>, filePath: string, _options?: StxOptions): Promise<string>;
27
+ /**
28
+ * Custom directive for creating islands (for partial hydration)
29
+ */
30
+ export declare const islandDirective: CustomDirective;
package/dist/types.d.ts CHANGED
@@ -1,32 +1,25 @@
1
- export declare type CustomDirectiveHandler = (
2
- content: string,
3
- params: string[],
4
- context: Record<string, any>,
5
- filePath: string
6
- ) => string | Promise<string>
7
-
8
- export interface CustomDirective {
1
+ /**
2
+ * Custom directive definition
3
+ */
4
+ export declare interface CustomDirective {
9
5
  name: string
10
6
  handler: CustomDirectiveHandler
11
7
  hasEndTag?: boolean
12
8
  description?: string
13
9
  }
14
-
15
- export type MiddlewareHandler = (
16
- template: string,
17
- context: Record<string, any>,
18
- filePath: string,
19
- options: StxOptions
20
- ) => string | Promise<string>
21
-
22
- export interface Middleware {
10
+ /**
11
+ * Middleware definition
12
+ */
13
+ export declare interface Middleware {
23
14
  name: string
24
15
  handler: MiddlewareHandler
25
16
  timing: 'before' | 'after'
26
17
  description?: string
27
18
  }
28
-
29
- export interface I18nConfig {
19
+ /**
20
+ * Internationalization (i18n) configuration
21
+ */
22
+ export declare interface I18nConfig {
30
23
  defaultLocale: string
31
24
  locale: string
32
25
  translationsDir: string
@@ -34,8 +27,10 @@ export interface I18nConfig {
34
27
  fallbackToKey: boolean
35
28
  cache: boolean
36
29
  }
37
-
38
- export interface WebComponent {
30
+ /**
31
+ * Web component definition
32
+ */
33
+ export declare interface WebComponent {
39
34
  name: string
40
35
  tag: string
41
36
  file: string
@@ -46,24 +41,28 @@ export interface WebComponent {
46
41
  attributes?: string[]
47
42
  description?: string
48
43
  }
49
-
50
- export interface WebComponentConfig {
44
+ /**
45
+ * Web components configuration
46
+ */
47
+ export declare interface WebComponentConfig {
51
48
  enabled: boolean
52
49
  outputDir: string
53
50
  components: WebComponent[]
54
51
  }
55
-
56
- export type DocFormat = 'markdown' | 'html' | 'json'
57
-
58
- export interface ComponentPropDoc {
52
+ /**
53
+ * Component property documentation
54
+ */
55
+ export declare interface ComponentPropDoc {
59
56
  name: string
60
57
  type?: string
61
58
  required?: boolean
62
59
  default?: string
63
60
  description?: string
64
61
  }
65
-
66
- export interface ComponentDoc {
62
+ /**
63
+ * Component documentation
64
+ */
65
+ export declare interface ComponentDoc {
67
66
  name: string
68
67
  path: string
69
68
  description?: string
@@ -72,23 +71,29 @@ export interface ComponentDoc {
72
71
  isWebComponent?: boolean
73
72
  tag?: string
74
73
  }
75
-
76
- export interface TemplateDoc {
74
+ /**
75
+ * Template documentation
76
+ */
77
+ export declare interface TemplateDoc {
77
78
  name: string
78
79
  path: string
79
80
  description?: string
80
81
  components?: string[]
81
82
  directives?: string[]
82
83
  }
83
-
84
- export interface DirectiveDoc {
84
+ /**
85
+ * Directive documentation
86
+ */
87
+ export declare interface DirectiveDoc {
85
88
  name: string
86
89
  description?: string
87
90
  hasEndTag: boolean
88
91
  example?: string
89
92
  }
90
-
91
- export interface DocGeneratorConfig {
93
+ /**
94
+ * Documentation generator configuration
95
+ */
96
+ export declare interface DocGeneratorConfig {
92
97
  enabled: boolean
93
98
  outputDir: string
94
99
  format: DocFormat
@@ -98,45 +103,145 @@ export interface DocGeneratorConfig {
98
103
  extraContent?: string
99
104
  template?: string
100
105
  }
101
-
102
- export interface StreamingConfig {
106
+ /**
107
+ * Streaming configuration
108
+ */
109
+ export declare interface StreamingConfig {
103
110
  enabled: boolean
104
111
  bufferSize: number
105
112
  strategy: 'auto' | 'manual' | 'sections'
106
113
  timeout: number
107
114
  }
108
-
109
- export interface StreamRenderer {
115
+ /**
116
+ * Stream renderer for progressive loading
117
+ */
118
+ export declare interface StreamRenderer {
110
119
  renderShell: (data?: Record<string, any>) => Promise<string>
111
120
  renderSection: (section: string, data?: Record<string, any>) => Promise<string>
112
121
  getSections: () => string[]
113
122
  getTemplate: () => string
114
123
  }
115
-
116
- export interface HydrationConfig {
124
+ /**
125
+ * Hydration configuration
126
+ */
127
+ export declare interface HydrationConfig {
117
128
  enabled: boolean
118
129
  mode: 'progressive' | 'islands'
119
130
  clientEntry: string
120
131
  autoMarkers: boolean
121
132
  preload: 'none' | 'eager' | 'lazy'
122
133
  }
123
-
124
- export interface Island {
134
+ /**
135
+ * Island definition for partial hydration
136
+ */
137
+ export declare interface Island {
125
138
  id: string
126
139
  component: string
127
140
  props?: Record<string, any>
128
141
  priority?: 'eager' | 'lazy'
129
142
  shadowDOM?: boolean
130
143
  }
131
-
132
- export interface StxConfig {
144
+ /**
145
+ * Accessibility configuration
146
+ */
147
+ export declare interface A11yConfig {
148
+ enabled: boolean
149
+ addSrOnlyStyles: boolean
150
+ level: 'AA' | 'AAA'
151
+ ignoreChecks?: string[]
152
+ autoFix: boolean
153
+ }
154
+ /**
155
+ * SEO OpenGraph configuration
156
+ */
157
+ export declare interface OpenGraphConfig {
158
+ type?: string
159
+ title?: string
160
+ description?: string
161
+ url?: string
162
+ image?: string
163
+ imageAlt?: string
164
+ imageWidth?: number
165
+ imageHeight?: number
166
+ siteName?: string
167
+ }
168
+ /**
169
+ * SEO Twitter card configuration
170
+ */
171
+ export declare interface TwitterConfig {
172
+ card?: 'summary' | 'summary_large_image' | 'app' | 'player'
173
+ title?: string
174
+ description?: string
175
+ image?: string
176
+ site?: string
177
+ creator?: string
178
+ }
179
+ /**
180
+ * SEO configuration
181
+ */
182
+ export declare interface SeoConfig {
183
+ title?: string
184
+ description?: string
185
+ keywords?: string[] | string
186
+ robots?: string
187
+ canonical?: string
188
+ openGraph?: OpenGraphConfig
189
+ twitter?: TwitterConfig
190
+ structuredData?: Record<string, any>
191
+ }
192
+ /**
193
+ * SEO features configuration
194
+ */
195
+ export declare interface SeoFeatureConfig {
196
+ enabled: boolean
197
+ defaultConfig?: SeoConfig
198
+ socialPreview?: boolean
199
+ defaultImage?: string
200
+ }
201
+ /**
202
+ * Animation configuration
203
+ */
204
+ export declare interface AnimationConfig {
205
+ enabled: boolean
206
+ defaultDuration: number
207
+ defaultEase: string
208
+ respectMotionPreferences: boolean
209
+ staggerDelay: number
210
+ }
211
+ /**
212
+ * Syntax highlighting configuration
213
+ */
214
+ export declare interface SyntaxHighlightingConfig {
215
+ enabled: boolean
216
+ serverSide: boolean
217
+ defaultTheme: SyntaxHighlightTheme
218
+ highlightUnknownLanguages: boolean
219
+ additionalThemes?: SyntaxHighlightTheme[]
220
+ }
221
+ /**
222
+ * Markdown configuration
223
+ */
224
+ export declare interface MarkdownConfig {
225
+ enabled: boolean
226
+ dir?: string
227
+ syntaxHighlighting?: Partial<SyntaxHighlightingConfig>
228
+ }
229
+ /**
230
+ * stx configuration options
231
+ */
232
+ export declare interface StxConfig {
233
+ templatesDir?: string
234
+ defaultTitle?: string
235
+ defaultDescription?: string
236
+ defaultImage?: string
237
+ cache?: boolean
238
+ cacheDir?: string
239
+ cacheVersion?: string
133
240
  enabled: boolean
134
241
  partialsDir: string
135
242
  componentsDir: string
136
243
  debug: boolean
137
- cache: boolean
138
244
  cachePath: string
139
- cacheVersion: string
140
245
  customDirectives?: CustomDirective[]
141
246
  middleware?: Middleware[]
142
247
  i18n?: Partial<I18nConfig>
@@ -144,6 +249,67 @@ export interface StxConfig {
144
249
  docs?: Partial<DocGeneratorConfig>
145
250
  streaming?: Partial<StreamingConfig>
146
251
  hydration?: Partial<HydrationConfig>
252
+ a11y?: Partial<A11yConfig>
253
+ seo?: Partial<SeoFeatureConfig>
254
+ animation?: Partial<AnimationConfig>
255
+ skipDefaultSeoTags?: boolean
256
+ markdown?: Partial<MarkdownConfig>
147
257
  }
148
-
258
+ /**
259
+ * stx Config
260
+ */
261
+ /**
262
+ * Custom directive handler function
263
+ */
264
+ export type CustomDirectiveHandler = (
265
+ content: string,
266
+ params: string[],
267
+ context: Record<string, any>,
268
+ filePath: string
269
+ ) => string | Promise<string>
270
+ /**
271
+ * Middleware handler function
272
+ */
273
+ export type MiddlewareHandler = (
274
+ template: string,
275
+ context: Record<string, any>,
276
+ filePath: string,
277
+ options: StxOptions
278
+ ) => string | Promise<string>
279
+ /**
280
+ * Documentation format options
281
+ */
282
+ export type DocFormat = 'markdown' | 'html' | 'json'
283
+ /**
284
+ * Available syntax highlighting themes
285
+ */
286
+ export type SyntaxHighlightTheme = | 'css-variables'
287
+ | 'dark-plus'
288
+ | 'dracula'
289
+ | 'dracula-soft'
290
+ | 'github-dark'
291
+ | 'github-dark-dimmed'
292
+ | 'github-light'
293
+ | 'hc_light'
294
+ | 'light-plus'
295
+ | 'material-theme'
296
+ | 'material-theme-darker'
297
+ | 'material-theme-lighter'
298
+ | 'material-theme-ocean'
299
+ | 'material-theme-palenight'
300
+ | 'min-dark'
301
+ | 'min-light'
302
+ | 'monokai'
303
+ | 'nord'
304
+ | 'one-dark-pro'
305
+ | 'poimandres'
306
+ | 'rose-pine'
307
+ | 'rose-pine-dawn'
308
+ | 'rose-pine-moon'
309
+ | 'slack-dark'
310
+ | 'slack-ochin'
311
+ | 'solarized-dark'
312
+ | 'solarized-light'
313
+ | 'vitesse-dark'
314
+ | 'vitesse-light'
149
315
  export type StxOptions = Partial<StxConfig>
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,27 @@
1
1
  import type { StxOptions } from './types';
2
-
3
- declare const componentsCache: (...args: any[]) => unknown;
2
+ /**
3
+ * Shared function to render a component with props and slot content
4
+ */
4
5
  export declare function renderComponent(componentPath: string, props: Record<string, any>, slotContent: string, componentsDir: string, parentContext: Record<string, any>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>): Promise<string>;
6
+ /**
7
+ * Check if a file exists
8
+ */
5
9
  export declare function fileExists(filePath: string): Promise<boolean>;
10
+ /**
11
+ * Extract variables from script content
12
+ */
6
13
  export declare function extractVariables(scriptContent: string, context: Record<string, any>, filePath: string): Promise<void>;
14
+ /**
15
+ * Resolve a template path based on the current file path
16
+ */
7
17
  export declare function resolveTemplatePath(templatePath: string, currentFilePath: string, options: StxOptions, dependencies?: Set<string>): Promise<string | null>;
8
- export declare function getSourceLineInfo(template: string, errorPosition?: number, errorPattern?: string): void;
18
+ /**
19
+ * Get source line number from an error in a template
20
+ * This helps provide more precise error messages
21
+ * @param template The full template string
22
+ * @param errorPosition The character position of the error (if available)
23
+ * @param errorPattern The pattern to locate in the template (fallback if position not available)
24
+ * @returns Line number and context information
25
+ */
26
+ export declare function getSourceLineInfo(template: string, errorPosition?: number, errorPattern?: string): { lineNumber: number, lineContent: string, context: string };
9
27
  export declare function createDetailedErrorMessage(errorType: string, errorMessage: string, filePath: string, template: string, errorPosition?: number, errorPattern?: string): string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Register a composer for a specific view
3
+ */
4
+ export declare function composer(view: string, callback: ViewComposerCallback): void;
5
+ /**
6
+ * Register a composer for all views matching a pattern
7
+ */
8
+ export declare function composerPattern(pattern: string | RegExp, callback: ViewComposerCallback): void;
9
+ /**
10
+ * Execute all composers for a given view
11
+ */
12
+ export declare function runComposers(filePath: string, context: Record<string, any>): Promise<void>;
13
+ /**
14
+ * Clear all registered composers
15
+ * (Mainly for testing purposes)
16
+ */
17
+ export declare function clearComposers(): void;
18
+ /**
19
+ * View Composers functionality for stx templating
20
+ * Similar to Laravel's View Composers, this allows registering
21
+ * callbacks that should run whenever a specific view is rendered.
22
+ */
23
+ /**
24
+ * Type definition for view composer callback function
25
+ */
26
+ export type ViewComposerCallback = (context: Record<string, any>, filePath: string) => void | Promise<void>
@@ -1,16 +1,9 @@
1
- import type { StxOptions, WebComponent } from './types';
2
-
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Builds web components from stx components
4
+ */
3
5
  export declare function buildWebComponents(options: StxOptions, dependencies: Set<string>): Promise<string[]>;
4
- declare function buildWebComponent(component: WebComponent, options: StxOptions, dependencies: Set<string>): Promise<string | null>;
5
- declare interface WebComponentCodeOptions {
6
- name: string
7
- tag: string
8
- baseElement?: string
9
- source: string
10
- shadowDOM: boolean
11
- template: boolean
12
- styleSource?: string
13
- attributes?: string[]
14
- }
15
- declare function generateWebComponentCode(options: WebComponentCodeOptions): string;
6
+ /**
7
+ * Directive handler for embedding web components in templates
8
+ */
16
9
  export declare function webComponentDirectiveHandler(content: string, params: string[], context: Record<string, any>, _filePath: string): string;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.0.9",
5
- "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
4
+ "version": "0.1.6",
5
+ "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/stacksjs/stx#readme",
@@ -26,13 +26,13 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "types": "./dist/index.d.ts",
29
- "import": "./dist/index.js"
29
+ "import": "./dist/src/index.js"
30
30
  },
31
31
  "./*": {
32
32
  "import": "./dist/*"
33
33
  }
34
34
  },
35
- "module": "./dist/index.js",
35
+ "module": "./dist/src/index.js",
36
36
  "types": "./dist/index.d.ts",
37
37
  "bin": {
38
38
  "stx": "./dist/bin/cli.js"
@@ -43,7 +43,9 @@
43
43
  "dist"
44
44
  ],
45
45
  "scripts": {
46
- "build": "bun --bun build.ts",
46
+ "build": "bun run build:css && bun --bun build.ts",
47
+ "build:css": "bun ./scripts/build-css.ts",
48
+ "css:watch": "bun ./scripts/watch-css.ts",
47
49
  "compile": "bun build ./bin/cli.ts --compile --minify --outfile ./bin/stx",
48
50
  "compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64",
49
51
  "compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile ./bin/stx-linux-x64",
@@ -62,13 +64,20 @@
62
64
  "lint:fix": "bunx eslint . --fix",
63
65
  "fresh": "bunx rimraf node_modules/ bun.lock && bun i",
64
66
  "changelog": "bunx changelogen --output CHANGELOG.md",
65
- "prepublishOnly": "bun run build && bun run compile:all",
67
+ "prepublishOnly": "bun run build && bun ./scripts/update-git-hash.ts && bun run compile:all && bun run zip:all",
66
68
  "release": "bun run changelog && bunx bumpp package.json --all",
67
- "test": "bun test",
69
+ "test": "bun test --preload ./happy-dom.ts",
70
+ "test:watch": "bun test --watch --preload ./happy-dom.ts",
71
+ "test:coverage": "bun test --coverage --preload ./happy-dom.ts",
68
72
  "typecheck": "bun tsc --noEmit"
69
73
  },
70
74
  "dependencies": {
71
- "marked": "^15.0.11",
72
- "yaml": "^2.7.1"
75
+ "@stacksjs/clapp": "^0.2.0",
76
+ "@stacksjs/headwind": "^0.1.3",
77
+ "@stacksjs/markdown": "0.0.1",
78
+ "@stacksjs/sanitizer": "0.0.1",
79
+ "bun-plugin-stx": "0.0.10",
80
+ "bunfig": "^0.15.0",
81
+ "ts-syntax-highlighter": "^0.1.0"
73
82
  }
74
83
  }