@fullstackunicorn/root 3.0.0 → 3.1.0

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.
@@ -502,7 +502,7 @@
502
502
  {
503
503
  "path": "client/load.js",
504
504
  "class": "sacred",
505
- "sha256": "911da4f40e24a82e9d860dd8aa55bde3a4d9c41f8fb853908439bffd83cf687d",
505
+ "sha256": "a892db255693e1e8db1afc4bb7395c5c944152529ce45e4076f1913cbfbea738",
506
506
  "referenceSha256": "173abaf7547afdfb0fbccca0c150d5dece48bbb79b6d8e97b9202de237b36fd3"
507
507
  },
508
508
  {
@@ -961,7 +961,7 @@
961
961
  {
962
962
  "path": "index.html",
963
963
  "class": "entry",
964
- "sha256": "4139d9fc954608ad7e678a97af582711ec102346f652ce32451c9913a3312ab5",
964
+ "sha256": "e014ed077a6a981a0dcb7f35f9027ad9b3b58079f05a7b088fba8cba57b49403",
965
965
  "referenceSha256": "dd6a11b7a819a20e7d1425bb3eccf0566ecd5b1eea1d4a3507354f1011d56170"
966
966
  },
967
967
  {
@@ -1591,7 +1591,7 @@
1591
1591
  {
1592
1592
  "path": "panels/content/Payment.js",
1593
1593
  "class": "composition",
1594
- "sha256": "71682702af05375619646537a6049229b478af9f5ac4ad9310b0c3978be014cc",
1594
+ "sha256": "2f1573bc4b555ff61676c413789e17642fc00d1840b34ed8abf5048832faf59a",
1595
1595
  "referenceSha256": "71682702af05375619646537a6049229b478af9f5ac4ad9310b0c3978be014cc"
1596
1596
  },
1597
1597
  {
@@ -1879,7 +1879,7 @@
1879
1879
  {
1880
1880
  "path": "root/preferences.js",
1881
1881
  "class": "sacred",
1882
- "sha256": "183edd0405eea6496d58601a314ae9ab4a01079aaa1f060aaa95afec9c33ead6",
1882
+ "sha256": "a2dcb3a476907e5fb2b4ac9810cc9ccc73fd0f16e1e67836f5cc59f923a15d10",
1883
1883
  "referenceSha256": "183edd0405eea6496d58601a314ae9ab4a01079aaa1f060aaa95afec9c33ead6"
1884
1884
  },
1885
1885
  {
@@ -33,10 +33,13 @@ uri.data.lookups = {}
33
33
  uri.data.lookups.logic = `${env.CDN0}/lookup/:path/@logic.json`
34
34
  uri.data.lookups.verbal = `${env.CDN0}/lookup/:path/:lang.json`
35
35
 
36
+ uri.data.load = {}
37
+ uri.data.load.json = `${env.CDN0}/data/load/:id/:lang`
38
+ uri.data.load.media = `${env.CDN0}/data/load/:id/media/:lang`
39
+
36
40
  uri.media = `${env.CDN0}/media/:path`
37
41
  uri.trademarks = `${env.CDN0}/media/trademarks/:path`
38
- uri.preload = `${env.CDN0}/preload.json`
39
- uri.version = `${env.CDN0}/version/:lang.json`
42
+ uri.version = `${env.CDN0}/version/:lang`
40
43
 
41
44
  uri.cookies = {}
42
45
  uri.cookies.set = `/api/cookies/set`
@@ -52,7 +52,7 @@ class Load {
52
52
  const pictures = []
53
53
  const visit = (value, key = '') => {
54
54
  if (!value || typeof value !== 'object') return
55
- if (value.src && /\/[SML][123]\//.test(value.src)) {
55
+ if (value.src && /\/(?:S[1-3]|M[1-6]|L[1-3])\//.test(value.src)) {
56
56
  if (['background', 'backdrop', 'ambient'].includes(key) && value.placeholder) return
57
57
  pictures.push({ ...value, profile: value.profile || images.fields[key] })
58
58
  return
@@ -1,4 +1,5 @@
1
1
  {
2
+ "sizesVersion": 1,
2
3
  "concurrency": 2,
3
4
  "profiles": {
4
5
  "cover": {
@@ -6,9 +7,9 @@
6
7
  "widths": {}
7
8
  },
8
9
  "portrait": {
9
- "default": "M2",
10
+ "default": "M4",
10
11
  "widths": {
11
- "576": "M3",
12
+ "576": "M6",
12
13
  "1024": "L2"
13
14
  }
14
15
  }
@@ -22,8 +23,11 @@
22
23
  "S2": 128,
23
24
  "S3": 256,
24
25
  "M1": 320,
25
- "M2": 640,
26
- "M3": 960,
26
+ "M2": 400,
27
+ "M3": 480,
28
+ "M4": 640,
29
+ "M5": 800,
30
+ "M6": 960,
27
31
  "L1": 1280,
28
32
  "L2": 1920,
29
33
  "L3": 2560
@@ -12,7 +12,7 @@
12
12
  <meta http-equiv="Expires" content="0">
13
13
 
14
14
  <meta content="#ffffff" name="msapplication-TileColor" />
15
- <meta content="Hans" name="apple-mobile-web-app-title" />
15
+ <meta content="" name="apple-mobile-web-app-title" />
16
16
 
17
17
  <!-- {{metadata}} -->
18
18
  <!-- {{languages}} -->
@@ -5,6 +5,7 @@ import { stripe } from '#@/client/stripe.js'
5
5
  import { ProductPod } from '#@/panels/product/Product.pod.js'
6
6
  import { useGetFont } from '#@/imports/fonts/use.js'
7
7
  import { paymentReceived } from './paymentState.js'
8
+ import { constants } from '#@/root/constants.js'
8
9
 
9
10
  export const Payment = ({sessionId, path, modules, children}) => {
10
11
  const [result,setResult] = useState(null)
@@ -19,7 +20,8 @@ export const Payment = ({sessionId, path, modules, children}) => {
19
20
  }, [sessionId,path])
20
21
  const paid = result?.sessionId === sessionId && paymentReceived(result.session,path)
21
22
  if (!paid) return result?.sessionId === sessionId ? children : null
22
- return <><Page title={modules.labels.paymentReceived + " — Hans’s Bookshelf"} robots="noindex,nofollow" />
23
+ const pageTitle = modules.labels.paymentReceived + (constants.trademark.text ? ` — ${constants.trademark.text}` : '')
24
+ return <><Page title={pageTitle} robots="noindex,nofollow" />
23
25
  <ProductPod title={modules.labels.paymentReceived}>
24
26
  <Text classes={[font]} tag="P" inline={{fontSize:18,fontWeight:400,lineHeight:28.8,margin:0}} text={modules.labels.paymentShipping} />
25
27
  </ProductPod>
@@ -1,8 +1,9 @@
1
1
  import { storage } from '#@/imports/storage.js'
2
2
  import { useSyncExternalStore } from 'react'
3
3
  import { useGetStatics } from '#@/base/statics/@use.js'
4
+ import { constants } from '#@/root/constants.js'
4
5
 
5
- const key = 'hans.adwiser.me.currency'
6
+ const key = `${constants.env.CLIENT_ID}.currency`
6
7
 
7
8
  export const useCurrency = () => {
8
9
  const statics = useGetStatics()
@@ -13,396 +13,640 @@
13
13
  "items": {
14
14
  "en-US": {
15
15
  "name": "English",
16
- "variant": "United States"
16
+ "variant": "United States",
17
+ "english": "English",
18
+ "native": "English"
17
19
  },
18
20
  "en-GB": {
19
21
  "name": "English",
20
- "variant": "United Kingdom"
22
+ "variant": "United Kingdom",
23
+ "english": "English",
24
+ "native": "English"
21
25
  },
22
26
  "es-ES": {
23
27
  "name": "Spanish",
24
- "variant": "Spain"
28
+ "variant": "Spain",
29
+ "english": "Spanish",
30
+ "native": "Español"
25
31
  },
26
32
  "es-MX": {
27
33
  "name": "Spanish",
28
- "variant": "Mexico"
34
+ "variant": "Mexico",
35
+ "english": "Spanish",
36
+ "native": "Español"
29
37
  },
30
38
  "fr-FR": {
31
39
  "name": "French",
32
- "variant": "France"
40
+ "variant": "France",
41
+ "english": "French",
42
+ "native": "Français"
33
43
  },
34
44
  "fr-CA": {
35
45
  "name": "French",
36
- "variant": "Canada"
46
+ "variant": "Canada",
47
+ "english": "French",
48
+ "native": "Français"
37
49
  },
38
50
  "de-DE": {
39
- "name": "German"
51
+ "name": "German",
52
+ "english": "German",
53
+ "native": "Deutsch"
40
54
  },
41
55
  "it-IT": {
42
- "name": "Italian"
56
+ "name": "Italian",
57
+ "english": "Italian",
58
+ "native": "Italiano"
43
59
  },
44
60
  "pt-PT": {
45
61
  "name": "Portuguese",
46
- "variant": "Portugal"
62
+ "variant": "Portugal",
63
+ "english": "Portuguese",
64
+ "native": "Português"
47
65
  },
48
66
  "pt-BR": {
49
67
  "name": "Portuguese",
50
- "variant": "Brazil"
68
+ "variant": "Brazil",
69
+ "english": "Portuguese",
70
+ "native": "Português"
51
71
  },
52
72
  "ru-RU": {
53
73
  "name": "Russian",
54
- "variant": "Russia"
74
+ "variant": "Russia",
75
+ "english": "Russian",
76
+ "native": "Русский"
55
77
  },
56
78
  "ru-RU-Latn": {
57
79
  "name": "Russian",
58
- "variant": "Latin"
80
+ "variant": "Latin",
81
+ "english": "Russian",
82
+ "native": "Русский"
59
83
  },
60
84
  "zh-CN": {
61
85
  "name": "Chinese",
62
- "variant": "Simplified, China"
86
+ "variant": "Simplified, China",
87
+ "english": "Chinese",
88
+ "native": "中文"
63
89
  },
64
90
  "zh-TW": {
65
91
  "name": "Chinese",
66
- "variant": "Traditional, Taiwan"
92
+ "variant": "Traditional, Taiwan",
93
+ "english": "Chinese",
94
+ "native": "中文"
67
95
  },
68
96
  "ja-JP": {
69
- "name": "Japanese"
97
+ "name": "Japanese",
98
+ "english": "Japanese",
99
+ "native": "日本語"
70
100
  },
71
101
  "ko-KR": {
72
- "name": "Korean"
102
+ "name": "Korean",
103
+ "english": "Korean",
104
+ "native": "한국어"
73
105
  },
74
106
  "ar-SA": {
75
- "name": "Arabic"
107
+ "name": "Arabic",
108
+ "english": "Arabic",
109
+ "native": "العربية"
76
110
  },
77
111
  "hi-IN": {
78
- "name": "Hindi"
112
+ "name": "Hindi",
113
+ "english": "Hindi",
114
+ "native": "हिन्दी"
79
115
  },
80
116
  "bn-BD": {
81
117
  "name": "Bengali",
82
- "variant": "Bangladesh"
118
+ "variant": "Bangladesh",
119
+ "english": "Bengali",
120
+ "native": "বাংলা"
83
121
  },
84
122
  "pa-IN": {
85
123
  "name": "Punjabi",
86
- "variant": "India"
124
+ "variant": "India",
125
+ "english": "Punjabi",
126
+ "native": "ਪੰਜਾਬੀ"
87
127
  },
88
128
  "ta-IN": {
89
129
  "name": "Tamil",
90
- "variant": "India"
130
+ "variant": "India",
131
+ "english": "Tamil",
132
+ "native": "தமிழ்"
91
133
  },
92
134
  "te-IN": {
93
- "name": "Telugu"
135
+ "name": "Telugu",
136
+ "english": "Telugu",
137
+ "native": "తెలుగు"
94
138
  },
95
139
  "ur-PK": {
96
- "name": "Urdu"
140
+ "name": "Urdu",
141
+ "english": "Urdu",
142
+ "native": "اردو"
97
143
  },
98
144
  "tr-TR": {
99
- "name": "Turkish"
145
+ "name": "Turkish",
146
+ "english": "Turkish",
147
+ "native": "Türkçe"
100
148
  },
101
149
  "fa-IR": {
102
- "name": "Persian"
150
+ "name": "Persian",
151
+ "english": "Persian",
152
+ "native": "فارسی"
103
153
  },
104
154
  "vi-VN": {
105
- "name": "Vietnamese"
155
+ "name": "Vietnamese",
156
+ "english": "Vietnamese",
157
+ "native": "Tiếng Việt"
106
158
  },
107
159
  "th-TH": {
108
- "name": "Thai"
160
+ "name": "Thai",
161
+ "english": "Thai",
162
+ "native": "ไทย"
109
163
  },
110
164
  "nl-NL": {
111
- "name": "Dutch"
165
+ "name": "Dutch",
166
+ "english": "Dutch",
167
+ "native": "Nederlands"
112
168
  },
113
169
  "sv-SE": {
114
- "name": "Swedish"
170
+ "name": "Swedish",
171
+ "english": "Swedish",
172
+ "native": "Svenska"
115
173
  },
116
174
  "pl-PL": {
117
- "name": "Polish"
175
+ "name": "Polish",
176
+ "english": "Polish",
177
+ "native": "Polski"
118
178
  },
119
179
  "cs-CZ": {
120
- "name": "Czech"
180
+ "name": "Czech",
181
+ "english": "Czech",
182
+ "native": "Čeština"
121
183
  },
122
184
  "ro-RO": {
123
- "name": "Romanian"
185
+ "name": "Romanian",
186
+ "english": "Romanian",
187
+ "native": "Română"
124
188
  },
125
189
  "hu-HU": {
126
- "name": "Hungarian"
190
+ "name": "Hungarian",
191
+ "english": "Hungarian",
192
+ "native": "Magyar"
127
193
  },
128
194
  "fi-FI": {
129
- "name": "Finnish"
195
+ "name": "Finnish",
196
+ "english": "Finnish",
197
+ "native": "Suomi"
130
198
  },
131
199
  "da-DK": {
132
- "name": "Danish"
200
+ "name": "Danish",
201
+ "english": "Danish",
202
+ "native": "Dansk"
133
203
  },
134
204
  "no-NO": {
135
- "name": "Norwegian"
205
+ "name": "Norwegian",
206
+ "english": "Norwegian",
207
+ "native": "Norsk"
136
208
  },
137
209
  "el-GR": {
138
- "name": "Greek"
210
+ "name": "Greek",
211
+ "english": "Greek",
212
+ "native": "Ελληνικά"
139
213
  },
140
214
  "he-IL": {
141
- "name": "Hebrew"
215
+ "name": "Hebrew",
216
+ "english": "Hebrew",
217
+ "native": "עברית"
142
218
  },
143
219
  "id-ID": {
144
- "name": "Indonesian"
220
+ "name": "Indonesian",
221
+ "english": "Indonesian",
222
+ "native": "Indonesia"
145
223
  },
146
224
  "ms-MY": {
147
- "name": "Malay"
225
+ "name": "Malay",
226
+ "english": "Malay",
227
+ "native": "Melayu"
148
228
  },
149
229
  "tl-PH": {
150
- "name": "Tagalog"
230
+ "name": "Tagalog",
231
+ "english": "Tagalog",
232
+ "native": "Filipino"
151
233
  },
152
234
  "uk-UA": {
153
- "name": "Ukrainian"
235
+ "name": "Ukrainian",
236
+ "english": "Ukrainian",
237
+ "native": "Українська"
154
238
  },
155
239
  "sr-RS": {
156
240
  "name": "Serbian",
157
- "variant": "Serbia"
241
+ "variant": "Serbia",
242
+ "english": "Serbian",
243
+ "native": "Српски"
158
244
  },
159
245
  "sr-RS-Latn": {
160
246
  "name": "Serbian",
161
- "variant": "Latin"
247
+ "variant": "Latin",
248
+ "english": "Serbian",
249
+ "native": "Srpski"
162
250
  },
163
251
  "hr-HR": {
164
- "name": "Croatian"
252
+ "name": "Croatian",
253
+ "english": "Croatian",
254
+ "native": "Hrvatski"
165
255
  },
166
256
  "bg-BG": {
167
- "name": "Bulgarian"
257
+ "name": "Bulgarian",
258
+ "english": "Bulgarian",
259
+ "native": "Български"
168
260
  },
169
261
  "lt-LT": {
170
- "name": "Lithuanian"
262
+ "name": "Lithuanian",
263
+ "english": "Lithuanian",
264
+ "native": "Lietuvių"
171
265
  },
172
266
  "lv-LV": {
173
- "name": "Latvian"
267
+ "name": "Latvian",
268
+ "english": "Latvian",
269
+ "native": "Latviešu"
174
270
  },
175
271
  "et-EE": {
176
- "name": "Estonian"
272
+ "name": "Estonian",
273
+ "english": "Estonian",
274
+ "native": "Eesti"
177
275
  },
178
276
  "sk-SK": {
179
- "name": "Slovak"
277
+ "name": "Slovak",
278
+ "english": "Slovak",
279
+ "native": "Slovenčina"
180
280
  },
181
281
  "sl-SI": {
182
- "name": "Slovenian"
282
+ "name": "Slovenian",
283
+ "english": "Slovenian",
284
+ "native": "Slovenščina"
183
285
  },
184
286
  "af-ZA": {
185
- "name": "Afrikaans"
287
+ "name": "Afrikaans",
288
+ "english": "Afrikaans",
289
+ "native": "Afrikaans"
186
290
  },
187
291
  "sw-KE": {
188
- "name": "Swahili"
292
+ "name": "Swahili",
293
+ "english": "Swahili",
294
+ "native": "Kiswahili"
189
295
  },
190
296
  "sq-AL": {
191
- "name": "Albanian"
297
+ "name": "Albanian",
298
+ "english": "Albanian",
299
+ "native": "Shqip"
192
300
  },
193
301
  "hy-AM": {
194
- "name": "Armenian"
302
+ "name": "Armenian",
303
+ "english": "Armenian",
304
+ "native": "Հայերեն"
195
305
  },
196
306
  "ka-GE": {
197
- "name": "Georgian"
307
+ "name": "Georgian",
308
+ "english": "Georgian",
309
+ "native": "Ქართული"
198
310
  },
199
311
  "mn-MN": {
200
- "name": "Mongolian"
312
+ "name": "Mongolian",
313
+ "english": "Mongolian",
314
+ "native": "Монгол"
201
315
  },
202
316
  "kk-KZ": {
203
- "name": "Kazakh"
317
+ "name": "Kazakh",
318
+ "english": "Kazakh",
319
+ "native": "Қазақ тілі"
204
320
  },
205
321
  "uz-UZ": {
206
- "name": "Uzbek"
322
+ "name": "Uzbek",
323
+ "english": "Uzbek",
324
+ "native": "O‘zbek"
207
325
  },
208
326
  "az-AZ": {
209
- "name": "Azerbaijani"
327
+ "name": "Azerbaijani",
328
+ "english": "Azerbaijani",
329
+ "native": "Azərbaycan"
210
330
  },
211
331
  "bs-BA": {
212
- "name": "Bosnian"
332
+ "name": "Bosnian",
333
+ "english": "Bosnian",
334
+ "native": "Bosanski"
213
335
  },
214
336
  "mk-MK": {
215
- "name": "Macedonian"
337
+ "name": "Macedonian",
338
+ "english": "Macedonian",
339
+ "native": "Македонски"
216
340
  },
217
341
  "cy-GB": {
218
- "name": "Welsh"
342
+ "name": "Welsh",
343
+ "english": "Welsh",
344
+ "native": "Cymraeg"
219
345
  },
220
346
  "is-IS": {
221
- "name": "Icelandic"
347
+ "name": "Icelandic",
348
+ "english": "Icelandic",
349
+ "native": "Íslenska"
222
350
  },
223
351
  "ga-IE": {
224
- "name": "Irish"
352
+ "name": "Irish",
353
+ "english": "Irish",
354
+ "native": "Gaeilge"
225
355
  },
226
356
  "mt-MT": {
227
- "name": "Maltese"
357
+ "name": "Maltese",
358
+ "english": "Maltese",
359
+ "native": "Malti"
228
360
  },
229
361
  "xh-ZA": {
230
- "name": "Xhosa"
362
+ "name": "Xhosa",
363
+ "english": "Xhosa",
364
+ "native": "IsiXhosa"
231
365
  },
232
366
  "zu-ZA": {
233
- "name": "Zulu"
367
+ "name": "Zulu",
368
+ "english": "Zulu",
369
+ "native": "IsiZulu"
234
370
  },
235
371
  "am-ET": {
236
- "name": "Amharic"
372
+ "name": "Amharic",
373
+ "english": "Amharic",
374
+ "native": "አማርኛ"
237
375
  },
238
376
  "my-MM": {
239
- "name": "Burmese"
377
+ "name": "Burmese",
378
+ "english": "Burmese",
379
+ "native": "မြန်မာ"
240
380
  },
241
381
  "km-KH": {
242
- "name": "Khmer"
382
+ "name": "Khmer",
383
+ "english": "Khmer",
384
+ "native": "ខ្មែរ"
243
385
  },
244
386
  "lo-LA": {
245
- "name": "Lao"
387
+ "name": "Lao",
388
+ "english": "Lao",
389
+ "native": "ລາວ"
246
390
  },
247
391
  "si-LK": {
248
- "name": "Sinhala"
392
+ "name": "Sinhala",
393
+ "english": "Sinhala",
394
+ "native": "සිංහල"
249
395
  },
250
396
  "ml-IN": {
251
- "name": "Malayalam"
397
+ "name": "Malayalam",
398
+ "english": "Malayalam",
399
+ "native": "മലയാളം"
252
400
  },
253
401
  "kn-IN": {
254
- "name": "Kannada"
402
+ "name": "Kannada",
403
+ "english": "Kannada",
404
+ "native": "ಕನ್ನಡ"
255
405
  },
256
406
  "gu-IN": {
257
- "name": "Gujarati"
407
+ "name": "Gujarati",
408
+ "english": "Gujarati",
409
+ "native": "ગુજરાતી"
258
410
  },
259
411
  "mr-IN": {
260
- "name": "Marathi"
412
+ "name": "Marathi",
413
+ "english": "Marathi",
414
+ "native": "मराठी"
261
415
  },
262
416
  "or-IN": {
263
- "name": "Odia"
417
+ "name": "Odia",
418
+ "english": "Odia",
419
+ "native": "ଓଡ଼ିଆ"
264
420
  },
265
421
  "ne-NP": {
266
- "name": "Nepali"
422
+ "name": "Nepali",
423
+ "english": "Nepali",
424
+ "native": "नेपाली"
267
425
  },
268
426
  "ps-AF": {
269
- "name": "Pashto"
427
+ "name": "Pashto",
428
+ "english": "Pashto",
429
+ "native": "پښتو"
270
430
  },
271
431
  "sd-PK": {
272
- "name": "Sindhi"
432
+ "name": "Sindhi",
433
+ "english": "Sindhi",
434
+ "native": "سنڌي"
273
435
  },
274
436
  "bo-CN": {
275
- "name": "Tibetan"
437
+ "name": "Tibetan",
438
+ "english": "Tibetan",
439
+ "native": "བོད་སྐད་"
276
440
  },
277
441
  "tg-TJ": {
278
- "name": "Tajik"
442
+ "name": "Tajik",
443
+ "english": "Tajik",
444
+ "native": "Тоҷикӣ"
279
445
  },
280
446
  "ky-KG": {
281
- "name": "Kyrgyz"
447
+ "name": "Kyrgyz",
448
+ "english": "Kyrgyz",
449
+ "native": "Кыргызча"
282
450
  },
283
451
  "tk-TM": {
284
- "name": "Turkmen"
452
+ "name": "Turkmen",
453
+ "english": "Turkmen",
454
+ "native": "Türkmen dili"
285
455
  },
286
456
  "dv-MV": {
287
- "name": "Dhivehi"
457
+ "name": "Dhivehi",
458
+ "english": "Dhivehi",
459
+ "native": "ދިވެހި"
288
460
  },
289
461
  "so-SO": {
290
- "name": "Somali"
462
+ "name": "Somali",
463
+ "english": "Somali",
464
+ "native": "Soomaali"
291
465
  },
292
466
  "ha-NG": {
293
- "name": "Hausa"
467
+ "name": "Hausa",
468
+ "english": "Hausa",
469
+ "native": "Hausa"
294
470
  },
295
471
  "yo-NG": {
296
- "name": "Yoruba"
472
+ "name": "Yoruba",
473
+ "english": "Yoruba",
474
+ "native": "Èdè Yorùbá"
297
475
  },
298
476
  "ig-NG": {
299
- "name": "Igbo"
477
+ "name": "Igbo",
478
+ "english": "Igbo",
479
+ "native": "Igbo"
300
480
  },
301
481
  "ti-ET": {
302
- "name": "Tigrinya"
482
+ "name": "Tigrinya",
483
+ "english": "Tigrinya",
484
+ "native": "ትግርኛ"
303
485
  },
304
486
  "rw-RW": {
305
- "name": "Kinyarwanda"
487
+ "name": "Kinyarwanda",
488
+ "english": "Kinyarwanda",
489
+ "native": "Ikinyarwanda"
306
490
  },
307
491
  "ff-SN": {
308
- "name": "Fula"
492
+ "name": "Fula",
493
+ "english": "Fula",
494
+ "native": "Pulaar"
309
495
  },
310
496
  "sm-WS": {
311
- "name": "Samoan"
497
+ "name": "Samoan",
498
+ "english": "Samoan",
499
+ "native": "Gagana Samoa"
312
500
  },
313
501
  "to-TO": {
314
- "name": "Tongan"
502
+ "name": "Tongan",
503
+ "english": "Tongan",
504
+ "native": "Lea fakatonga"
315
505
  },
316
506
  "st-LS": {
317
- "name": "Sotho"
507
+ "name": "Sotho",
508
+ "english": "Sotho",
509
+ "native": "Sesotho"
318
510
  },
319
511
  "tn-BW": {
320
- "name": "Tswana"
512
+ "name": "Tswana",
513
+ "english": "Tswana",
514
+ "native": "Setswana"
321
515
  },
322
516
  "ss-SZ": {
323
- "name": "Swati"
517
+ "name": "Swati",
518
+ "english": "Swati",
519
+ "native": "SiSwati"
324
520
  },
325
521
  "ve-ZA": {
326
- "name": "Venda"
522
+ "name": "Venda",
523
+ "english": "Venda",
524
+ "native": "Tshivenḓa"
327
525
  },
328
526
  "nr-ZA": {
329
- "name": "Ndebele"
527
+ "name": "Ndebele",
528
+ "english": "Ndebele",
529
+ "native": "IsiNdebele"
330
530
  },
331
531
  "nd-ZW": {
332
- "name": "Ndebele"
532
+ "name": "Ndebele",
533
+ "english": "Ndebele",
534
+ "native": "IsiNdebele"
333
535
  },
334
536
  "ts-ZA": {
335
- "name": "Tsonga"
537
+ "name": "Tsonga",
538
+ "english": "Tsonga",
539
+ "native": "XiTsonga"
336
540
  },
337
541
  "lg-UG": {
338
- "name": "Luganda"
542
+ "name": "Luganda",
543
+ "english": "Luganda",
544
+ "native": "Luganda"
339
545
  },
340
546
  "ln-CD": {
341
- "name": "Lingala"
547
+ "name": "Lingala",
548
+ "english": "Lingala",
549
+ "native": "Lingála"
342
550
  },
343
551
  "bm-ZM": {
344
- "name": "Bemba"
552
+ "name": "Bemba",
553
+ "english": "Bemba",
554
+ "native": "Bamanakan"
345
555
  },
346
556
  "ny-MW": {
347
- "name": "Chichewa"
557
+ "name": "Chichewa",
558
+ "english": "Chichewa",
559
+ "native": "Chichewa"
348
560
  },
349
561
  "wo-SN": {
350
- "name": "Wolof"
562
+ "name": "Wolof",
563
+ "english": "Wolof",
564
+ "native": "Wolof"
351
565
  },
352
566
  "sg-CF": {
353
- "name": "Sango"
567
+ "name": "Sango",
568
+ "english": "Sango",
569
+ "native": "Sängö"
354
570
  },
355
571
  "es-AR": {
356
572
  "name": "Spanish",
357
- "variant": "Argentina"
573
+ "variant": "Argentina",
574
+ "english": "Spanish",
575
+ "native": "Español"
358
576
  },
359
577
  "es-CO": {
360
578
  "name": "Spanish",
361
- "variant": "Colombia"
579
+ "variant": "Colombia",
580
+ "english": "Spanish",
581
+ "native": "Español"
362
582
  },
363
583
  "en-CA": {
364
584
  "name": "English",
365
- "variant": "Canada"
585
+ "variant": "Canada",
586
+ "english": "English",
587
+ "native": "English"
366
588
  },
367
589
  "en-AU": {
368
590
  "name": "English",
369
- "variant": "Australia"
591
+ "variant": "Australia",
592
+ "english": "English",
593
+ "native": "English"
370
594
  },
371
595
  "zh-HK": {
372
596
  "name": "Chinese",
373
- "variant": "Traditional, Hong Kong"
597
+ "variant": "Traditional, Hong Kong",
598
+ "english": "Chinese",
599
+ "native": "中文"
374
600
  },
375
601
  "ta-LK": {
376
602
  "name": "Tamil",
377
- "variant": "Sri Lanka"
603
+ "variant": "Sri Lanka",
604
+ "english": "Tamil",
605
+ "native": "தமிழ்"
378
606
  },
379
607
  "bn-IN": {
380
608
  "name": "Bengali",
381
- "variant": "India"
609
+ "variant": "India",
610
+ "english": "Bengali",
611
+ "native": "বাংলা"
382
612
  },
383
613
  "pa-PK": {
384
614
  "name": "Punjabi",
385
- "variant": "Pakistan"
615
+ "variant": "Pakistan",
616
+ "english": "Punjabi",
617
+ "native": "پنجابی"
386
618
  },
387
619
  "ku-TR": {
388
620
  "name": "Kurdish",
389
- "variant": "Turkey"
621
+ "variant": "Turkey",
622
+ "english": "Kurdish",
623
+ "native": "Kurdî (kurmancî)"
390
624
  },
391
625
  "ku-IQ": {
392
626
  "name": "Kurdish",
393
- "variant": "Iraq"
627
+ "variant": "Iraq",
628
+ "english": "Kurdish",
629
+ "native": "Kurdî (kurmancî)"
394
630
  },
395
631
  "as-IN": {
396
- "name": "Assamese"
632
+ "name": "Assamese",
633
+ "english": "Assamese",
634
+ "native": "অসমীয়া"
397
635
  },
398
636
  "mai-IN": {
399
- "name": "Maithili"
637
+ "name": "Maithili",
638
+ "english": "Maithili",
639
+ "native": "मैथिली"
400
640
  },
401
641
  "sat-IN": {
402
- "name": "Santali"
642
+ "name": "Santali",
643
+ "english": "Santali",
644
+ "native": "ᱥᱟᱱᱛᱟᱲᱤ"
403
645
  },
404
646
  "brx-IN": {
405
- "name": "Bodo"
647
+ "name": "Bodo",
648
+ "english": "Bodo",
649
+ "native": "बर’"
406
650
  }
407
651
  }
408
652
  }
@@ -5,6 +5,7 @@ import assert from 'node:assert/strict'
5
5
 
6
6
  const template = fileURLToPath(new URL('../assets/monorepo/', import.meta.url))
7
7
  const backend = fileURLToPath(new URL('../assets/blank/backend/', import.meta.url))
8
+ const sourceText = asset => typeof asset?.text === 'string' && asset.text.trim() ? asset.text.trim() : ''
8
9
  const json = async (file, value) => {
9
10
  await mkdir(path.dirname(file), { recursive: true })
10
11
  await writeFile(file, JSON.stringify(value, null, 4) + '\n')
@@ -16,6 +17,7 @@ const absent = async file => {
16
17
  }
17
18
  const validate = async (input, domain) => {
18
19
  assert.equal(input.domain, domain, 'domain_mismatch')
20
+ assert(input.codeOnly === undefined || typeof input.codeOnly === 'boolean', 'invalid_code_only')
19
21
  assert(/^[a-z0-9]+(?:[.-][a-z0-9]+)+$/.test(domain), 'invalid_domain')
20
22
  assert(typeof input.group === 'string' && (domain === input.group || domain.endsWith('.' + input.group)), 'invalid_group')
21
23
  assert(path.isAbsolute(input.websites), 'websites_path_required')
@@ -26,6 +28,11 @@ const validate = async (input, domain) => {
26
28
  assert(asset && path.isAbsolute(asset.file), name + '_file_required')
27
29
  assert(/\.(svg|png)$/.test(asset.file), name + '_format_invalid')
28
30
  assert((await stat(asset.file)).isFile(), name + '_file_missing')
31
+ if (asset.inverseFile !== undefined) {
32
+ assert(path.isAbsolute(asset.inverseFile), name + '_inverse_file_required')
33
+ assert(/\.(svg|png)$/.test(asset.inverseFile), name + '_inverse_format_invalid')
34
+ assert((await stat(asset.inverseFile)).isFile(), name + '_inverse_file_missing')
35
+ }
29
36
  }
30
37
  assert(input.trademark.width > 0 && input.trademark.height > 0, 'trademark_dimensions_required')
31
38
  assert(input.logo.size > 0 && typeof input.logo.visible === 'boolean', 'logo_settings_required')
@@ -36,30 +43,54 @@ const generate = async ({ domain, config }) => {
36
43
  await validate(input, domain)
37
44
  const code = path.join(input.websites, 'Code', input.group, domain)
38
45
  const data = path.join(input.websites, 'Data', input.group, domain)
39
- await absent(code)
40
- await absent(data)
46
+ const source = input.codeOnly ? JSON.parse(await readFile(path.join(data, '@origin/input.json'), 'utf8')) : { original: input.language, locales: [input.language] }
47
+ assert(Array.isArray(source.locales) && source.locales.length > 0 && source.locales.every(locale => /^[a-z]{2,3}-[A-Za-z]{2,4}$/.test(locale)) && new Set(source.locales).size === source.locales.length, 'invalid_source_locales')
48
+ assert(source.original === input.language && source.locales.includes(input.language), 'source_language_mismatch')
49
+ if (input.codeOnly) {
50
+ assert((await stat(data)).isDirectory(), 'source_data_required')
51
+ for (const target of ['frontend', 'backend', '.env', '.env.test', '.env.next', '.env.live', 'package.json', 'root.config.json', 'route-map.json', 'bootstrap.json']) {
52
+ await absent(path.join(code, target))
53
+ }
54
+ } else {
55
+ await absent(code)
56
+ await absent(data)
57
+ }
41
58
  await mkdir(path.dirname(code), { recursive: true })
42
59
  await cp(path.join(template, 'frontend'), path.join(code, 'frontend'), { recursive: true, errorOnExist: true, force: false })
43
60
  await cp(backend, path.join(code, 'backend'), { recursive: true, errorOnExist: true, force: false })
44
- await cp(path.join(template, 'sources'), data, { recursive: true, errorOnExist: true, force: false })
45
- for (const folder of ['@origin', 'data', 'page', 'media/trademarks', 'fonts', 'site']) await mkdir(path.join(data, folder), { recursive: true })
61
+ if (!input.codeOnly) {
62
+ await cp(path.join(template, 'sources'), data, { recursive: true, errorOnExist: true, force: false })
63
+ for (const folder of ['@origin', 'data', 'page', 'media/trademarks', 'fonts', 'site']) await mkdir(path.join(data, folder), { recursive: true })
64
+ }
65
+ await json(path.join(code, 'frontend/root/content.locales.json'), source.locales)
46
66
  const site = { domain, title: input.title, language: input.language }
47
67
  for (const name of ['trademark', 'logo']) {
48
- const source = input[name], file = name + path.extname(source.file)
49
- await cp(source.file, path.join(data, 'media/trademarks', file))
68
+ const source = input[name]
69
+ const canonical = name + path.extname(source.file)
70
+ const inverseSource = source.inverseFile || source.file
71
+ const inverse = source.inverseFile ? name + '.inverse' + path.extname(source.inverseFile) : canonical
72
+ if (!input.codeOnly) {
73
+ await cp(source.file, path.join(data, 'media/trademarks', canonical))
74
+ if (source.inverseFile) await cp(inverseSource, path.join(data, 'media/trademarks', inverse))
75
+ }
50
76
  const publicFolder = path.join(code, 'frontend/assets/media/trademarks')
51
77
  await mkdir(publicFolder, { recursive: true })
52
- await cp(source.file, path.join(publicFolder, file))
53
- site[name] = { ...source, src: './media/trademarks/' + file }
78
+ await cp(source.file, path.join(publicFolder, canonical))
79
+ if (source.inverseFile) await cp(inverseSource, path.join(publicFolder, inverse))
80
+ site[name] = { ...source, canonical: './media/trademarks/' + canonical, inverse: './media/trademarks/' + inverse }
54
81
  delete site[name].file
82
+ delete site[name].inverseFile
55
83
  }
56
- await json(path.join(code, 'frontend/configure/trademark.json'), { canonical: path.basename(site.trademark.src), inverse: path.basename(site.trademark.src), X: site.trademark.width, Y: site.trademark.height })
57
- await json(path.join(code, 'frontend/configure/logo.json'), { canonical: path.basename(site.logo.src), inverse: path.basename(site.logo.src), XY: site.logo.size })
84
+ await json(path.join(code, 'frontend/configure/trademark.json'), { canonical: path.basename(site.trademark.canonical), inverse: path.basename(site.trademark.inverse), X: site.trademark.width, Y: site.trademark.height, ...(sourceText(input.trademark) ? { text: sourceText(input.trademark) } : {}) })
85
+ await json(path.join(code, 'frontend/configure/logo.json'), { canonical: path.basename(site.logo.canonical), inverse: path.basename(site.logo.inverse), XY: site.logo.size })
58
86
  for (const part of ['frontend', 'backend']) {
59
87
  const file = path.join(code, part, 'package.json')
60
88
  const content = JSON.parse(await readFile(file, 'utf8'))
61
89
  content.name = '@' + domain + '/' + part
62
- if (part === 'frontend') content.scripts.build = 'style && vite build'
90
+ if (part === 'frontend') {
91
+ content.scripts.build = 'style && vite build'
92
+ content.homepage = 'https://' + domain
93
+ }
63
94
  await json(file, content)
64
95
  if (part === 'backend') await json(path.join(code, part, 'package-lock.json'), {
65
96
  name: content.name, version: content.version, lockfileVersion: 3, requires: true,
@@ -68,37 +99,39 @@ const generate = async ({ domain, config }) => {
68
99
  }
69
100
  const html = path.join(code, 'frontend/index.html')
70
101
  const title = input.title.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('"', '&quot;')
71
- await writeFile(html, (await readFile(html, 'utf8')).replace('<title></title>', '<title>' + title + '</title>'))
102
+ await writeFile(html, (await readFile(html, 'utf8')).replace('<title></title>', '<title>' + title + '</title>').replace('<meta content="" name="apple-mobile-web-app-title" />', '<meta content="' + title + '" name="apple-mobile-web-app-title" />'))
72
103
  for (const environment of ['', 'test', 'next', 'live']) {
73
104
  const prefix = environment === 'test' || environment === 'next' ? environment : ''
74
105
  const siteOrigin = environment ? 'https://' + (prefix ? prefix + '.' : '') + domain : 'http://127.0.0.1:8080'
75
106
  const cdnOrigin = 'https://cdn.' + domain
76
107
  await writeFile(path.join(code, environment ? '.env.' + environment : '.env'), 'PLATFORM=web\nCLIENT_ID=' + domain + '\nSITE_ORIGIN=' + siteOrigin + '\nCDN0=' + cdnOrigin + (prefix ? '/' + prefix : '') + '\n')
77
108
  }
78
- await json(path.join(code, 'package.json'), { name: domain, version: '1.0.0', private: true, type: 'module', scripts: { build: 'npm --prefix frontend run build' }, devDependencies: { '@fullstackunicorn/root': '3.0.0' } })
109
+ await json(path.join(code, 'package.json'), { name: domain, version: '1.0.0', private: true, type: 'module', scripts: { build: 'npm --prefix frontend run build' }, devDependencies: { '@fullstackunicorn/root': '3.1.0' } })
79
110
  await json(path.join(code, 'root.config.json'), input)
80
- await json(path.join(data, '@origin/bootstrap.json'), { version: 3, domain, language: input.language, title: input.title, pages: ['home'], trademark: site.trademark, logo: site.logo })
81
- await json(path.join(data, '@origin/input.json'), {
82
- mode: 'direct', original: input.language, locales: [input.language],
83
- sourceSets: [], compositions: [], components: { home: 'Home' }
84
- })
85
- await json(path.join(data, '@origin/covers.json'), [])
86
- await json(path.join(data, 'page/home/logic.json'), { calls: {} })
87
- await json(path.join(data, 'page/home/' + input.language + '.schema.json'), {
88
- '@context': 'https://schema.org', '@graph': [{
89
- '@type': 'WebPage', '@id': 'https://' + domain + '/' + input.language + '/home#page',
90
- url: 'https://' + domain + '/' + input.language + '/home', name: input.title,
91
- inLanguage: input.language
92
- }]
93
- })
94
- const logicFile = path.join(data, 'site/root/@logic.json')
95
- const logic = JSON.parse(await readFile(logicFile, 'utf8'))
96
- logic['@lang'] = input.language
97
- logic['@langs'] = []
98
- await json(logicFile, logic)
99
- await json(path.join(data, 'site/settings.json'), site)
111
+ if (!input.codeOnly) {
112
+ await json(path.join(data, '@origin/bootstrap.json'), { version: 3, domain, language: input.language, title: input.title, pages: ['home'], trademark: site.trademark, logo: site.logo })
113
+ await json(path.join(data, '@origin/input.json'), {
114
+ mode: 'direct', original: input.language, locales: [input.language],
115
+ sourceSets: [], compositions: [], components: { home: 'Home' }
116
+ })
117
+ await json(path.join(data, '@origin/covers.json'), [])
118
+ await json(path.join(data, 'page/home/logic.json'), { calls: {} })
119
+ await json(path.join(data, 'page/home/' + input.language + '.schema.json'), {
120
+ '@context': 'https://schema.org', '@graph': [{
121
+ '@type': 'WebPage', '@id': 'https://' + domain + '/' + input.language + '/home#page',
122
+ url: 'https://' + domain + '/' + input.language + '/home', name: input.title,
123
+ inLanguage: input.language
124
+ }]
125
+ })
126
+ const logicFile = path.join(data, 'site/root/@logic.json')
127
+ const logic = JSON.parse(await readFile(logicFile, 'utf8'))
128
+ logic['@lang'] = input.language
129
+ logic['@langs'] = []
130
+ await json(logicFile, logic)
131
+ await json(path.join(data, 'site/settings.json'), site)
132
+ }
100
133
  await json(path.join(code, 'route-map.json'), { version: 1, routes: {} })
101
- await json(path.join(code, 'bootstrap.json'), { generator: '@fullstackunicorn/root', version: '3.0.0', code, data })
134
+ await json(path.join(code, 'bootstrap.json'), { generator: '@fullstackunicorn/root', version: '3.1.0', code, data })
102
135
  return { code, data }
103
136
  }
104
137
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.0",
2
+ "version": "3.1.0",
3
3
  "name": "@fullstackunicorn/root",
4
4
  "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
5
  "description": "Create a build-only website monorepo with original brand components and Websites source data",
@@ -14,7 +14,8 @@
14
14
  "modules/bootstrap.js",
15
15
  "assets/blank/backend",
16
16
  "assets/monorepo",
17
- "scripts/check-model.mjs"
17
+ "scripts/check-model.mjs",
18
+ "scripts/check-platform.mjs"
18
19
  ],
19
20
  "bin": {
20
21
  "root": "./index.cmd.js"
@@ -38,8 +39,10 @@
38
39
  "scripts": {
39
40
  "test": "node --test tests/*.test.js"
40
41
  },
41
- "dependencies": {},
42
- "devDependencies": {},
42
+ "dependencies": {
43
+ "@babel/parser": "^8.1.2",
44
+ "@babel/traverse": "^8.1.2"
45
+ },
43
46
  "engines": {
44
47
  "node": ">=22.12.0"
45
48
  },
package/package.md CHANGED
@@ -1,20 +1,71 @@
1
- # @fullstackunicorn/root 2.0.0
1
+ # @fullstackunicorn/root 3.1.0
2
2
 
3
- Generate a website monorepo with a white home page and the supplied brand assets.
3
+ Generate a build-only website monorepo from the canonical model.
4
4
 
5
5
  ```sh
6
- root generate andreas.adwiser.me --config /inputs/site.json
6
+ root generate example.test --config /inputs/site.json
7
+ ```
8
+
9
+ From this package checkout the equivalent command is:
10
+
11
+ ```sh
12
+ node index.cmd.js generate example.test --config /inputs/site.json
7
13
  ```
8
14
 
9
15
  Input: `domain`, `group`, absolute `websites` directory, `title`, BCP-47 `language`,
10
- `trademark: {file, width, height}` and `logo: {file, size, visible}`.
16
+ `trademark: {file, inverseFile?, width, height, text?}` and
17
+ `logo: {file, inverseFile?, size, visible}`.
11
18
  Brand files are SVG or PNG. Paths refer to the Linux build environment.
12
19
 
13
- Output: `Code/<group>/<domain>` and `Data/<group>/<domain>`.
20
+ Default output: `Code/<group>/<domain>` and `Data/<group>/<domain>`.
14
21
  Existing destinations are rejected. Inputs are validated before files are written.
15
22
 
16
- Run `npm ci` after the first installation has generated the lockfile, then
17
- `npm run build` inside `frontend`. The build runs the Style compiler and Vite.
18
- Serve `dist` with Nginx. The template defines no HMR, development server or preview command.
23
+ Set `codeOnly: true` to bootstrap code for already acquired source data.
24
+ `Data/<group>/<domain>` must exist and is left byte-for-byte unchanged.
25
+ Existing `Code/<group>/<domain>/@feed` and other non-generated material are preserved.
26
+ All generated root destinations must be absent: `frontend`, `backend`, `.env`,
27
+ `.env.test`, `.env.next`, `.env.live`, `package.json`, `root.config.json`,
28
+ `route-map.json`, and `bootstrap.json`. Any collision rejects the operation before writing.
29
+ Brand assets are still copied into the frontend build assets. In this mode the
30
+ project feed supplies the CDN brand assets, site initialization data, lookups,
31
+ fonts, pages and schema in Data; the bootstrap does not replace acquired sources.
32
+
33
+ Run installation and build in Linux with Node >=22.12.0.
34
+ Use `npm install` for the first frontend installation, then `npm ci` with the
35
+ resulting lockfile. Check the generated frontend before building:
36
+
37
+ ```sh
38
+ node scripts/check-model.mjs /Websites/Code/example.test/example.test/frontend --platform
39
+ npm --prefix /Websites/Code/example.test/example.test/frontend run build
40
+ ```
41
+
42
+ The build runs the Style compiler and Vite. Serve `dist` with Nginx.
43
+ The template defines no HMR, development server or preview command.
19
44
  Use the same build for test, next and live; choose the environment at container startup.
20
45
  Synchronize Data through Websites, generate, and publish through the Websites BFF/API or MCP.
46
+
47
+ The generated frontend uses media sizes contract version 1 (`S1`–`S3`,
48
+ `M1`–`M6`, `L1`–`L3`) and the extensionless public version route
49
+ `${CDN0}/version/:lang`. Per-site loads resolve below
50
+ `${CDN0}/data/load/:id/`; the legacy `preload.json` URL is not generated.
51
+
52
+ ## Locale and identity configuration
53
+
54
+ Before writing Code, bootstrap validates the locale contract. A fresh project uses
55
+ `[language]`. With `codeOnly: true`, bootstrap reads `Data/<group>/<domain>/@origin/input.json`
56
+ and writes its `locales` array to `frontend/root/content.locales.json`. The source
57
+ `original` must equal the requested `language`, and that language must be present
58
+ in the unique, valid locale list. A mismatch rejects bootstrap before writing.
59
+ The acquisition feed owns translated page data and site-root UI for these locales.
60
+
61
+ `title` supplies the Apple web-app title in `frontend/index.html`, escaped for HTML.
62
+ The model contains no project-specific Apple title. Per-page HTML titles and schema
63
+ remain supplied by Websites from page schema; they are not substituted with this
64
+ project-level identity setting.
65
+
66
+ Platform checks parse JavaScript/JSX and resolve lexical scope. Locally bound names
67
+ such as `document` and object properties such as `labels.document` are ordinary
68
+ application data. Unbound browser globals, DOM JSX tags and browser/CSS imports
69
+ outside imports remain errors. Supply a project's actual Native imports directory
70
+ with `--native /project/@feed/native/imports`; those adapters supplement the
71
+ canonical model adapters without disabling any platform check.
@@ -2,9 +2,15 @@ import { readFile, readdir } from 'node:fs/promises'
2
2
  import { createHash } from 'node:crypto'
3
3
  import path from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
+ import { platformIssues } from './check-platform.mjs'
5
6
 
6
7
  const model = fileURLToPath(new URL('../assets/monorepo/', import.meta.url))
7
- const target = path.resolve(process.argv.slice(2).find(value => !value.startsWith('--')) || path.join(model, 'frontend'))
8
+ const args = process.argv.slice(2)
9
+ const nativeFlag = args.indexOf('--native')
10
+ if (nativeFlag !== -1 && (!args[nativeFlag + 1] || args[nativeFlag + 1].startsWith('--'))) throw new Error('native_path_required')
11
+ const nativePath = nativeFlag === -1 ? null : path.resolve(args[nativeFlag + 1])
12
+ const positional = args.filter((value, index) => !value.startsWith('--') && (nativeFlag === -1 || index !== nativeFlag + 1))
13
+ const target = path.resolve(positional[0] || path.join(model, 'frontend'))
8
14
  const manifest = JSON.parse(await readFile(path.join(model, 'files.json'), 'utf8'))
9
15
  const errors = []
10
16
  for (const item of manifest.files) {
@@ -19,17 +25,13 @@ for (const item of manifest.files) {
19
25
  }
20
26
  }
21
27
  if (process.argv.includes('--platform')) {
22
- const forbidden = /\b(?:window|document|navigator|localStorage|sessionStorage|DOMParser|ResizeObserver|MutationObserver|IntersectionObserver|getComputedStyle)\b|<(?:[a-z][a-z0-9]*)\b|['"](?:react-dom(?:\/[^'"]*)?|react-helmet-async)['"]|import\s+['"][^'"]+\.css['"]/
23
28
  const walk = async (folder, relative = '') => {
24
29
  for (const item of await readdir(folder, { withFileTypes: true })) {
25
30
  if (['node_modules', 'dist', '.devtools', '.git', 'assets', 'style', 'imports'].includes(item.name)) continue
26
31
  const name = path.join(relative, item.name), file = path.join(folder, item.name)
27
32
  if (item.isDirectory()) await walk(file, name)
28
33
  else if (relative && item.name.endsWith('.js')) {
29
- const lines = (await readFile(file, 'utf8')).split('\n')
30
- lines.forEach((line, index) => {
31
- if (!line.trim().startsWith('//') && forbidden.test(line)) errors.push({ code: 'PLATFORM_CODE_OUTSIDE_IMPORTS', path: name, line: index + 1 })
32
- })
34
+ errors.push(...platformIssues(await readFile(file, 'utf8'), name))
33
35
  }
34
36
  }
35
37
  }
@@ -44,6 +46,7 @@ if (process.argv.includes('--platform')) {
44
46
  return files
45
47
  }
46
48
  const native = new Set(await imports(path.join(model, 'native/imports')))
49
+ if (nativePath) for (const name of await imports(nativePath)) native.add(name)
47
50
  for (const name of await imports(path.join(target, 'imports'))) {
48
51
  if (!native.has(name)) errors.push({ code: 'NATIVE_ADAPTER_MISSING', path: 'imports/' + name })
49
52
  }
@@ -0,0 +1,44 @@
1
+ import { parse } from '@babel/parser'
2
+ import traverseModule from '@babel/traverse'
3
+
4
+ const traverse = traverseModule.default || traverseModule
5
+ const globals = new Set(['window', 'document', 'navigator', 'localStorage', 'sessionStorage', 'DOMParser', 'ResizeObserver', 'MutationObserver', 'IntersectionObserver', 'getComputedStyle'])
6
+ const platformImport = value => /^(react-dom(?:\/.*)?|react-helmet-async)$/.test(value) || /\.css(?:[?#].*)?$/.test(value)
7
+
8
+ export const platformIssues = (source, file) => {
9
+ const errors = []
10
+ const lines = new Set()
11
+ const report = node => {
12
+ const line = node.loc.start.line
13
+ if (lines.has(line)) return
14
+ lines.add(line)
15
+ errors.push({ code: 'PLATFORM_CODE_OUTSIDE_IMPORTS', path: file, line })
16
+ }
17
+ let ast
18
+ try { ast = parse(source, { sourceType: 'unambiguous', plugins: ['jsx'] }) }
19
+ catch (error) { return [{ code: 'PLATFORM_PARSE_ERROR', path: file, line: error.loc?.line, message: error.message }] }
20
+ traverse(ast, {
21
+ ReferencedIdentifier(path) {
22
+ if (globals.has(path.node.name) && !path.scope.getBinding(path.node.name)) report(path.node)
23
+ },
24
+ MemberExpression(path) {
25
+ const { object, property, computed } = path.node
26
+ if (object.type !== 'Identifier' || object.name !== 'globalThis' || path.scope.getBinding('globalThis')) return
27
+ const name = computed && property.type === 'StringLiteral' ? property.value : !computed && property.type === 'Identifier' ? property.name : null
28
+ if (globals.has(name)) report(path.node)
29
+ },
30
+ JSXOpeningElement(path) {
31
+ const name = path.node.name
32
+ if (name.type === 'JSXIdentifier' && /^[a-z]/.test(name.name)) report(path.node)
33
+ },
34
+ ImportDeclaration(path) { if (platformImport(path.node.source.value)) report(path.node) },
35
+ ExportNamedDeclaration(path) { if (path.node.source && platformImport(path.node.source.value)) report(path.node) },
36
+ ExportAllDeclaration(path) { if (platformImport(path.node.source.value)) report(path.node) },
37
+ CallExpression(path) {
38
+ const callee = path.node.callee
39
+ const argument = path.node.arguments[0]
40
+ if ((callee.type === 'Import' || callee.type === 'Identifier' && callee.name === 'require' && !path.scope.getBinding('require')) && argument?.type === 'StringLiteral' && platformImport(argument.value)) report(path.node)
41
+ }
42
+ })
43
+ return errors
44
+ }