locadex 0.1.2 → 0.1.3

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 (71) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +14 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/fixErrors.d.ts +4 -0
  7. package/dist/commands/fixErrors.d.ts.map +1 -0
  8. package/dist/commands/fixErrors.js +41 -0
  9. package/dist/commands/fixErrors.js.map +1 -0
  10. package/dist/logging/logger.d.ts.map +1 -1
  11. package/dist/logging/logger.js.map +1 -1
  12. package/dist/mcp/getGuide.d.ts.map +1 -1
  13. package/dist/mcp/getGuide.js +2 -1
  14. package/dist/mcp/getGuide.js.map +1 -1
  15. package/dist/mcp/tools/guides.d.ts.map +1 -1
  16. package/dist/mcp/tools/guides.js +25 -55
  17. package/dist/mcp/tools/guides.js.map +1 -1
  18. package/dist/mcp.d.ts.map +1 -1
  19. package/dist/mcp.js +4 -2
  20. package/dist/mcp.js.map +1 -1
  21. package/dist/tasks/concurrency.d.ts.map +1 -1
  22. package/dist/tasks/concurrency.js +15 -23
  23. package/dist/tasks/concurrency.js.map +1 -1
  24. package/dist/tasks/fixErrors.d.ts +2 -0
  25. package/dist/tasks/fixErrors.d.ts.map +1 -0
  26. package/dist/tasks/fixErrors.js +82 -0
  27. package/dist/tasks/fixErrors.js.map +1 -0
  28. package/dist/tasks/i18n.d.ts.map +1 -1
  29. package/dist/tasks/i18n.js +25 -82
  30. package/dist/tasks/i18n.js.map +1 -1
  31. package/dist/tasks/setup.d.ts.map +1 -1
  32. package/dist/tasks/setup.js +21 -9
  33. package/dist/tasks/setup.js.map +1 -1
  34. package/dist/types/claude-sdk.d.ts +13 -9
  35. package/dist/types/claude-sdk.d.ts.map +1 -1
  36. package/dist/types/claude-sdk.js.map +1 -1
  37. package/dist/utils/claudeCode.d.ts +13 -1
  38. package/dist/utils/claudeCode.d.ts.map +1 -1
  39. package/dist/utils/claudeCode.js +173 -66
  40. package/dist/utils/claudeCode.js.map +1 -1
  41. package/dist/utils/errors.d.ts +20 -0
  42. package/dist/utils/errors.d.ts.map +1 -0
  43. package/dist/utils/errors.js +39 -0
  44. package/dist/utils/errors.js.map +1 -0
  45. package/dist/utils/packages/installPackage.d.ts +1 -2
  46. package/dist/utils/packages/installPackage.d.ts.map +1 -1
  47. package/dist/utils/packages/installPackage.js +19 -28
  48. package/dist/utils/packages/installPackage.js.map +1 -1
  49. package/dist/utils/shared.d.ts +1 -1
  50. package/dist/utils/shared.js +1 -1
  51. package/dist/utils/shared.js.map +1 -1
  52. package/dist/utils/shutdown.d.ts +1 -2
  53. package/dist/utils/shutdown.d.ts.map +1 -1
  54. package/dist/utils/shutdown.js +1 -5
  55. package/dist/utils/shutdown.js.map +1 -1
  56. package/guides/next/advanced/{ternary-operators.md → conditional-rendering.md} +97 -39
  57. package/guides/next/advanced/external-strings.md +346 -0
  58. package/guides/next/advanced/interpolated-strings.md +35 -115
  59. package/guides/next/advanced/{complicated-mapping-expressions.md → mapping-expressions.md} +58 -51
  60. package/guides/next/basic/branches.md +62 -45
  61. package/guides/next/basic/jsx.md +35 -33
  62. package/guides/next/basic/strings.md +43 -25
  63. package/guides/next/basic/variables.md +12 -12
  64. package/guides/next/important/functions.md +13 -11
  65. package/guides/next/{advanced → migration}/migrating.md +2 -3
  66. package/package.json +1 -1
  67. package/guides/next/advanced/var-outside-client-component.md +0 -446
  68. package/guides/next/advanced/var-outside-client-server-component.md +0 -550
  69. package/guides/next/advanced/var-outside-server-component.md +0 -545
  70. package/guides/next/basic/client-side-components.md +0 -221
  71. package/guides/next/basic/server-side-components.md +0 -165
@@ -1,550 +0,0 @@
1
- # Internationalization Pattern: Variables Used in Both Client and Server Components
2
-
3
- ## When to Apply This Pattern
4
-
5
- Apply this pattern when variables declared outside function scope contain strings needing internationalization AND are used by both client-side and server-side components.
6
-
7
- ## Rules
8
-
9
- 1. **Minimal footprint**: Minimize code changes by keeping internationalized content in the same file where it originated
10
- 2. **No file movement**: Avoid moving content between files unless absolutely necessary
11
- 3. **Only add the "use client" directive when ABSOLUTELY necessary**: Do not add "use server" directives
12
- 4. **Scope**: Only use this implementation for string translation (for HTML translation use ALWAYS `<T>`)
13
-
14
- Rule of thumb for implementation:
15
-
16
- - If data is being imported, wrap it in a function that takes `t()` as a parameter
17
- - If data is in the same file, you can either wrap it in a function or move it directly into the components that need it
18
-
19
- ## Implementation Patterns
20
-
21
- ### Pattern 1: Simple String Shared Between Client and Server
22
-
23
- **Scenario**: Constant string imported by both server and client components
24
-
25
- ```jsx title="content.ts"
26
- const SOME_STRING = 'Hello, World!';
27
- export default SOME_STRING;
28
- ```
29
-
30
- **Client component usage**:
31
-
32
- ```jsx title="client-component.tsx"
33
- import SOME_STRING from './content.ts';
34
- export default function clientComponent() {
35
- const [state, setState] = useState();
36
- return <>{SOME_STRING}</>;
37
- }
38
- ```
39
-
40
- **Server component usage**:
41
-
42
- ```jsx title="server-component.tsx"
43
- import SOME_STRING from './content.ts';
44
- export default function serverComponent() {
45
- return <>{SOME_STRING}</>;
46
- }
47
- ```
48
-
49
- **Solution**: Convert the variable to a function that accepts translation callback parameter to resolve translations dynamically.
50
-
51
- 1. Convert the constant into a function that takes `t()` as a parameter and begins with the word "get" (`SOME_STRING` -> `getSomeString()`)
52
- 2. Wrap all of the strings in the `t()` function.
53
- 3. import `useGT()` and `getGT()` to their respective files and add the `'use client'` directive for the client side components.
54
-
55
- ```tsx title="content.ts"
56
- import { InlineTranslationOptions } from 'gt-next/types';
57
- const getSomeString = (
58
- t: (string: string, options?: InlineTranslationOptions) => string
59
- ) => {
60
- return t('Hello, World!');
61
- };
62
- export default getSomeString;
63
- ```
64
-
65
- **Important**: Note that the translation function must be called directly on the string.
66
- It cannot be called on a variable, such as `t(SOME_STRING)`
67
-
68
- **Updated Components**: Pass respective `t()` function when calling `navMap()`
69
-
70
- **Updated Client component**:
71
-
72
- ```jsx title="client-component.tsx"
73
- 'use client';
74
- import SOME_STRING from './content.ts';
75
- import { useGT } from 'gt-next/client';
76
- export default function clientComponent() {
77
- const [state, setState] = useState();
78
- const t = useGT();
79
- return <>{SOME_STRING(t)}</>;
80
- }
81
- ```
82
-
83
- **Updated Server component**:
84
-
85
- ```jsx title="server-component.tsx"
86
- import SOME_STRING from './content.ts';
87
- import { getGT } from 'gt-next/server';
88
- export default async function serverComponent() {
89
- const t = await getGT();
90
- return <>{SOME_STRING(t)}</>;
91
- }
92
- ```
93
-
94
- **Common Pitfalls**
95
-
96
- - importing `useGT()` from `"gt-next"` instead of `"gt-next/client"`
97
- - importing `getGT()` from `"gt-next"` instead of `"gt-next/server"`
98
- - forgetting the `"use client"` directive in the client component file
99
- - adding a `"use server"` in the server component file
100
-
101
- ### Pattern 2: Complex Data Structure Shared Between Client and Server
102
-
103
- **Scenario**: Complex object exported to both client and server components
104
-
105
- ```jsx title="navMap.ts"
106
- const navMap = {
107
- name: "dashboard",
108
- url: "/dashboard",
109
- type: "page",
110
- },
111
- {
112
- name: "landing",
113
- url: "/landing",
114
- type: "page",
115
- },
116
- {
117
- name: "links",
118
- type: "divider",
119
- children: [
120
- {
121
- name: "blog",
122
- url: "/blog",
123
- },
124
- {
125
- name: "help",
126
- url: "/help",
127
- },
128
- ],
129
- };
130
- export default navMap;
131
- ```
132
-
133
- ```jsx title="client-component.tsx"
134
- import navMap from './navMap';
135
- import NavItem from './NavItem';
136
- export default function clientComponent() {
137
- return (
138
- <>
139
- {navMap.map((navItem) => (
140
- <NavItem item={navItem} />
141
- ))}
142
- </>
143
- );
144
- }
145
- ```
146
-
147
- ```jsx title="server-component.tsx"
148
- import navMap from './navMap';
149
- import NavItem from './NavItem';
150
- export default function serverComponent() {
151
- return (
152
- <>
153
- {navMap
154
- .filter(() => navItem.type === 'page')
155
- .map((navItem) => (
156
- <NavItem item={navItem} />
157
- ))}
158
- </>
159
- );
160
- }
161
- ```
162
-
163
- **Solution**: Create function that accepts translation callback parameter to resolve translations dynamically
164
-
165
- 1. Convert the constant into a function that takes `t()` as a parameter and begins with the word "get" (`navMap` -> `getNavMap()`)
166
- 2. Wrap all of the strings in the `t()` function.
167
- 3. import `useGT()` and `getGT()` to their respective files and add the `'use client'` directive for the client side components.
168
-
169
- ```jsx title="navMap.ts"
170
- import { InlineTranslationOptions } from "gt-next/types";
171
- const getNavMap = (t: (string: string, options?: InlineTranslationOptions) => string) => {
172
- return (
173
- {
174
- name: t("dashboard"),
175
- url: "/dashboard",
176
- type: "page",
177
- },
178
- {
179
- name: t("landing"),
180
- url: "/landing",
181
- type: "page",
182
- },
183
- {
184
- name: t("links"),
185
- type: "divider",
186
- children: [
187
- {
188
- name: t("blog"),
189
- url: "/blog",
190
- },
191
- {
192
- name: t("help"),
193
- url: "/help",
194
- },
195
- ],
196
- }
197
- );
198
- };
199
- export default getNavMap;
200
- ```
201
-
202
- **Updated Components**: Pass respective `t()` function when calling `navMap()`
203
-
204
- **Client component**:
205
-
206
- ```jsx title="client-component.tsx"
207
- 'use client';
208
- import getNavMap from './navMap';
209
- import NavItem from './NavItem';
210
- import { useGT } from 'gt-next/client';
211
- export default function clientComponent() {
212
- const t = useGT();
213
- const navMap = getNavMap(t);
214
- return (
215
- <>
216
- {navMap(t).map((navItem) => (
217
- <NavItem item={navItem} />
218
- ))}
219
- </>
220
- );
221
- }
222
- ```
223
-
224
- **Server component**:
225
-
226
- ```jsx title="server-component.tsx"
227
- import getNavMap from "./navMap";
228
- import NavItem from "./NavItem";
229
- import { getGT } from "gt-next/server";
230
- export default function serverComponent() {
231
- const t = await getGT();
232
- const navMap = getNavMap(t);
233
- return (
234
- <>
235
- {navMap
236
- .filter(() => navItem.type === "page")
237
- .map((navItem) => (
238
- <NavItem item={navItem} />
239
- ))}
240
- </>
241
- );
242
- }
243
- ```
244
-
245
- **Result**: Both client and server components access translations through functions that take the `t()` function as a parameter.
246
-
247
- ## IMPORTANT
248
-
249
- Be careful to only modify non-functional strings. Avoid modifying functional strings such as ids.
250
-
251
- ## Implementation Patterns: Functions
252
-
253
- ### Pattern 1: Function in Same File (Client and Server)
254
-
255
- **Scenario**: Function declared outside component scope within SAME FILE, used by both client and server components
256
-
257
- ```jsx
258
- function getErrorMessage(errorType) {
259
- switch (errorType) {
260
- case 'network':
261
- return 'Network connection failed';
262
- case 'auth':
263
- return 'Authentication failed';
264
- default:
265
- return 'Unknown error occurred';
266
- }
267
- }
268
-
269
- // Client component usage
270
- export function ClientExample() {
271
- const [error, setError] = useState('network');
272
- const message = getErrorMessage(error);
273
- return <div>{message}</div>;
274
- }
275
-
276
- // Server component usage
277
- export function ServerExample() {
278
- const error = 'network';
279
- const message = getErrorMessage(error);
280
- return <div>{message}</div>;
281
- }
282
- ```
283
-
284
- **Solution**: Pass `t()` function as parameter to the function
285
-
286
- 1. Modify the function to accept `t()` as a parameter
287
- 2. Use `t()` for string translations within the function
288
- 3. Add `'use client'` directive and import `useGT()` for client component
289
- 4. Import `getGT()` and make server component async
290
- 5. Pass `t()` when calling the function in both components
291
-
292
- ```jsx
293
- import { useGT } from 'gt-next/client';
294
- import { getGT } from 'gt-next/server';
295
-
296
- function getErrorMessage(errorType, t: (string: string, options?: InlineTranslationOptions) => string) {
297
- switch (errorType) {
298
- case 'network':
299
- return t('Network connection failed');
300
- case 'auth':
301
- return t('Authentication failed');
302
- default:
303
- return t('Unknown error occurred');
304
- }
305
- }
306
-
307
- // Client component usage
308
- 'use client';
309
- export function ClientExample() {
310
- const [error, setError] = useState('network');
311
- const t = useGT();
312
- const message = getErrorMessage(error, t);
313
- return <div>{message}</div>;
314
- }
315
-
316
- // Server component usage
317
- export async function ServerExample() {
318
- const error = 'network';
319
- const t = await getGT();
320
- const message = getErrorMessage(error, t);
321
- return <div>{message}</div>;
322
- }
323
- ```
324
-
325
- ### Pattern 2: Function in Different File (Client and Server)
326
-
327
- **Scenario**: Function exported from one file and imported by both client and server components (MULTIPLE FILES)
328
-
329
- ```jsx title="utils.ts"
330
- export function formatStatus(status) {
331
- switch (status) {
332
- case 'pending':
333
- return 'Pending approval';
334
- case 'approved':
335
- return 'Request approved';
336
- case 'rejected':
337
- return 'Request rejected';
338
- default:
339
- return 'Status unknown';
340
- }
341
- }
342
- ```
343
-
344
- ```jsx title="ClientComponent.tsx"
345
- import { formatStatus } from './utils';
346
-
347
- export function ClientComponent() {
348
- const [status, setStatus] = useState('pending');
349
- const statusText = formatStatus(status);
350
- return <div>{statusText}</div>;
351
- }
352
- ```
353
-
354
- ```jsx title="ServerComponent.tsx"
355
- import { formatStatus } from './utils';
356
-
357
- export function ServerComponent() {
358
- const status = 'pending';
359
- const statusText = formatStatus(status);
360
- return <div>{statusText}</div>;
361
- }
362
- ```
363
-
364
- **Solution**: Modify function to accept `t()` parameter and pass it from both component types
365
-
366
- 1. Modify the function in the utils file to accept `t()` as a parameter
367
- 2. Use `t()` for string translations within the function
368
- 3. Add `'use client'` directive and import `useGT()` for client component
369
- 4. Import `getGT()` and make server component async
370
- 5. Pass `t()` when calling the imported function from both components
371
-
372
- ```jsx title="utils.ts"
373
- export function formatStatus(status, t: (string: string, options?: InlineTranslationOptions) => string) {
374
- switch (status) {
375
- case 'pending':
376
- return t('Pending approval');
377
- case 'approved':
378
- return t('Request approved');
379
- case 'rejected':
380
- return t('Request rejected');
381
- default:
382
- return t('Status unknown');
383
- }
384
- }
385
- ```
386
-
387
- ```jsx title="ClientComponent.tsx"
388
- 'use client';
389
- import { useGT } from 'gt-next/client';
390
- import { formatStatus } from './utils';
391
-
392
- export function ClientComponent() {
393
- const [status, setStatus] = useState('pending');
394
- const t = useGT();
395
- const statusText = formatStatus(status, t);
396
- return <div>{statusText}</div>;
397
- }
398
- ```
399
-
400
- ```jsx title="ServerComponent.tsx"
401
- import { getGT } from 'gt-next/server';
402
- import { formatStatus } from './utils';
403
-
404
- export async function ServerComponent() {
405
- const status = 'pending';
406
- const t = await getGT();
407
- const statusText = formatStatus(status, t);
408
- return <div>{statusText}</div>;
409
- }
410
- ```
411
-
412
- ### Pattern 3: Complex Function Chain Across Client and Server
413
-
414
- **Scenario**: Function chain that calls other functions across multiple files, used by both client and server components
415
-
416
- ```jsx title="userActions.ts"
417
- import { validateUserData } from './userValidator';
418
-
419
- export function processUserRegistration(userData) {
420
- const validationResult = validateUserData(userData);
421
-
422
- if (!validationResult.success) {
423
- return {
424
- success: false,
425
- message: validationResult.errorMessage,
426
- };
427
- }
428
-
429
- return {
430
- success: true,
431
- message: 'User registration completed successfully',
432
- };
433
- }
434
- ```
435
-
436
- ```jsx title="userValidator.ts"
437
- export function validateUserData(userData) {
438
- if (!userData.email) {
439
- return {
440
- success: false,
441
- errorMessage: 'Email address is required',
442
- };
443
- }
444
-
445
- if (!userData.password) {
446
- return {
447
- success: false,
448
- errorMessage: 'Password is required',
449
- };
450
- }
451
-
452
- return {
453
- success: true,
454
- message: 'User data validated successfully',
455
- };
456
- }
457
- ```
458
-
459
- **Solution**: Pass `t()` function through the entire call chain for both client and server usage
460
-
461
- 1. Modify each function in the chain to accept and pass through the `t()` parameter
462
- 2. Use `t()` for string translations at the final destination
463
- 3. Handle both client and server component usage patterns
464
-
465
- ```jsx title="userActions.ts"
466
- import { validateUserData } from './userValidator';
467
-
468
- export function processUserRegistration(userData, t: (string: string, options?: InlineTranslationOptions) => string) {
469
- const validationResult = validateUserData(userData, t);
470
-
471
- if (!validationResult.success) {
472
- return {
473
- success: false,
474
- message: validationResult.errorMessage
475
- };
476
- }
477
-
478
- return {
479
- success: true,
480
- message: t('User registration completed successfully')
481
- };
482
- }
483
- ```
484
-
485
- ```jsx title="userValidator.ts"
486
- export function validateUserData(userData, t: (string: string, options?: InlineTranslationOptions) => string) {
487
- if (!userData.email) {
488
- return {
489
- success: false,
490
- errorMessage: t('Email address is required')
491
- };
492
- }
493
-
494
- if (!userData.password) {
495
- return {
496
- success: false,
497
- errorMessage: t('Password is required')
498
- };
499
- }
500
-
501
- return {
502
- success: true,
503
- message: t('User data validated successfully')
504
- };
505
- }
506
- ```
507
-
508
- **Client Component Usage**:
509
-
510
- ```jsx title="ClientRegistration.tsx"
511
- 'use client';
512
- import { useGT } from 'gt-next/client';
513
- import { processUserRegistration } from './userActions';
514
-
515
- export function ClientRegistration() {
516
- const [userData, setUserData] = useState({});
517
- const t = useGT();
518
-
519
- const handleSubmit = () => {
520
- const result = processUserRegistration(userData, t);
521
- console.log(result.message);
522
- };
523
-
524
- return <button onClick={handleSubmit}>Register</button>;
525
- }
526
- ```
527
-
528
- **Server Component Usage**:
529
-
530
- ```jsx title="ServerRegistration.tsx"
531
- import { getGT } from 'gt-next/server';
532
- import { processUserRegistration } from './userActions';
533
-
534
- export async function ServerRegistration() {
535
- const userData = { email: 'test@example.com', password: 'password123' };
536
- const t = await getGT();
537
- const result = processUserRegistration(userData, t);
538
-
539
- return <div>{result.message}</div>;
540
- }
541
- ```
542
-
543
- **Common Pitfalls for Functions (Addresses Both Client and Server)**
544
-
545
- - Forgetting to add the `t` parameter to the function signature
546
- - Not passing `t()` when calling the function
547
- - **Client-specific pitfalls**: Importing `useGT()` from `'gt-next'` instead of `'gt-next/client'`, forgetting `'use client'` directive
548
- - **Server-specific pitfalls**: Importing `getGT()` from `'gt-next'` instead of `'gt-next/server'`, not making the component async when using `getGT()`
549
- - Making utility functions async when they shouldn't be (only server component functions should be made async)
550
- - Breaking the `t()` parameter chain when passing through multiple function calls