juxscript 1.1.349 → 1.1.352

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 (86) hide show
  1. package/dist/lib/components/blocks/menu.d.ts +40 -0
  2. package/dist/lib/components/blocks/menu.d.ts.map +1 -0
  3. package/dist/lib/components/blocks/menu.js +136 -0
  4. package/dist/lib/components/button.d.ts +33 -0
  5. package/dist/lib/components/button.d.ts.map +1 -0
  6. package/dist/lib/components/button.js +107 -0
  7. package/dist/lib/components/checkbox.d.ts +62 -0
  8. package/dist/lib/components/checkbox.d.ts.map +1 -0
  9. package/dist/lib/components/checkbox.js +178 -0
  10. package/dist/lib/components/container.d.ts +58 -0
  11. package/dist/lib/components/container.d.ts.map +1 -0
  12. package/dist/lib/components/container.js +151 -0
  13. package/dist/lib/components/data.d.ts +58 -0
  14. package/dist/lib/components/data.d.ts.map +1 -0
  15. package/dist/lib/components/data.js +130 -0
  16. package/dist/lib/components/grid.d.ts +58 -0
  17. package/dist/lib/components/grid.d.ts.map +1 -0
  18. package/dist/lib/components/grid.js +127 -0
  19. package/dist/lib/components/include.d.ts +86 -0
  20. package/dist/lib/components/include.d.ts.map +1 -0
  21. package/dist/lib/components/include.js +238 -0
  22. package/dist/lib/components/input.d.ts +58 -0
  23. package/dist/lib/components/input.d.ts.map +1 -0
  24. package/dist/lib/components/input.js +161 -0
  25. package/dist/lib/components/link.d.ts +35 -0
  26. package/dist/lib/components/link.d.ts.map +1 -0
  27. package/dist/lib/components/link.js +135 -0
  28. package/dist/lib/components/list.d.ts +48 -0
  29. package/dist/lib/components/list.d.ts.map +1 -0
  30. package/dist/lib/components/list.js +178 -0
  31. package/dist/lib/components/nav.d.ts +46 -0
  32. package/dist/lib/components/nav.d.ts.map +1 -0
  33. package/dist/lib/components/nav.js +189 -0
  34. package/dist/lib/components/radio.d.ts +40 -0
  35. package/dist/lib/components/radio.d.ts.map +1 -0
  36. package/dist/lib/components/radio.js +112 -0
  37. package/dist/lib/components/select.d.ts +41 -0
  38. package/dist/lib/components/select.d.ts.map +1 -0
  39. package/dist/lib/components/select.js +111 -0
  40. package/dist/lib/components/sidebar.d.ts +40 -0
  41. package/dist/lib/components/sidebar.d.ts.map +1 -0
  42. package/dist/lib/components/sidebar.js +141 -0
  43. package/dist/lib/components/store.d.ts +78 -0
  44. package/dist/lib/components/store.d.ts.map +1 -0
  45. package/dist/lib/components/store.js +248 -0
  46. package/dist/lib/components/style.d.ts +27 -0
  47. package/dist/lib/components/style.d.ts.map +1 -0
  48. package/dist/lib/components/style.js +52 -0
  49. package/dist/lib/components/table.d.ts +56 -0
  50. package/dist/lib/components/table.d.ts.map +1 -0
  51. package/dist/lib/components/table.js +199 -0
  52. package/dist/lib/components/tabs.d.ts +52 -0
  53. package/dist/lib/components/tabs.d.ts.map +1 -0
  54. package/dist/lib/components/tabs.js +206 -0
  55. package/dist/lib/components/tag.d.ts +41 -0
  56. package/dist/lib/components/tag.d.ts.map +1 -0
  57. package/dist/lib/components/tag.js +103 -0
  58. package/dist/lib/devtools/devtools.d.ts +3 -0
  59. package/dist/lib/devtools/devtools.d.ts.map +1 -0
  60. package/dist/lib/devtools/devtools.js +181 -0
  61. package/dist/lib/index.d.ts +68 -0
  62. package/dist/lib/index.d.ts.map +1 -0
  63. package/dist/lib/index.js +63 -0
  64. package/dist/lib/state/pageState.d.ts +19 -0
  65. package/dist/lib/state/pageState.d.ts.map +1 -0
  66. package/dist/lib/state/pageState.js +360 -0
  67. package/dist/lib/utils/codeHighlight.d.ts +7 -0
  68. package/dist/lib/utils/codeHighlight.d.ts.map +1 -0
  69. package/dist/lib/utils/codeHighlight.js +105 -0
  70. package/dist/lib/utils/codeparser.d.ts +29 -0
  71. package/dist/lib/utils/codeparser.d.ts.map +1 -0
  72. package/dist/lib/utils/codeparser.js +384 -0
  73. package/dist/lib/utils/fetch.d.ts +176 -0
  74. package/dist/lib/utils/fetch.d.ts.map +1 -0
  75. package/dist/lib/utils/fetch.js +427 -0
  76. package/dist/lib/utils/formatId.d.ts +16 -0
  77. package/dist/lib/utils/formatId.d.ts.map +1 -0
  78. package/dist/lib/utils/formatId.js +27 -0
  79. package/dist/lib/utils/idgen.d.ts +2 -0
  80. package/dist/lib/utils/idgen.d.ts.map +1 -0
  81. package/dist/lib/utils/idgen.js +4 -0
  82. package/dist/lib/utils/niceName.d.ts +14 -0
  83. package/dist/lib/utils/niceName.d.ts.map +1 -0
  84. package/dist/lib/utils/niceName.js +22 -0
  85. package/machinery/compiler4.js +61 -2
  86. package/package.json +1 -1
@@ -0,0 +1,427 @@
1
+ /**
2
+ * Jux Fetch Utility
3
+ *
4
+ * A lightweight fetch wrapper with sensible defaults, error handling, and method chaining.
5
+ * Includes configuration helpers for juxconfig.js integration.
6
+ *
7
+ * Usage:
8
+ * // Configure once (optional)
9
+ * jux.fetch.config({
10
+ * baseUrl: 'https://api.example.com',
11
+ * credentials: 'include',
12
+ * timeout: 10000,
13
+ * log: 'errors',
14
+ * onUnauthorized: () => window.location.href = '/login'
15
+ * });
16
+ *
17
+ * // Simple GET
18
+ * const { data, error } = await jux.fetch('/users').send();
19
+ *
20
+ * // Method chaining
21
+ * const { data, error } = await jux.fetch('/users')
22
+ * .method('POST')
23
+ * .body({ name: 'John' })
24
+ * .params({ limit: 10 })
25
+ * .timeout(5000)
26
+ * .log(true)
27
+ * .send();
28
+ *
29
+ * // With juxconfig services
30
+ * const { data } = await jux.fetch('/users')
31
+ * .baseUrl(jux.fetch.getServiceUrl('database'))
32
+ * .send();
33
+ *
34
+ * // Service client helper
35
+ * const db = jux.fetch.serviceClient('database');
36
+ * const { data } = await db.fetch('/users').send();
37
+ */
38
+ // Global configuration
39
+ let globalConfig = {
40
+ credentials: 'same-origin',
41
+ headers: {
42
+ 'Content-Type': 'application/json'
43
+ },
44
+ timeout: 30000,
45
+ log: false
46
+ };
47
+ /**
48
+ * Configure global fetch defaults
49
+ */
50
+ export function configureFetch(config) {
51
+ globalConfig = {
52
+ ...globalConfig,
53
+ ...config,
54
+ headers: {
55
+ ...globalConfig.headers,
56
+ ...config.headers
57
+ }
58
+ };
59
+ }
60
+ /**
61
+ * Build URL with query parameters
62
+ */
63
+ function buildUrl(url, params) {
64
+ if (!params || Object.keys(params).length === 0) {
65
+ return url;
66
+ }
67
+ const searchParams = new URLSearchParams();
68
+ Object.entries(params).forEach(([key, value]) => {
69
+ if (value !== undefined && value !== null) {
70
+ searchParams.append(key, String(value));
71
+ }
72
+ });
73
+ const queryString = searchParams.toString();
74
+ if (!queryString)
75
+ return url;
76
+ return url.includes('?')
77
+ ? `${url}&${queryString}`
78
+ : `${url}?${queryString}`;
79
+ }
80
+ /**
81
+ * Main fetch function
82
+ */
83
+ async function executeFetch(url, options = {}) {
84
+ const { params, body, timeout = globalConfig.timeout, log = globalConfig.log, onUnauthorized = globalConfig.onUnauthorized, onError = globalConfig.onError, parseResponse = true, headers = {}, ...fetchOptions } = options;
85
+ // Build full URL
86
+ let fullUrl = url;
87
+ // Add base URL if configured and URL is relative
88
+ if (globalConfig.baseUrl && !url.startsWith('http://') && !url.startsWith('https://')) {
89
+ fullUrl = `${globalConfig.baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
90
+ }
91
+ // Add query params
92
+ fullUrl = buildUrl(fullUrl, params);
93
+ // Merge headers
94
+ const mergedHeaders = {
95
+ ...globalConfig.headers,
96
+ ...headers
97
+ };
98
+ // Prepare request init
99
+ const requestInit = {
100
+ ...fetchOptions,
101
+ headers: mergedHeaders,
102
+ credentials: options.credentials ?? globalConfig.credentials
103
+ };
104
+ // Stringify body if it's an object
105
+ if (body !== undefined) {
106
+ if (body instanceof FormData) {
107
+ requestInit.body = body;
108
+ // Remove Content-Type header for FormData (browser sets it with boundary)
109
+ delete requestInit.headers['Content-Type'];
110
+ }
111
+ else if (typeof body === 'object') {
112
+ requestInit.body = JSON.stringify(body);
113
+ }
114
+ else {
115
+ requestInit.body = body;
116
+ }
117
+ }
118
+ // Log request
119
+ if (log === true) {
120
+ console.log(`[JUX Fetch] ${requestInit.method || 'GET'} ${fullUrl}`, {
121
+ headers: requestInit.headers,
122
+ body: requestInit.body,
123
+ params
124
+ });
125
+ }
126
+ // Setup timeout
127
+ const controller = new AbortController();
128
+ const timeoutId = timeout ? setTimeout(() => controller.abort(), timeout) : null;
129
+ if (!requestInit.signal) {
130
+ requestInit.signal = controller.signal;
131
+ }
132
+ try {
133
+ const response = await fetch(fullUrl, requestInit);
134
+ if (timeoutId)
135
+ clearTimeout(timeoutId);
136
+ // Handle unauthorized
137
+ if (response.status === 401 || response.status === 403) {
138
+ if (onUnauthorized) {
139
+ onUnauthorized();
140
+ }
141
+ }
142
+ // Parse response
143
+ let data = null;
144
+ let errorData = null;
145
+ if (parseResponse) {
146
+ const contentType = response.headers.get('content-type');
147
+ if (contentType?.includes('application/json')) {
148
+ try {
149
+ const json = await response.json();
150
+ if (response.ok) {
151
+ data = json;
152
+ }
153
+ else {
154
+ errorData = json;
155
+ }
156
+ }
157
+ catch (e) {
158
+ // JSON parse error
159
+ }
160
+ }
161
+ else if (response.ok) {
162
+ // Non-JSON response, try to get text
163
+ try {
164
+ data = (await response.text());
165
+ }
166
+ catch (e) {
167
+ // Ignore text parse errors
168
+ }
169
+ }
170
+ }
171
+ // Check if request was successful
172
+ if (!response.ok) {
173
+ const error = {
174
+ message: errorData?.message || errorData?.error || response.statusText || 'Request failed',
175
+ status: response.status,
176
+ statusText: response.statusText,
177
+ data: errorData
178
+ };
179
+ // Log error
180
+ if (log === true || log === 'errors') {
181
+ console.error(`[JUX Fetch Error] ${requestInit.method || 'GET'} ${fullUrl}`, error);
182
+ }
183
+ if (onError) {
184
+ onError(error);
185
+ }
186
+ return {
187
+ data: null,
188
+ error,
189
+ status: response.status,
190
+ response
191
+ };
192
+ }
193
+ // Log success
194
+ if (log === true) {
195
+ console.log(`[JUX Fetch Success] ${requestInit.method || 'GET'} ${fullUrl}`, {
196
+ status: response.status,
197
+ data
198
+ });
199
+ }
200
+ return {
201
+ data,
202
+ error: null,
203
+ status: response.status,
204
+ response
205
+ };
206
+ }
207
+ catch (err) {
208
+ if (timeoutId)
209
+ clearTimeout(timeoutId);
210
+ const error = {
211
+ message: err.name === 'AbortError'
212
+ ? 'Request timeout'
213
+ : err.message || 'Network error',
214
+ status: 0
215
+ };
216
+ // Log error
217
+ if (log === true || log === 'errors') {
218
+ console.error(`[JUX Fetch Error] ${requestInit.method || 'GET'} ${fullUrl}`, error);
219
+ }
220
+ if (onError) {
221
+ onError(error);
222
+ }
223
+ return {
224
+ data: null,
225
+ error,
226
+ status: 0,
227
+ response: null
228
+ };
229
+ }
230
+ }
231
+ /**
232
+ * FetchBuilder class for method chaining
233
+ */
234
+ class FetchBuilder {
235
+ constructor(url, options = {}) {
236
+ this.options = {};
237
+ this.url = url;
238
+ this.options = options;
239
+ }
240
+ method(value) {
241
+ this.options.method = value;
242
+ return this;
243
+ }
244
+ body(value) {
245
+ this.options.body = value;
246
+ return this;
247
+ }
248
+ params(value) {
249
+ this.options.params = value;
250
+ return this;
251
+ }
252
+ headers(value) {
253
+ this.options.headers = { ...this.options.headers, ...value };
254
+ return this;
255
+ }
256
+ header(key, value) {
257
+ this.options.headers = { ...this.options.headers, [key]: value };
258
+ return this;
259
+ }
260
+ timeout(value) {
261
+ this.options.timeout = value;
262
+ return this;
263
+ }
264
+ credentials(value) {
265
+ this.options.credentials = value;
266
+ return this;
267
+ }
268
+ log(value) {
269
+ this.options.log = value;
270
+ return this;
271
+ }
272
+ parseResponse(value) {
273
+ this.options.parseResponse = value;
274
+ return this;
275
+ }
276
+ onUnauthorized(callback) {
277
+ this.options.onUnauthorized = callback;
278
+ return this;
279
+ }
280
+ onError(callback) {
281
+ this.options.onError = callback;
282
+ return this;
283
+ }
284
+ /**
285
+ * Execute the fetch request
286
+ */
287
+ send() {
288
+ return executeFetch(this.url, this.options);
289
+ }
290
+ /**
291
+ * Alias for send()
292
+ */
293
+ fetch() {
294
+ return this.send();
295
+ }
296
+ /**
297
+ * Make the builder thenable (Promise-like) so it can be awaited directly
298
+ * This allows: await jux.fetch('/users') without needing .send()
299
+ */
300
+ then(onfulfilled, onrejected) {
301
+ return this.send().then(onfulfilled, onrejected);
302
+ }
303
+ /**
304
+ * Make the builder catchable for Promise.catch()
305
+ */
306
+ catch(onrejected) {
307
+ return this.send().catch(onrejected);
308
+ }
309
+ /**
310
+ * Make the builder finally-able for Promise.finally()
311
+ */
312
+ finally(onfinally) {
313
+ return this.send().finally(onfinally);
314
+ }
315
+ }
316
+ /**
317
+ * Create a fetch builder
318
+ */
319
+ export function juxFetch(url, options = {}) {
320
+ return new FetchBuilder(url, options);
321
+ }
322
+ /**
323
+ * Convenience methods for common HTTP verbs
324
+ */
325
+ export const fetchHelpers = {
326
+ get: (url, options) => new FetchBuilder(url, { ...options, method: 'GET' }),
327
+ post: (url, body, options) => new FetchBuilder(url, { ...options, method: 'POST', body }),
328
+ put: (url, body, options) => new FetchBuilder(url, { ...options, method: 'PUT', body }),
329
+ patch: (url, body, options) => new FetchBuilder(url, { ...options, method: 'PATCH', body }),
330
+ delete: (url, options) => new FetchBuilder(url, { ...options, method: 'DELETE' })
331
+ };
332
+ /**
333
+ * Fetch multiple URLs in parallel
334
+ */
335
+ export async function fetchAll(urls, options) {
336
+ return Promise.all(urls.map(url => executeFetch(url, options)));
337
+ }
338
+ /**
339
+ * Get a service URL from window.juxConfig
340
+ */
341
+ export function getServiceUrl(serviceName) {
342
+ if (typeof window === 'undefined')
343
+ return null;
344
+ const juxConfig = window.juxConfig;
345
+ if (!juxConfig?.services)
346
+ return null;
347
+ return juxConfig.services[serviceName] || null;
348
+ }
349
+ /**
350
+ * Create a fetch instance preconfigured for a specific service
351
+ *
352
+ * Usage:
353
+ * const api = jux.fetch.serviceClient('database');
354
+ * const { data } = await api.fetch('/users').send();
355
+ */
356
+ export function serviceClient(serviceName) {
357
+ const baseUrl = getServiceUrl(serviceName);
358
+ if (!baseUrl) {
359
+ console.warn(`[JUX Fetch] Service '${serviceName}' not found in juxConfig.services`);
360
+ }
361
+ return {
362
+ fetch: (url, options) => {
363
+ return juxFetch(url, {
364
+ ...options,
365
+ baseUrl: baseUrl || undefined
366
+ });
367
+ },
368
+ baseUrl
369
+ };
370
+ }
371
+ /**
372
+ * Setup fetch from juxconfig
373
+ * Call this in your bootstrap function
374
+ *
375
+ * Usage:
376
+ * export default {
377
+ * bootstrap: [
378
+ * async function initFetch() {
379
+ * await jux.fetch.setupConfig();
380
+ * }
381
+ * ]
382
+ * };
383
+ */
384
+ export async function setupConfig() {
385
+ if (typeof window === 'undefined') {
386
+ console.warn('[JUX Fetch] setupConfig() called outside browser environment');
387
+ return;
388
+ }
389
+ const juxConfig = window.juxConfig;
390
+ if (!juxConfig) {
391
+ console.warn('[JUX Fetch] No juxConfig found on window. Make sure your juxconfig.js is loaded.');
392
+ return;
393
+ }
394
+ const services = juxConfig.services || {};
395
+ if (Object.keys(services).length === 0) {
396
+ console.log('[JUX Fetch] No services configured in juxConfig');
397
+ return;
398
+ }
399
+ // Configure fetch with common defaults
400
+ const fetchConfig = {
401
+ timeout: juxConfig.fetchTimeout || 30000,
402
+ log: juxConfig.fetchLog || false,
403
+ credentials: 'include'
404
+ };
405
+ // Add service-specific handlers
406
+ if (services.auth) {
407
+ fetchConfig.onUnauthorized = () => {
408
+ console.warn('[JUX Fetch] Unauthorized - consider redirecting to login');
409
+ };
410
+ }
411
+ configureFetch(fetchConfig);
412
+ // Log configured services
413
+ console.log('[JUX Fetch] Configured with services:', Object.keys(services));
414
+ return {
415
+ services,
416
+ getServiceUrl
417
+ };
418
+ }
419
+ // Export combined API
420
+ export const fetchAPI = Object.assign(juxFetch, {
421
+ config: configureFetch,
422
+ setupConfig,
423
+ getServiceUrl,
424
+ serviceClient,
425
+ ...fetchHelpers,
426
+ all: fetchAll
427
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Convert a component ID to a human-readable label
3
+ *
4
+ * Examples:
5
+ * 'btn-1' → 'Btn 1'
6
+ * 'btn1' → 'Btn1'
7
+ * 'btn-primary-1' → 'Btn Primary 1'
8
+ * 'user-email-input' → 'User Email Input'
9
+ * 'firstName' → 'First Name'
10
+ * 'first_name' → 'First Name'
11
+ *
12
+ * @param id - Component ID (kebab-case, snake_case, or camelCase)
13
+ * @returns Human-readable label with proper capitalization
14
+ */
15
+ export declare function formatIdAsLabel(id: string): string;
16
+ //# sourceMappingURL=formatId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatId.d.ts","sourceRoot":"","sources":["../../../lib/utils/formatId.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAalD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Convert a component ID to a human-readable label
3
+ *
4
+ * Examples:
5
+ * 'btn-1' → 'Btn 1'
6
+ * 'btn1' → 'Btn1'
7
+ * 'btn-primary-1' → 'Btn Primary 1'
8
+ * 'user-email-input' → 'User Email Input'
9
+ * 'firstName' → 'First Name'
10
+ * 'first_name' → 'First Name'
11
+ *
12
+ * @param id - Component ID (kebab-case, snake_case, or camelCase)
13
+ * @returns Human-readable label with proper capitalization
14
+ */
15
+ export function formatIdAsLabel(id) {
16
+ if (!id)
17
+ return '';
18
+ // Split by common delimiters: hyphens, underscores, or camelCase boundaries
19
+ const words = id
20
+ .replace(/([a-z])([A-Z])/g, '$1 $2') // camelCase → separate words
21
+ .split(/[-_\s]+/) // Split by hyphens, underscores, spaces
22
+ .filter(word => word.length > 0);
23
+ // Capitalize first letter of each word
24
+ return words
25
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
26
+ .join(' ');
27
+ }
@@ -0,0 +1,2 @@
1
+ export default function generateId(prefix?: string, length?: number): string;
2
+ //# sourceMappingURL=idgen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idgen.d.ts","sourceRoot":"","sources":["../../../lib/utils/idgen.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,MAAM,GAAE,MAAc,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAGrF"}
@@ -0,0 +1,4 @@
1
+ export default function generateId(prefix = 'jux', length = 9) {
2
+ const randomPart = Math.random().toString(36).substr(2, length); // Generate a random string
3
+ return `${prefix}-${randomPart}`;
4
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Convert a kebab-case or snake_case ID into a human-readable label.
3
+ *
4
+ * Examples:
5
+ * 'my-button' → 'My Button'
6
+ * 'nav-home' → 'Nav Home'
7
+ * 'user_name' → 'User Name'
8
+ * 'firstName' → 'First Name'
9
+ * 'save-and-close' → 'Save And Close'
10
+ * 'already Nice' → 'Already Nice'
11
+ */
12
+ export declare function niceName(id: string): string;
13
+ export default niceName;
14
+ //# sourceMappingURL=niceName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"niceName.d.ts","sourceRoot":"","sources":["../../../lib/utils/niceName.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAS3C;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Convert a kebab-case or snake_case ID into a human-readable label.
3
+ *
4
+ * Examples:
5
+ * 'my-button' → 'My Button'
6
+ * 'nav-home' → 'Nav Home'
7
+ * 'user_name' → 'User Name'
8
+ * 'firstName' → 'First Name'
9
+ * 'save-and-close' → 'Save And Close'
10
+ * 'already Nice' → 'Already Nice'
11
+ */
12
+ export function niceName(id) {
13
+ return id
14
+ // Insert space before camelCase capitals: 'firstName' → 'first Name'
15
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
16
+ // Replace dashes, underscores, dots with spaces
17
+ .replace(/[-_.]+/g, ' ')
18
+ // Uppercase first letter of each word
19
+ .replace(/\b\w/g, c => c.toUpperCase())
20
+ .trim();
21
+ }
22
+ export default niceName;
@@ -26,29 +26,88 @@ export class JuxCompiler {
26
26
  findJuxscriptPath() {
27
27
  if (this._juxscriptPath) return this._juxscriptPath;
28
28
 
29
-
30
-
31
29
  const projectRoot = process.cwd();
32
30
 
31
+ // 1. User's project node_modules (standard npm install)
33
32
  const userPath = path.resolve(projectRoot, 'node_modules/juxscript/dist/lib/index.js');
34
33
  if (fs.existsSync(userPath)) {
34
+ console.log(`📦 Using: ${userPath}`);
35
35
  this._juxscriptPath = userPath;
36
36
  return userPath;
37
37
  }
38
38
 
39
+ // 2. User's project node_modules — flat dist
40
+ const userPathFlat = path.resolve(projectRoot, 'node_modules/juxscript/dist/index.js');
41
+ if (fs.existsSync(userPathFlat)) {
42
+ console.log(`📦 Using: ${userPathFlat}`);
43
+ this._juxscriptPath = userPathFlat;
44
+ return userPathFlat;
45
+ }
46
+
47
+ // 3. Dev mode — built from parent package
39
48
  const packageRoot = path.resolve(__dirname, '..');
40
49
  const devPath = path.resolve(packageRoot, 'dist', 'lib', 'index.js');
41
50
  if (fs.existsSync(devPath)) {
51
+ console.log(`📦 Using (dev): ${devPath}`);
42
52
  this._juxscriptPath = devPath;
43
53
  return devPath;
44
54
  }
45
55
 
56
+ // 4. Dev mode — flat dist
57
+ const devPathFlat = path.resolve(packageRoot, 'dist', 'index.js');
58
+ if (fs.existsSync(devPathFlat)) {
59
+ console.log(`📦 Using (dev flat): ${devPathFlat}`);
60
+ this._juxscriptPath = devPathFlat;
61
+ return devPathFlat;
62
+ }
63
+
64
+ // 5. Monorepo sibling
46
65
  const monoPath = path.resolve(projectRoot, '../jux/dist/lib/index.js');
47
66
  if (fs.existsSync(monoPath)) {
67
+ console.log(`📦 Using (mono): ${monoPath}`);
48
68
  this._juxscriptPath = monoPath;
49
69
  return monoPath;
50
70
  }
51
71
 
72
+ // 6. Try require.resolve as last resort
73
+ try {
74
+ const resolved = require.resolve('juxscript');
75
+ if (fs.existsSync(resolved)) {
76
+ console.log(`📦 Using (resolved): ${resolved}`);
77
+ this._juxscriptPath = resolved;
78
+ return resolved;
79
+ }
80
+ } catch (_) { }
81
+
82
+ // Debug: show what was checked
83
+ console.error('❌ Searched for juxscript at:');
84
+ console.error(` ${userPath}`);
85
+ console.error(` ${userPathFlat}`);
86
+ console.error(` ${devPath}`);
87
+ console.error(` ${devPathFlat}`);
88
+ console.error(` ${monoPath}`);
89
+
90
+ // Check if node_modules/juxscript exists at all
91
+ const juxscriptDir = path.resolve(projectRoot, 'node_modules/juxscript');
92
+ if (fs.existsSync(juxscriptDir)) {
93
+ console.error(`\n📁 node_modules/juxscript exists. Contents:`);
94
+ try {
95
+ const pkg = JSON.parse(fs.readFileSync(path.join(juxscriptDir, 'package.json'), 'utf8'));
96
+ console.error(` main: ${pkg.main}`);
97
+ console.error(` types: ${pkg.types}`);
98
+ if (pkg.exports) console.error(` exports: ${JSON.stringify(pkg.exports)}`);
99
+ } catch (_) { }
100
+ const distDir = path.join(juxscriptDir, 'dist');
101
+ if (fs.existsSync(distDir)) {
102
+ const files = fs.readdirSync(distDir, { recursive: true });
103
+ console.error(` dist/ files: ${files.slice(0, 20).join(', ')}${files.length > 20 ? '...' : ''}`);
104
+ } else {
105
+ console.error(` ⚠️ dist/ directory missing — lib may not be built`);
106
+ }
107
+ } else {
108
+ console.error(`\n⚠️ node_modules/juxscript does not exist — run: npm install juxscript`);
109
+ }
110
+
52
111
  return null;
53
112
  }
54
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.349",
3
+ "version": "1.1.352",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "./dist/lib/index.js",