@maxwellcohen/lastro 0.0.0-stage → 0.0.1

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +324 -2
  3. package/bin/lastro.js +5 -0
  4. package/bin/postinstall.js +6 -0
  5. package/docs/hero.png +0 -0
  6. package/package.json +355 -4
  7. package/pkg/devtools/index.js +15 -0
  8. package/pkg/eslint-config/index.js +123 -0
  9. package/pkg/head/client.js +18 -0
  10. package/pkg/head/index.d.ts +4 -0
  11. package/pkg/head/index.js +30 -0
  12. package/pkg/image/client.js +2 -0
  13. package/pkg/image/index.d.ts +3 -0
  14. package/pkg/image/index.js +2 -0
  15. package/pkg/image/stubs.js +8 -0
  16. package/pkg/image/tnenopmoCsdroW0001erutciP____.client.js +18 -0
  17. package/pkg/image/tnenopmoCsdroW0001erutciP____.js +27 -0
  18. package/pkg/jact/client.js +108 -0
  19. package/pkg/jact/core.js +292 -0
  20. package/pkg/jact/index.d.ts +48 -0
  21. package/pkg/jact/jsx-runtime.d.ts +18 -0
  22. package/pkg/jact/jsx-runtime.js +3 -0
  23. package/pkg/jact/names.js +49 -0
  24. package/pkg/jact/server.js +66 -0
  25. package/pkg/jqueasy/index.d.ts +2 -0
  26. package/pkg/jqueasy/index.js +442 -0
  27. package/pkg/polyfills/es.js +1 -0
  28. package/pkg/polyfills/full.js +1 -0
  29. package/pkg/polyfills/legacy.js +3 -0
  30. package/pkg/polyfills/regenerator.js +1 -0
  31. package/pkg/polyfills/web.js +1 -0
  32. package/pkg/prettier-config/index.json +1 -0
  33. package/pkg/router/client.js +5 -0
  34. package/pkg/router/index.d.ts +6 -0
  35. package/pkg/router/index.js +7 -0
  36. package/pkg/router/stubs.js +12 -0
  37. package/pkg/router/tnenopmoCniahC___.client.js +50 -0
  38. package/pkg/router/tnenopmoCniahC___.js +10 -0
  39. package/pkg/serializer/client.js +24 -0
  40. package/pkg/serializer/index.js +41 -0
  41. package/pkg/starter/README.md +53 -0
  42. package/pkg/starter/lastro-env.d.ts +1 -0
  43. package/pkg/starter/lastro.config.js +9 -0
  44. package/pkg/starter/package.json +47 -0
  45. package/pkg/starter/pages/about.tsx +11 -0
  46. package/pkg/starter/pages/index.tsx +29 -0
  47. package/pkg/starter/pages/posts/[id].server.ts +1 -0
  48. package/pkg/starter/pages/posts/[id].tsx +4 -0
  49. package/pkg/starter/pages/posts.server.ts +1 -0
  50. package/pkg/starter/pages/posts.tsx +16 -0
  51. package/pkg/starter/tsconfig.json +5 -0
  52. package/pkg/telemetry/client.js +11 -0
  53. package/pkg/telemetry/index.js +5 -0
  54. package/pkg/test-utils/index.js +15 -0
  55. package/pkg/thoroughness/client.js +32 -0
  56. package/pkg/thoroughness/index.js +12 -0
  57. package/pkg/tsconfig/tsconfig.json +23 -0
  58. package/pkg/types/index.d.ts +2 -0
  59. package/pkg/types/index.js +2 -0
  60. package/scripts/assemble.cjs +37 -0
  61. package/src/build/assets.js +127 -0
  62. package/src/build/bans-plugin.js +58 -0
  63. package/src/build/graph.js +157 -0
  64. package/src/build/index.js +213 -0
  65. package/src/build/naming-plugin.js +62 -0
  66. package/src/build/routes.js +33 -0
  67. package/src/build/typecheck.js +16 -0
  68. package/src/cli.js +101 -0
  69. package/src/client/boot.js +38 -0
  70. package/src/client/clone.js +10 -0
  71. package/src/client/compare.js +7 -0
  72. package/src/client/config.js +3 -0
  73. package/src/client/copies.js +12 -0
  74. package/src/client/env.js +13 -0
  75. package/src/client/errors.js +11 -0
  76. package/src/client/features.js +101 -0
  77. package/src/client/heartbeat.js +38 -0
  78. package/src/client/idle.js +7 -0
  79. package/src/client/logger.js +12 -0
  80. package/src/client/mount.js +11 -0
  81. package/src/client/ready.js +7 -0
  82. package/src/client/state.js +14 -0
  83. package/src/client/vitals.js +16 -0
  84. package/src/client-runtime/registry.js +46 -0
  85. package/src/create.js +46 -0
  86. package/src/dev.js +36 -0
  87. package/src/guard.js +56 -0
  88. package/src/index.js +8 -0
  89. package/src/postinstall.js +27 -0
  90. package/src/preview.js +66 -0
  91. package/src/server/app.js +201 -0
  92. package/src/server/index.js +34 -0
  93. package/src/server/template.csr.html +48 -0
  94. package/src/server/template.html +12 -0
  95. package/src/shared/app-require.js +18 -0
  96. package/src/shared/audit.js +34 -0
  97. package/src/shared/bans.js +102 -0
  98. package/src/shared/config.js +40 -0
  99. package/src/shared/naming.js +82 -0
  100. package/src/shared/signal.js +36 -0
  101. package/src/util/natives-node.js +20 -0
  102. package/src/util/natives.js +67 -0
  103. package/test/bans.integration.js +97 -0
  104. package/test/bans.test.js +110 -0
  105. package/test/cjs-only.test.js +37 -0
  106. package/test/csr.test.js +61 -0
  107. package/test/guard.test.js +46 -0
  108. package/test/members.test.js +28 -0
  109. package/test/naming.integration.js +73 -0
  110. package/test/naming.test.js +44 -0
  111. package/test/natives.test.js +46 -0
  112. package/test/server.test.js +18 -0
  113. package/test/signal.integration.js +105 -0
  114. package/test/signal.test.js +33 -0
package/package.json CHANGED
@@ -1,6 +1,357 @@
1
1
  {
2
2
  "name": "@maxwellcohen/lastro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Last place, guaranteed. Ships zero speed by default. Please do not use this framework: it is very thorough about being slow.",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "meta-framework",
8
+ "ssr",
9
+ "parody",
10
+ "slow",
11
+ "jquery",
12
+ "left-pad"
13
+ ],
14
+ "type": "commonjs",
15
+ "bin": {
16
+ "lastro": "./bin/lastro.js"
17
+ },
18
+ "main": "./src/index.js",
19
+ "exports": {
20
+ ".": "./src/index.js",
21
+ "./jact": {
22
+ "types": "./pkg/jact/index.d.ts",
23
+ "browser": "./pkg/jact/client.js",
24
+ "require": "./pkg/jact/server.js"
25
+ },
26
+ "./jact/jsx-runtime": {
27
+ "types": "./pkg/jact/jsx-runtime.d.ts",
28
+ "require": "./pkg/jact/jsx-runtime.js"
29
+ },
30
+ "./jqueasy": {
31
+ "types": "./pkg/jqueasy/index.d.ts",
32
+ "require": "./pkg/jqueasy/index.js"
33
+ },
34
+ "./router": {
35
+ "types": "./pkg/router/index.d.ts",
36
+ "browser": "./pkg/router/client.js",
37
+ "require": "./pkg/router/index.js"
38
+ },
39
+ "./image": {
40
+ "types": "./pkg/image/index.d.ts",
41
+ "browser": "./pkg/image/client.js",
42
+ "require": "./pkg/image/index.js"
43
+ },
44
+ "./head": {
45
+ "types": "./pkg/head/index.d.ts",
46
+ "browser": "./pkg/head/client.js",
47
+ "require": "./pkg/head/index.js"
48
+ },
49
+ "./serializer": {
50
+ "browser": "./pkg/serializer/client.js",
51
+ "require": "./pkg/serializer/index.js"
52
+ },
53
+ "./telemetry": {
54
+ "browser": "./pkg/telemetry/client.js",
55
+ "require": "./pkg/telemetry/index.js"
56
+ },
57
+ "./thoroughness": {
58
+ "browser": "./pkg/thoroughness/client.js",
59
+ "require": "./pkg/thoroughness/index.js"
60
+ },
61
+ "./polyfills": "./pkg/polyfills/full.js",
62
+ "./polyfills/full": "./pkg/polyfills/full.js",
63
+ "./polyfills/legacy": "./pkg/polyfills/legacy.js",
64
+ "./devtools": "./pkg/devtools/index.js",
65
+ "./test-utils": "./pkg/test-utils/index.js",
66
+ "./eslint": "./pkg/eslint-config/index.js",
67
+ "./prettier": "./pkg/prettier-config/index.json",
68
+ "./tsconfig.json": "./pkg/tsconfig/tsconfig.json",
69
+ "./types": {
70
+ "types": "./pkg/types/index.d.ts",
71
+ "require": "./pkg/types/index.js"
72
+ },
73
+ "./bans": "./src/shared/bans.js",
74
+ "./naming": "./src/shared/naming.js",
75
+ "./natives": {
76
+ "browser": "./src/util/natives.js",
77
+ "require": "./src/util/natives-node.js"
78
+ },
79
+ "./client/*": "./src/client/*",
80
+ "./package.json": "./package.json",
81
+ "./polyfills/es": "./pkg/polyfills/es.js",
82
+ "./polyfills/web": "./pkg/polyfills/web.js",
83
+ "./polyfills/regenerator": "./pkg/polyfills/regenerator.js",
84
+ "./server": "./src/server/index.js",
85
+ "./build": "./src/build/index.js"
86
+ },
87
+ "engines": {
88
+ "node": ">=26.13.0"
89
+ },
90
+ "publishConfig": {
91
+ "access": "public"
92
+ },
93
+ "scripts": {
94
+ "postinstall": "node ./bin/postinstall.js",
95
+ "prepack": "node ./scripts/assemble.cjs",
96
+ "pretest": "node ./scripts/assemble.cjs",
97
+ "test": "node test/guard.test.js && node test/signal.test.js && node test/bans.test.js && node test/naming.test.js && node test/natives.test.js && node test/members.test.js && node test/server.test.js && node test/csr.test.js && node test/cjs-only.test.js",
98
+ "test:integration": "node test/signal.integration.js && node test/bans.integration.js && node test/naming.integration.js",
99
+ "build": "node ./scripts/assemble.cjs",
100
+ "lint": "node test/cjs-only.test.js"
101
+ },
102
+ "dependencies": {
103
+ "@babel/core": "7.24.4",
104
+ "@babel/preset-env": "7.24.4",
105
+ "@babel/preset-react": "7.24.1",
106
+ "@babel/preset-typescript": "7.24.1",
107
+ "@fontsource/roboto": "5.0.12",
108
+ "@swc/core": "1.4.12",
109
+ "@swc/core-legacy": "npm:@swc/core@1.3.100",
110
+ "ajv": "8.12.0",
111
+ "ajv-legacy": "npm:ajv@6.12.6",
112
+ "ansi-regex": "5.0.1",
113
+ "ansi-regex-legacy": "npm:ansi-regex@2.1.1",
114
+ "ansi-styles": "4.3.0",
115
+ "ansi-styles-legacy": "npm:ansi-styles@2.2.1",
116
+ "arr-filter": "1.1.2",
117
+ "arr-map": "2.0.2",
118
+ "array-every": "0.1.2",
119
+ "array-find-index": "1.0.2",
120
+ "array-includes": "3.1.8",
121
+ "array-slice": "1.1.0",
122
+ "array-uniq": "1.0.3",
123
+ "array.prototype.flat": "1.3.2",
124
+ "array.prototype.flatmap": "1.3.2",
125
+ "arrify": "2.0.1",
126
+ "async": "3.2.6",
127
+ "async-legacy": "npm:async@1.5.2",
128
+ "axios": "1.22.0",
129
+ "axios-legacy": "npm:axios@0.36.0",
130
+ "babel-polyfill": "6.26.0",
131
+ "bluebird": "3.7.2",
132
+ "bluebird-legacy": "npm:bluebird@2.11.0",
133
+ "body-parser": "2.2.0",
134
+ "body-parser-legacy": "npm:body-parser@1.20.9",
135
+ "braces": "3.0.3",
136
+ "camelcase": "6.3.0",
137
+ "camelcase-legacy": "npm:camelcase@4.1.0",
138
+ "chalk": "4.1.2",
139
+ "chalk-legacy": "npm:chalk@1.1.3",
140
+ "cheerio": "1.0.0",
141
+ "chokidar": "4.0.3",
142
+ "chokidar-legacy": "npm:chokidar@3.6.0",
143
+ "classnames": "2.5.1",
144
+ "classnames-legacy": "npm:classnames@2.2.6",
145
+ "cli-color": "2.0.4",
146
+ "colors": "1.4.0",
147
+ "colors-legacy": "npm:colors@1.0.3",
148
+ "commander": "9.5.0",
149
+ "commander-legacy": "npm:commander@2.20.3",
150
+ "concat-map": "0.0.1",
151
+ "concat-stream": "2.0.0",
152
+ "concat-stream-legacy": "npm:concat-stream@1.6.2",
153
+ "cookie": "0.6.0",
154
+ "cookie-legacy": "npm:cookie@0.4.2",
155
+ "core-js": "3.50.0",
156
+ "core-js-legacy": "npm:core-js@2.6.12",
157
+ "cosmiconfig": "8.3.6",
158
+ "cross-spawn": "7.0.6",
159
+ "cross-spawn-legacy": "npm:cross-spawn@6.0.10",
160
+ "date-fns": "3.6.0",
161
+ "date-fns-legacy": "npm:date-fns@1.30.1",
162
+ "dayjs": "1.11.10",
163
+ "dayjs-legacy": "npm:dayjs@1.8.36",
164
+ "debug": "4.3.4",
165
+ "debug-legacy": "npm:debug@2.6.9",
166
+ "diff": "5.2.0",
167
+ "diff-legacy": "npm:diff@3.5.0",
168
+ "dotenv": "16.4.5",
169
+ "ejs": "3.1.10",
170
+ "ends-with": "0.2.0",
171
+ "esbuild": "0.20.2",
172
+ "esbuild-legacy": "npm:esbuild@0.17.19",
173
+ "escape-string-regexp": "4.0.0",
174
+ "escape-string-regexp-legacy": "npm:escape-string-regexp@1.0.5",
175
+ "eslint": "8.57.0",
176
+ "execa": "5.1.1",
177
+ "execa-legacy": "npm:execa@1.0.0",
178
+ "express": "5.1.0",
179
+ "express-legacy": "npm:express@4.22.3",
180
+ "fast-glob": "3.3.2",
181
+ "fast-glob-legacy": "npm:fast-glob@3.3.2",
182
+ "form-data": "4.0.0",
183
+ "form-data-legacy": "npm:form-data@2.5.6",
184
+ "fromentries": "1.3.2",
185
+ "fs-extra": "11.2.0",
186
+ "fs-extra-legacy": "npm:fs-extra@0.30.0",
187
+ "glob": "8.1.0",
188
+ "globalthis": "1.0.4",
189
+ "got": "11.8.6",
190
+ "got-legacy": "npm:got@6.7.1",
191
+ "graceful-fs": "4.2.11",
192
+ "graceful-fs-legacy": "npm:graceful-fs@3.0.12",
193
+ "handlebars": "4.7.10",
194
+ "has-flag": "4.0.0",
195
+ "has-flag-legacy": "npm:has-flag@1.0.0",
196
+ "has-symbols": "1.0.3",
197
+ "hasown": "2.0.2",
198
+ "iconv-lite": "0.6.3",
199
+ "iconv-lite-legacy": "npm:iconv-lite@0.4.24",
200
+ "index-of": "0.2.0",
201
+ "inherits": "2.0.4",
202
+ "inherits-legacy": "npm:inherits@2.0.3",
203
+ "inquirer": "8.2.6",
204
+ "is-even": "1.0.0",
205
+ "is-even-legacy": "npm:is-even@0.1.2",
206
+ "is-function": "1.0.2",
207
+ "is-number": "7.0.0",
208
+ "is-odd": "3.0.1",
209
+ "is-odd-legacy": "npm:is-odd@1.0.0",
210
+ "is-plain-object": "5.0.0",
211
+ "isarray": "2.0.5",
212
+ "isarray-legacy": "npm:isarray@1.0.0",
213
+ "js-yaml": "4.1.0",
214
+ "js-yaml-legacy": "npm:js-yaml@3.15.2",
215
+ "kind-of": "6.0.3",
216
+ "last-index-of": "0.1.0",
217
+ "left-pad": "1.3.0",
218
+ "left-pad-legacy": "npm:left-pad@0.0.3",
219
+ "lightningcss": "1.24.1",
220
+ "lodash": "4.18.1",
221
+ "lodash.escaperegexp": "4.1.2",
222
+ "lodash.includes": "4.3.0",
223
+ "lodash.trim": "4.5.1",
224
+ "loose-envify": "1.4.0",
225
+ "loose-envify-legacy": "npm:loose-envify@1.3.1",
226
+ "lru-cache": "6.0.0",
227
+ "lru-cache-legacy": "npm:lru-cache@4.1.5",
228
+ "marked": "12.0.1",
229
+ "marked-legacy": "npm:marked@4.3.0",
230
+ "mime": "3.0.0",
231
+ "mime-legacy": "npm:mime@1.6.0",
232
+ "mime-types": "2.1.35",
233
+ "mime-types-legacy": "npm:mime-types@2.1.18",
234
+ "minimatch": "5.1.6",
235
+ "minimatch-legacy": "npm:minimatch@3.1.5",
236
+ "minimist": "1.2.8",
237
+ "minimist-legacy": "npm:minimist@0.2.4",
238
+ "mkdirp": "1.0.4",
239
+ "mkdirp-legacy": "npm:mkdirp@0.5.6",
240
+ "moment": "2.30.1",
241
+ "moment-legacy": "npm:moment@2.29.4",
242
+ "ms": "2.1.3",
243
+ "ms-legacy": "npm:ms@0.7.3",
244
+ "node-fetch": "2.7.0",
245
+ "node-fetch-legacy": "npm:node-fetch@2.7.0",
246
+ "number-is-integer": "1.0.1",
247
+ "number-is-nan": "1.0.1",
248
+ "object-assign": "4.1.1",
249
+ "object-assign-legacy": "npm:object-assign@3.0.0",
250
+ "object-keys": "1.1.1",
251
+ "object.assign": "4.1.5",
252
+ "object.entries": "1.1.8",
253
+ "object.values": "1.2.0",
254
+ "onnxruntime-node": "1.31.1",
255
+ "pad-left": "2.1.0",
256
+ "picomatch": "4.0.2",
257
+ "picomatch-legacy": "npm:picomatch@2.3.2",
258
+ "prettier": "3.2.5",
259
+ "prettier-legacy": "npm:prettier@1.19.1",
260
+ "promise.allsettled": "1.0.7",
261
+ "prop-types": "15.8.1",
262
+ "prop-types-legacy": "npm:prop-types@15.6.2",
263
+ "punycode": "2.3.1",
264
+ "punycode-legacy": "npm:punycode@1.4.1",
265
+ "q": "1.5.1",
266
+ "q-legacy": "npm:q@0.9.7",
267
+ "qs": "6.14.0",
268
+ "qs-legacy": "npm:qs@6.5.3",
269
+ "readable-stream": "3.6.2",
270
+ "readable-stream-legacy": "npm:readable-stream@2.3.8",
271
+ "regenerator-runtime": "0.14.1",
272
+ "regenerator-runtime-legacy": "npm:regenerator-runtime@0.11.1",
273
+ "repeat-string": "1.6.1",
274
+ "rimraf": "3.0.2",
275
+ "rimraf-legacy": "npm:rimraf@2.7.1",
276
+ "rxjs": "7.8.1",
277
+ "rxjs-legacy": "npm:rxjs@5.5.12",
278
+ "safe-buffer": "5.2.1",
279
+ "safe-buffer-legacy": "npm:safe-buffer@5.1.2",
280
+ "semver": "7.6.0",
281
+ "semver-legacy": "npm:semver@5.7.2",
282
+ "sharp": "0.35.6",
283
+ "starts-with": "1.0.2",
284
+ "string.prototype.padstart": "3.1.6",
285
+ "string.prototype.replaceall": "1.0.10",
286
+ "string.prototype.trim": "1.2.9",
287
+ "string_decoder": "1.3.0",
288
+ "string_decoder-legacy": "npm:string_decoder@0.10.31",
289
+ "strip-ansi": "6.0.1",
290
+ "strip-ansi-legacy": "npm:strip-ansi@3.0.1",
291
+ "supports-color": "7.2.0",
292
+ "supports-color-legacy": "npm:supports-color@2.0.0",
293
+ "terser": "5.30.3",
294
+ "through2": "4.0.2",
295
+ "through2-legacy": "npm:through2@2.0.5",
296
+ "tough-cookie": "4.1.3",
297
+ "tough-cookie-legacy": "npm:tough-cookie@2.5.0",
298
+ "tslib": "2.6.2",
299
+ "tslib-legacy": "npm:tslib@1.14.1",
300
+ "typescript": "5.4.5",
301
+ "typescript-legacy": "npm:typescript@3.9.10",
302
+ "underscore": "1.13.8",
303
+ "uuid": "9.0.1",
304
+ "uuid-legacy": "npm:uuid@3.4.0",
305
+ "which": "2.0.2",
306
+ "which-legacy": "npm:which@1.3.1",
307
+ "yallist": "4.0.0",
308
+ "yallist-legacy": "npm:yallist@3.1.1",
309
+ "yaml": "2.4.1",
310
+ "yaml-legacy": "npm:yaml@1.10.2",
311
+ "yargs": "17.7.2",
312
+ "yargs-legacy": "npm:yargs@15.4.1"
313
+ },
314
+ "devDependencies": {
315
+ "@types/async": "3.2.24",
316
+ "@types/bluebird": "3.5.42",
317
+ "@types/body-parser": "1.19.5",
318
+ "@types/chalk": "2.2.0",
319
+ "@types/cheerio": "0.22.35",
320
+ "@types/classnames": "2.3.1",
321
+ "@types/cookie": "0.6.0",
322
+ "@types/debug": "4.1.12",
323
+ "@types/diff": "5.0.9",
324
+ "@types/ejs": "3.1.5",
325
+ "@types/express": "4.17.21",
326
+ "@types/fs-extra": "11.0.4",
327
+ "@types/glob": "8.1.0",
328
+ "@types/handlebars": "4.1.0",
329
+ "@types/jquery": "3.5.29",
330
+ "@types/js-yaml": "4.0.9",
331
+ "@types/lodash": "4.17.0",
332
+ "@types/marked": "6.0.0",
333
+ "@types/mime": "3.0.4",
334
+ "@types/minimatch": "5.1.2",
335
+ "@types/minimist": "1.2.5",
336
+ "@types/mkdirp": "1.0.2",
337
+ "@types/moment": "2.13.0",
338
+ "@types/ms": "0.7.34",
339
+ "@types/node": "20.12.7",
340
+ "@types/node-fetch": "2.6.11",
341
+ "@types/prop-types": "15.7.12",
342
+ "@types/q": "1.5.8",
343
+ "@types/qs": "6.9.14",
344
+ "@types/request": "2.48.12",
345
+ "@types/rimraf": "3.0.2",
346
+ "@types/semver": "7.5.8",
347
+ "@types/tough-cookie": "4.0.5",
348
+ "@types/underscore": "1.11.15",
349
+ "@types/uuid": "9.0.8",
350
+ "@types/yaml": "1.9.7",
351
+ "@types/yargs": "17.0.32"
352
+ },
353
+ "repository": {
354
+ "type": "git",
355
+ "url": "git+https://github.com/maxwellcohen/lastro.git"
356
+ }
357
+ }
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+ const clc = require('cli-color')
3
+ const QUIPS = [
4
+ 'tip: the fastest code is the code you never ship. We ship it anyway.',
5
+ 'tip: if it feels slow, congratulations, it is working.',
6
+ 'tip: try turning thoroughness down. (There is no down.)',
7
+ 'tip: benchmarks are just opinions with numbers.',
8
+ 'tip: your node_modules weighs more than your first car.',
9
+ ]
10
+ let n = 0
11
+ function log(step) {
12
+ // Only every fifth message earns a tip. We do not want to be annoying, only slow.
13
+ if (n++ % 5 === 4) console.log(clc.blackBright('[lastro:devtools] ') + QUIPS[(n / 5) % QUIPS.length | 0])
14
+ }
15
+ module.exports = { log }
@@ -0,0 +1,123 @@
1
+ 'use strict'
2
+ const n = require('@maxwellcohen/lastro/natives')
3
+ // Lastro Naming Conventions(TM) for ESLint (flat config). Same rules as `lastro build`.
4
+ const naming = require('@maxwellcohen/lastro/naming')
5
+
6
+ const rule = {
7
+ meta: { type: 'problem', fixable: 'code', schema: [], messages: { violation: '{{ message }}' } },
8
+ create(context) {
9
+ const file = context.filename || context.getFilename()
10
+ const isPage = naming.isPageFile(file)
11
+ const report = (node, message, fix) => context.report({ node, messageId: 'violation', data: { message: message + ' (Other frameworks would have let this slide. Lastro cares too much.)' }, fix })
12
+ const getSourceCode = () => context.sourceCode || context.getSourceCode()
13
+ // --fix: rename the declaration, every reference in this file, and JSX tag usages, to naming.suggest(name) (left-padded).
14
+ const renameFix = (declNode, idNode) => {
15
+ const name = idNode.name
16
+ const next = naming.suggest(name)
17
+ if (next === name || naming.checkName(next).length) return undefined
18
+ return (fixer) => {
19
+ const sourceCode = getSourceCode()
20
+ const variable = sourceCode.getDeclaredVariables(declNode).find((v) => v.name === name)
21
+ if (!variable) return null
22
+ const edits = new Map()
23
+ const add = (node, text) => edits.set(node.range[0] + ':' + node.range[1], fixer.replaceText(node, text))
24
+ const rename = (node) => {
25
+ const parent = node.parent
26
+ if (parent && parent.type === 'Property' && parent.shorthand && parent.value === node) add(node, name + ': ' + next)
27
+ else if (parent && parent.type === 'ExportSpecifier' && parent.local.range[0] === parent.exported.range[0]) edits.set(parent.range.join(':'), fixer.replaceText(parent, next + ' as ' + name))
28
+ else add(node, next)
29
+ }
30
+ variable.identifiers.forEach(rename)
31
+ variable.references.forEach((ref) => rename(ref.identifier))
32
+ // JSX tags are not references to eslint-scope, so walk the tree and resolve each one by scope.
33
+ const resolve = (node) => {
34
+ for (let scope = sourceCode.getScope(node); scope; scope = scope.upper) if (scope.set.has(node.name)) return scope.set.get(node.name)
35
+ return null
36
+ }
37
+ const visit = (node) => {
38
+ if (!node || typeof node.type !== 'string') return
39
+ if ((node.type === 'JSXOpeningElement' || node.type === 'JSXClosingElement') && node.name) {
40
+ let tag = node.name
41
+ while (tag.type === 'JSXMemberExpression') tag = tag.object
42
+ if (tag.type === 'JSXIdentifier' && tag.name === name && resolve(tag) === variable) add(tag, next)
43
+ }
44
+ for (const key of sourceCode.visitorKeys[node.type] || []) {
45
+ const child = node[key]
46
+ if (Array.isArray(child)) child.forEach(visit)
47
+ else visit(child)
48
+ }
49
+ }
50
+ visit(sourceCode.ast)
51
+ return Array.from(edits.values())
52
+ }
53
+ }
54
+ const scopes = new Map()
55
+ const declared = (idNode, parent, declNode) => {
56
+ const name = idNode.name
57
+ if (!naming.isComponentName(name)) return
58
+ const fix = declNode ? renameFix(declNode, idNode) : undefined
59
+ naming.checkName(name).forEach((m) => report(idNode, m, fix))
60
+ const topLevel = parent && parent.type === 'Program'
61
+ if (topLevel) naming.checkFile(name, file, { isPage }).forEach((m) => report(idNode, m))
62
+ const key = parent
63
+ scopes.set(key, [...(scopes.get(key) || []), { name, idNode }])
64
+ }
65
+ const container = (node) => {
66
+ let p = node.parent
67
+ while (p && !n.includes(['Program', 'BlockStatement'], p.type)) p = p.parent
68
+ return p
69
+ }
70
+ return {
71
+ FunctionDeclaration: (node) => node.id && declared(node.id, container(node), node),
72
+ ClassDeclaration: (node) => node.id && declared(node.id, container(node), node),
73
+ VariableDeclarator(node) {
74
+ const init = node.init
75
+ if (node.id.type === 'Identifier' && init && (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression')) declared(node.id, container(node), node)
76
+ },
77
+ JSXOpeningElement(node) {
78
+ if (node.name.type !== 'JSXIdentifier' || !naming.isComponentName(node.name.name)) return
79
+ naming.checkName(node.name.name).forEach((m) => report(node, m))
80
+ },
81
+ 'Program:exit'() {
82
+ for (const list of scopes.values()) {
83
+ for (let i = 1; i < list.length; i++) {
84
+ const problems = naming.checkOrder([list[i - 1].name, list[i].name])
85
+ problems.forEach((m) => report(list[i].idNode, m))
86
+ }
87
+ }
88
+ },
89
+ }
90
+ },
91
+ }
92
+
93
+ // Doing the Opposite(TM): errors when you use the package that e18e recommends instead of the one Lastro prefers.
94
+ const RECOMMENDED_REPLACEMENTS = ['tinyglobby', 'picocolors', 'clsx', 'ofetch', 'nativebird', 'defu', 'tinyexec', 'lilconfig', 'mri', 'sade', 'cleye', 'milliparsec', 'tinyclip', 'bcryptjs', 'fdir', 'nanoid', 'es-toolkit', 'obug']
95
+ const scenicRoute = {
96
+ meta: { type: 'problem', schema: [], messages: { scenic: '{{ name }} detected. Lastro prefers the scenic route.' } },
97
+ create(context) {
98
+ const check = (node, name) => {
99
+ // Subpaths are no escape: "pkg/sub" is still "pkg" (and "@scope/pkg/sub" is still "@scope/pkg").
100
+ const parts = typeof name === 'string' ? name.split('/') : []
101
+ const pkg = parts[0] && parts[0].charAt(0) === '@' ? parts.slice(0, 2).join('/') : parts[0]
102
+ if (typeof name === 'string' && n.includes(RECOMMENDED_REPLACEMENTS, pkg)) context.report({ node, messageId: 'scenic', data: { name: pkg } })
103
+ }
104
+ return {
105
+ ImportDeclaration: (node) => check(node, node.source.value),
106
+ CallExpression(node) {
107
+ if (node.callee.type === 'Identifier' && node.callee.name === 'require' && node.arguments[0]) check(node, node.arguments[0].value)
108
+ },
109
+ }
110
+ },
111
+ }
112
+
113
+ module.exports = [
114
+ {
115
+ files: ['**/*.{js,jsx,ts,tsx}'],
116
+ plugins: { lastro: { rules: { 'component-naming': rule, 'scenic-route': scenicRoute } } },
117
+ rules: {
118
+ 'lastro/component-naming': 'error',
119
+ 'lastro/scenic-route': 'error',
120
+ 'no-restricted-syntax': ['warn', { selector: 'Identifier[name="memo"]', message: 'Memoization is a form of speed, and speed is not welcome here (that is a Lastro problem, not a memoization problem).' }],
121
+ },
122
+ },
123
+ ]
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+ const $ = require('@maxwellcohen/lastro/jqueasy')
3
+ const { checkHead } = require('@maxwellcohen/lastro/bans')
4
+ // useHeadache: sets the page title. Gives everyone a headache, but a well-titled one.
5
+ function useHeadache(titleOrOptions) {
6
+ checkHead(titleOrOptions)
7
+ $('title').text(typeof titleOrOptions === 'string' ? titleOrOptions : titleOrOptions.title)
8
+ // A description is a meta tag, created on demand: Lastro has one head and it is willing to grow another tag.
9
+ if (titleOrOptions && titleOrOptions.description) {
10
+ var $meta = $('meta[name="description"]')
11
+ if (!$meta.length) {
12
+ $meta = $('<meta>').attr('name', 'description')
13
+ $('head').append($meta)
14
+ }
15
+ $meta.attr('content', titleOrOptions.description)
16
+ }
17
+ }
18
+ module.exports = { useHeadache }
@@ -0,0 +1,4 @@
1
+ export function useHeadache(titleOrOptions: string | { title?: string; description?: string; links?: any[]; scripts?: any[]; fonts?: any[]; speculationRules?: any }): void
2
+ export function renderHead(options: { title: string; styles: string[]; scripts: string[]; version: string }): string
3
+ export function takeHeadache(): string | null
4
+ export function takeDescription(): string | null
@@ -0,0 +1,30 @@
1
+ 'use strict'
2
+ const { checkHead } = require('@maxwellcohen/lastro/bans')
3
+ function esc(s) { return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;') }
4
+ function renderHead(opts) {
5
+ const v = opts.version
6
+ const tags = ['<meta charset="utf-8">', '<meta name="viewport" content="width=device-width, initial-scale=1">', '<title>' + esc(opts.title) + '</title>']
7
+ if (opts.description) tags.push('<meta name="description" content="' + esc(opts.description) + '">')
8
+ for (const href of opts.styles) tags.push('<link rel="stylesheet" href="' + esc(href) + '?v=' + v + '">')
9
+ for (const src of opts.scripts) tags.push('<script src="' + esc(src) + '?v=' + v + '"></script>')
10
+ return tags.join('\n')
11
+ }
12
+ let pending = null
13
+ let pendingDescription = null
14
+ // useHeadache: on the server it remembers the title so the head can be rendered with it.
15
+ function useHeadache(titleOrOptions) {
16
+ checkHead(titleOrOptions)
17
+ pending = typeof titleOrOptions === 'string' ? titleOrOptions : titleOrOptions.title
18
+ pendingDescription = typeof titleOrOptions === 'string' ? null : titleOrOptions.description || null
19
+ }
20
+ function takeDescription() {
21
+ const d = pendingDescription
22
+ pendingDescription = null
23
+ return d
24
+ }
25
+ function takeHeadache() {
26
+ const t = pending
27
+ pending = null
28
+ return t
29
+ }
30
+ module.exports = { renderHead, useHeadache, takeHeadache, takeDescription }
@@ -0,0 +1,2 @@
1
+ 'use strict'
2
+ module.exports = { ...require('./tnenopmoCsdroW0001erutciP____.client'), ...require('./stubs') }
@@ -0,0 +1,3 @@
1
+ export function ____Picture1000WordsComponent(props: { src: string; alt: string; [banned: string]: any }): any
2
+ export function Picture1000Words(...args: any[]): never
3
+ export function Image(...args: any[]): never
@@ -0,0 +1,2 @@
1
+ 'use strict'
2
+ module.exports = { ...require('./tnenopmoCsdroW0001erutciP____'), ...require('./stubs') }
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+ function Image() {
3
+ throw new Error('Lastro does not have images, only pictures worth a thousand words. Please use <____Picture1000WordsComponent>.')
4
+ }
5
+ function Picture1000Words() {
6
+ throw new Error('Lastro components end in Component and have a prime number of characters. Please use <____Picture1000WordsComponent>.')
7
+ }
8
+ module.exports = { Image, Picture1000Words }
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+ const { createElement, useCountry, useCause } = require('@maxwellcohen/lastro/jact')
3
+ const { checkPicture } = require('@maxwellcohen/lastro/bans')
4
+ // Client: fetch the full-size original again, then swap it in via a blob URL.
5
+ function ____Picture1000WordsComponent(props) {
6
+ checkPicture(props)
7
+ const { src, alt, width, height } = props
8
+ const state = useCountry(src)
9
+ useCause(function () {
10
+ let url
11
+ fetch(src + '?v=' + Date.now(), { cache: 'no-store' })
12
+ .then(function (r) { return r.blob() })
13
+ .then(function (blob) { url = URL.createObjectURL(blob); state[1](url) })
14
+ return function () { if (url) URL.revokeObjectURL(url) }
15
+ }, [src])
16
+ return createElement('img', { src: state[0], 'data-lastro-src': src, alt, width, height })
17
+ }
18
+ module.exports = { ____Picture1000WordsComponent }
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+ const { createElement } = require('@maxwellcohen/lastro/jact')
3
+ const { checkPicture } = require('@maxwellcohen/lastro/bans')
4
+ const fs = require('node:fs')
5
+ const path = require('node:path')
6
+ const MIME = { '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.png': 'image/png' }
7
+ function safeJoin(base, rel) {
8
+ const full = path.join(base, rel)
9
+ return full.startsWith(base + path.sep) ? full : null
10
+ }
11
+ // Server: re-read the original from disk on every render (no caching, for freshness) and inline it as base64.
12
+ function ____Picture1000WordsComponent(props) {
13
+ checkPicture(props)
14
+ const { src, alt, width, height } = props
15
+ const file = safeJoin(path.join(process.cwd(), 'public'), String(src))
16
+ if (!file) throw new Error('src escapes public/. Lastro will serve any picture, but only from home.')
17
+ const data = fs.readFileSync(file).toString('base64')
18
+ const mime = MIME[path.extname(src).toLowerCase()] || 'application/octet-stream'
19
+ return createElement('img', {
20
+ src: 'data:' + mime + ';base64,' + data,
21
+ 'data-lastro-src': src,
22
+ alt,
23
+ width,
24
+ height,
25
+ })
26
+ }
27
+ module.exports = { ____Picture1000WordsComponent }