1+ {
2+ "LiveAction Class" : {
3+ "prefix" : " liveaction" ,
4+ "body" : [
5+ " import { LiveAction } from '@/core/live'" ,
6+ " import { Action, State, Lifecycle, LiveComponent } from '@/core/decorators/LiveActionDecorators'" ,
7+ " " ,
8+ " interface ${1:ComponentName}Props {" ,
9+ " ${2:// Add your props here}" ,
10+ " }" ,
11+ " " ,
12+ " @LiveComponent('${1:ComponentName}Action')" ,
13+ " export class ${1:ComponentName}Action extends LiveAction {" ,
14+ " @State({ required: true, type: 'string' })" ,
15+ " ${3:exampleProperty}: string = '${4:default value}'" ,
16+ " " ,
17+ " getInitialState(props: ${1:ComponentName}Props) {" ,
18+ " return {" ,
19+ " ${3:exampleProperty}: props.${3:exampleProperty} || '${4:default value}'" ,
20+ " }" ,
21+ " }" ,
22+ " " ,
23+ " @Lifecycle('mount')" ,
24+ " mount() {" ,
25+ " ${5:// Add mount logic here}" ,
26+ " }" ,
27+ " " ,
28+ " @Action({ description: '${6:Action description}', emit: '${7:action-completed}' })" ,
29+ " ${8:exampleAction}() {" ,
30+ " ${9:// Add your action logic here}" ,
31+ " return { success: true, message: '${8:exampleAction} completed' }" ,
32+ " }" ,
33+ " }"
34+ ],
35+ "description" : " Create a complete LiveAction component with decorators"
36+ },
37+
38+ "LiveAction Simple" : {
39+ "prefix" : " liveaction-simple" ,
40+ "body" : [
41+ " import { LiveAction, SimpleAction, SimpleLifecycle, SimpleValidate, Validators, ValidationMessages } from '@/core'" ,
42+ " " ,
43+ " export class ${1:ComponentName}Action extends LiveAction {" ,
44+ " ${2:property}: ${3:string} = '${4:default}'" ,
45+ " " ,
46+ " getInitialState(props: any) {" ,
47+ " return {" ,
48+ " ${2:property}: '${4:default}'" ,
49+ " }" ,
50+ " }" ,
51+ " " ,
52+ " @SimpleLifecycle('mount')" ,
53+ " mount() {" ,
54+ " // Mount logic here" ,
55+ " }" ,
56+ " " ,
57+ " @SimpleAction('${6:Action description}')" ,
58+ " @SimpleValidate(Validators.required, ValidationMessages.required)" ,
59+ " ${5:exampleAction}(${7:param}: ${8:string}) {" ,
60+ " // Action logic here" ,
61+ " return { success: true }" ,
62+ " }" ,
63+ " }" ,
64+ " " ,
65+ " LiveAction.add(${1:ComponentName}Action)"
66+ ],
67+ "description" : " Create a simple LiveAction component with decorators"
68+ },
69+
70+ "LiveAction Method" : {
71+ "prefix" : " livemethod" ,
72+ "body" : [
73+ " @Action({ description: '${1:Method description}', emit: '${2:event-name}' })" ,
74+ " ${3:methodName}(${4:params}) {" ,
75+ " ${5:// Add your logic here}" ,
76+ " " ,
77+ " return { success: true, message: '${3:methodName} completed' }" ,
78+ " }"
79+ ],
80+ "description" : " Add a decorated action method to LiveAction"
81+ },
82+
83+ "LiveAction State Property" : {
84+ "prefix" : " livestate" ,
85+ "body" : [
86+ " @State({ required: ${1:true}, type: '${2:string}', default: '${3:defaultValue}' })" ,
87+ " ${4:propertyName}: ${2:string} = '${3:defaultValue}'"
88+ ],
89+ "description" : " Add a validated state property"
90+ },
91+
92+ "LiveAction Validation" : {
93+ "prefix" : " livevalidate" ,
94+ "body" : [
95+ " @Validate(" ,
96+ " ValidationRules.required('${1:Property is required}')," ,
97+ " ValidationRules.${2:minLength}(${3:3}, '${4:Validation message}')," ,
98+ " ValidationRules.custom(" ,
99+ " (value) => ${5:/* custom validation */}," ,
100+ " '${6:Custom validation message}'" ,
101+ " )" ,
102+ " )" ,
103+ " ${7:propertyName}: ${8:string}"
104+ ],
105+ "description" : " Add validation decorators to a property or method"
106+ },
107+
108+ "LiveAction Lifecycle" : {
109+ "prefix" : " livelifecycle" ,
110+ "body" : [
111+ " @Lifecycle('${1|mount,unmount,update|}')" ,
112+ " ${1:mount}() {" ,
113+ " ${2:// Add lifecycle logic here}" ,
114+ " }"
115+ ],
116+ "description" : " Add a lifecycle method"
117+ },
118+
119+ "LiveAction Builder" : {
120+ "prefix" : " livebuilder" ,
121+ "body" : [
122+ " import { createLiveAction } from '@/core/helpers/LiveActionHelpers'" ,
123+ " " ,
124+ " const ${1:ComponentName}Action = createLiveAction('${1:ComponentName}Action')" ,
125+ " .withProps<{${2:// Props interface}}>(" ,
126+ " .withInitialState((props) => ({" ,
127+ " ${3:property}: props.${3:property} || '${4:default}'" ,
128+ " }))" ,
129+ " .withAction('${5:actionName}', function(${6:params}) {" ,
130+ " ${7:// Action logic}" ,
131+ " return { success: true }" ,
132+ " })" ,
133+ " .withLifecycle('mount', function() {" ,
134+ " ${8:// Mount logic}" ,
135+ " })" ,
136+ " .build()" ,
137+ " " ,
138+ " export default ${1:ComponentName}Action"
139+ ],
140+ "description" : " Create LiveAction using the builder pattern"
141+ },
142+
143+ "React Live Component" : {
144+ "prefix" : " livecomponent" ,
145+ "body" : [
146+ " import { useLive } from '@/hooks/useLive'" ,
147+ " " ,
148+ " interface ${1:ComponentName}Props {" ,
149+ " componentId?: string" ,
150+ " ${2:// Add your props here}" ,
151+ " }" ,
152+ " " ,
153+ " export function ${1:ComponentName}({" ,
154+ " componentId," ,
155+ " ${3:...props}" ,
156+ " }: ${1:ComponentName}Props) {" ,
157+ " const {" ,
158+ " state," ,
159+ " loading," ,
160+ " error," ,
161+ " connected," ,
162+ " callMethod" ,
163+ " } = useLive({" ,
164+ " name: '${1:ComponentName}Action'," ,
165+ " props: ${3:props}," ,
166+ " componentId" ,
167+ " })" ,
168+ " " ,
169+ " return (" ,
170+ " <div>" ,
171+ " <h3>${1:ComponentName}</h3>" ,
172+ " <div>Status: {connected ? '🟢 Live' : '🔴 Offline'}</div>" ,
173+ " " ,
174+ " <button " ,
175+ " onClick={() => callMethod('${4:methodName}')}" ,
176+ " disabled={loading}" ,
177+ " >" ,
178+ " {loading ? 'Loading...' : '${5:Button Text}'}" ,
179+ " </button>" ,
180+ " " ,
181+ " {error && <div style={{color: 'red'}}>{error}</div>}" ,
182+ " </div>" ,
183+ " )" ,
184+ " }"
185+ ],
186+ "description" : " Create a React component that uses LiveAction"
187+ },
188+
189+ "Validation Rules" : {
190+ "prefix" : " validationrules" ,
191+ "body" : [
192+ " import { ValidationRules } from '@/core/validators/LiveActionValidators'" ,
193+ " " ,
194+ " const ${1:validationRules} = [" ,
195+ " ValidationRules.required('${2:Field is required}')," ,
196+ " ValidationRules.${3:minLength}(${4:3}, '${5:Minimum 3 characters}')," ,
197+ " ValidationRules.${6:pattern}(/${7:regex}/, '${8:Invalid format}')," ,
198+ " ValidationRules.custom(" ,
199+ " (value) => ${9:/* validation logic */}," ,
200+ " '${10:Custom validation message}'" ,
201+ " )" ,
202+ " ]"
203+ ],
204+ "description" : " Create validation rules array"
205+ },
206+
207+ "Simple Action Method" : {
208+ "prefix" : " simpleaction" ,
209+ "body" : [
210+ " @SimpleAction('${1:Method description}')" ,
211+ " @SimpleValidate(Validators.${2:required}, ValidationMessages.${2:required})" ,
212+ " ${3:methodName}(${4:param}: ${5:string}) {" ,
213+ " ${6:// Action logic here}" ,
214+ " return { success: true }" ,
215+ " }"
216+ ],
217+ "description" : " Add a simple action method with validation"
218+ },
219+
220+ "Simple Lifecycle" : {
221+ "prefix" : " simplelifecycle" ,
222+ "body" : [
223+ " @SimpleLifecycle('${1|mount,unmount|}')" ,
224+ " ${1:mount}() {" ,
225+ " ${2:// Lifecycle logic here}" ,
226+ " }"
227+ ],
228+ "description" : " Add a simple lifecycle method"
229+ },
230+
231+ "Simple Validate" : {
232+ "prefix" : " simplevalidate" ,
233+ "body" : [
234+ " @SimpleValidate(" ,
235+ " Validators.${1:safeString}(${2:2}, ${3:50})," ,
236+ " ValidationMessages.${1:safeString}(${2:2}, ${3:50})" ,
237+ " )"
238+ ],
239+ "description" : " Add simple validation to a method"
240+ },
241+
242+ "CLI Component Generation" : {
243+ "prefix" : " makeLive" ,
244+ "body" : [
245+ " bun run make:component ${1:ComponentName} --props --lifecycle --events --controls --method=${2:methodName}"
246+ ],
247+ "description" : " CLI command to generate LiveAction component"
248+ }
249+ }
0 commit comments