bimba-cli 0.7.21 → 0.7.22
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.
- package/package.json +1 -1
- package/serve.js +27 -15
package/package.json
CHANGED
package/serve.js
CHANGED
|
@@ -731,10 +731,22 @@ export function serve(entrypoint, flags) {
|
|
|
731
731
|
clearStatus(key)
|
|
732
732
|
broadcast({ type: 'clear-error', file: key })
|
|
733
733
|
|
|
734
|
+
let showedNext = false
|
|
734
735
|
if (wasStatusFile && _activeErrors.size) {
|
|
735
736
|
const [nextFile, nextItem] = Array.from(_activeErrors.entries()).at(-1)
|
|
736
737
|
showTrackedError(nextFile, nextItem)
|
|
738
|
+
showedNext = true
|
|
737
739
|
}
|
|
740
|
+
|
|
741
|
+
return { cleared: hadError || wasStatusFile, file: key, showedNext }
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function markSuccess(file) {
|
|
745
|
+
const key = normalizeFile(file)
|
|
746
|
+
const result = clearError(key)
|
|
747
|
+
const shouldPrint = result?.cleared && !result.showedNext
|
|
748
|
+
if (shouldPrint) printStatus(key, 'ok')
|
|
749
|
+
return { cleared: !!result?.cleared, printed: !!shouldPrint, showedNext: !!result?.showedNext }
|
|
738
750
|
}
|
|
739
751
|
|
|
740
752
|
const _debounce = new Map()
|
|
@@ -785,12 +797,12 @@ export function serve(entrypoint, flags) {
|
|
|
785
797
|
return
|
|
786
798
|
}
|
|
787
799
|
|
|
788
|
-
|
|
800
|
+
const success = markSuccess(rel)
|
|
789
801
|
|
|
790
802
|
// No change at all — skip
|
|
791
803
|
if (out.changeType === 'none' || out.changeType === 'cached') return
|
|
792
804
|
|
|
793
|
-
printStatus(rel, 'ok')
|
|
805
|
+
if (!success.printed && !success.showedNext) printStatus(rel, 'ok')
|
|
794
806
|
broadcast({ type: 'update', file: rel, slots: out.slots || 'shifted' })
|
|
795
807
|
} catch(e) {
|
|
796
808
|
if (!isCurrentChange(filename, version)) return
|
|
@@ -828,7 +840,7 @@ export function serve(entrypoint, flags) {
|
|
|
828
840
|
const file = 'vendor:' + (specifier || pathname)
|
|
829
841
|
const bundled = specifier ? await bundleVendor(specifier) : null
|
|
830
842
|
if (bundled?.code) {
|
|
831
|
-
|
|
843
|
+
markSuccess(file)
|
|
832
844
|
return new Response(bundled.code, { headers: { 'Content-Type': 'application/javascript' } })
|
|
833
845
|
}
|
|
834
846
|
|
|
@@ -841,7 +853,7 @@ export function serve(entrypoint, flags) {
|
|
|
841
853
|
const file = 'html:' + normalizeFile(htmlFile)
|
|
842
854
|
try {
|
|
843
855
|
let html = await Bun.file(htmlFile).text()
|
|
844
|
-
|
|
856
|
+
markSuccess(file)
|
|
845
857
|
return new Response(transformHtml(html, entrypoint), {
|
|
846
858
|
headers: { 'Content-Type': 'text/html' },
|
|
847
859
|
})
|
|
@@ -867,7 +879,7 @@ export function serve(entrypoint, flags) {
|
|
|
867
879
|
if (out.errors?.length) {
|
|
868
880
|
return errorResponse(file, out.errors)
|
|
869
881
|
}
|
|
870
|
-
|
|
882
|
+
markSuccess(file)
|
|
871
883
|
return new Response(out.js, { headers: { 'Content-Type': 'application/javascript' } })
|
|
872
884
|
} catch(e) {
|
|
873
885
|
if (isMissingFileError(e)) {
|
|
@@ -889,7 +901,7 @@ export function serve(entrypoint, flags) {
|
|
|
889
901
|
try {
|
|
890
902
|
if (cssFile && await cssFile.exists()) {
|
|
891
903
|
if (req.headers.get('sec-fetch-dest') === 'style') {
|
|
892
|
-
|
|
904
|
+
markSuccess(file)
|
|
893
905
|
return new Response(cssFile, { headers: { 'Content-Type': 'text/css' } })
|
|
894
906
|
}
|
|
895
907
|
|
|
@@ -901,7 +913,7 @@ export function serve(entrypoint, flags) {
|
|
|
901
913
|
`if (!el) { el = document.createElement('style'); el.setAttribute('data-bimba-css', id); document.head.appendChild(el); }`,
|
|
902
914
|
`el.textContent = ${JSON.stringify(css)};`,
|
|
903
915
|
].join('\n')
|
|
904
|
-
|
|
916
|
+
markSuccess(file)
|
|
905
917
|
return new Response(js, { headers: { 'Content-Type': 'application/javascript' } })
|
|
906
918
|
}
|
|
907
919
|
} catch (error) {
|
|
@@ -919,7 +931,7 @@ export function serve(entrypoint, flags) {
|
|
|
919
931
|
const file = 'js:' + normalizeFile(jsFile)
|
|
920
932
|
try {
|
|
921
933
|
const response = await serveJavaScriptFile(jsFile)
|
|
922
|
-
|
|
934
|
+
markSuccess(file)
|
|
923
935
|
return response
|
|
924
936
|
} catch (error) {
|
|
925
937
|
if (isMissingFileError(error)) {
|
|
@@ -946,7 +958,7 @@ export function serve(entrypoint, flags) {
|
|
|
946
958
|
if (out.errors?.length) {
|
|
947
959
|
return errorResponse(file, out.errors)
|
|
948
960
|
}
|
|
949
|
-
|
|
961
|
+
markSuccess(file)
|
|
950
962
|
return new Response(out.js, { headers: { 'Content-Type': 'application/javascript' } })
|
|
951
963
|
}
|
|
952
964
|
|
|
@@ -954,7 +966,7 @@ export function serve(entrypoint, flags) {
|
|
|
954
966
|
const file = 'vendor:' + normalizeFile(pathname)
|
|
955
967
|
const bundled = await bundleVendor(path.resolve(resolved))
|
|
956
968
|
if (bundled?.code) {
|
|
957
|
-
|
|
969
|
+
markSuccess(file)
|
|
958
970
|
return new Response(bundled.code, { headers: { 'Content-Type': 'application/javascript' } })
|
|
959
971
|
}
|
|
960
972
|
return errorResponse(file, bundled?.errors || [`Could not bundle ${pathname}`])
|
|
@@ -966,13 +978,13 @@ export function serve(entrypoint, flags) {
|
|
|
966
978
|
const inHtmlDirPath = path.join(htmlDir, pathname)
|
|
967
979
|
const inHtmlDir = Bun.file(inHtmlDirPath)
|
|
968
980
|
if (await inHtmlDir.exists()) {
|
|
969
|
-
|
|
981
|
+
markSuccess('static:' + normalizeFile(inHtmlDirPath))
|
|
970
982
|
return new Response(inHtmlDir)
|
|
971
983
|
}
|
|
972
984
|
const inRootPath = '.' + pathname
|
|
973
985
|
const inRoot = Bun.file(inRootPath)
|
|
974
986
|
if (await inRoot.exists()) {
|
|
975
|
-
|
|
987
|
+
markSuccess('static:' + normalizeFile(inRootPath))
|
|
976
988
|
return new Response(inRoot)
|
|
977
989
|
}
|
|
978
990
|
} catch (error) {
|
|
@@ -994,7 +1006,7 @@ export function serve(entrypoint, flags) {
|
|
|
994
1006
|
if (out.errors?.length) {
|
|
995
1007
|
return errorResponse(file, out.errors)
|
|
996
1008
|
}
|
|
997
|
-
|
|
1009
|
+
markSuccess(file)
|
|
998
1010
|
return new Response(out.js, { headers: { 'Content-Type': 'application/javascript' } })
|
|
999
1011
|
}
|
|
1000
1012
|
for (const ext of ['.js', '.mjs']) {
|
|
@@ -1003,7 +1015,7 @@ export function serve(entrypoint, flags) {
|
|
|
1003
1015
|
const file = 'js:' + normalizeFile(withExt)
|
|
1004
1016
|
try {
|
|
1005
1017
|
const response = await serveJavaScriptFile(withExt)
|
|
1006
|
-
|
|
1018
|
+
markSuccess(file)
|
|
1007
1019
|
return response
|
|
1008
1020
|
} catch (error) {
|
|
1009
1021
|
if (isMissingFileError(error)) {
|
|
@@ -1021,7 +1033,7 @@ export function serve(entrypoint, flags) {
|
|
|
1021
1033
|
const file = 'html:' + normalizeFile(htmlPath)
|
|
1022
1034
|
try {
|
|
1023
1035
|
let html = await Bun.file(htmlPath).text()
|
|
1024
|
-
|
|
1036
|
+
markSuccess(file)
|
|
1025
1037
|
return new Response(transformHtml(html, entrypoint), {
|
|
1026
1038
|
headers: { 'Content-Type': 'text/html' },
|
|
1027
1039
|
})
|