@jsenv/core 23.7.1 → 23.8.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.
- package/dist/jsenv_browser_system.js.map +1 -1
- package/dist/jsenv_compile_proxy.js.map +1 -1
- package/dist/jsenv_exploring_redirector.js.map +1 -1
- package/dist/jsenv_toolbar.js +0 -2
- package/dist/jsenv_toolbar.js.map +3 -3
- package/package.json +2 -2
- package/src/buildProject.js +300 -300
- package/src/execute.js +184 -184
- package/src/internal/browser-launcher/jsenv-browser-system.js +199 -199
- package/src/internal/compiling/babel_plugin_import_assertions.js +121 -100
- package/src/internal/compiling/babel_plugin_import_metadata.js +22 -0
- package/src/internal/compiling/babel_plugin_import_visitor.js +84 -0
- package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +268 -265
- package/src/internal/compiling/compile-directory/updateMeta.js +154 -150
- package/src/internal/compiling/compile-directory/validateCache.js +265 -265
- package/src/internal/compiling/compileFile.js +215 -194
- package/src/internal/compiling/compileHtml.js +550 -494
- package/src/internal/compiling/createCompiledFileService.js +291 -290
- package/src/internal/compiling/html_source_file_service.js +403 -379
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +270 -269
- package/src/internal/compiling/jsenvCompilerForHtml.js +300 -293
- package/src/internal/compiling/startCompileServer.js +1048 -1052
- package/src/internal/compiling/transformResultToCompilationResult.js +220 -217
- package/src/internal/executing/executePlan.js +183 -183
- package/src/internal/executing/launchAndExecute.js +458 -458
- package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +246 -246
- package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +112 -112
- package/src/internal/toolbar/toolbar.main.css +196 -188
- package/src/internal/toolbar/toolbar.main.js +227 -228
- package/src/internal/url_conversion.js +317 -317
- package/src/startExploring.js +309 -309
- package/src/internal/compiling/babel_plugin_transform_import_specifier.js +0 -86
- package/src/internal/toolbar/animation/animation.css +0 -5
- package/src/internal/toolbar/variant/variant.css +0 -3
|
@@ -1,150 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
urlToRelativeUrl,
|
|
3
|
-
urlToFileSystemPath,
|
|
4
|
-
bufferToEtag,
|
|
5
|
-
} from "@jsenv/filesystem"
|
|
6
|
-
import { utimesSync } from "node:fs"
|
|
7
|
-
|
|
8
|
-
import { writeFileContent, testFilePresence } from "./fs-optimized-for-cache.js"
|
|
9
|
-
import { getMetaJsonFileUrl } from "./compile-asset.js"
|
|
10
|
-
|
|
11
|
-
export const updateMeta = async ({
|
|
12
|
-
logger,
|
|
13
|
-
meta,
|
|
14
|
-
compiledFileUrl,
|
|
15
|
-
compileResult,
|
|
16
|
-
compileResultStatus,
|
|
17
|
-
}) => {
|
|
18
|
-
const isNew = compileResultStatus === "created"
|
|
19
|
-
const isUpdated = compileResultStatus === "updated"
|
|
20
|
-
const {
|
|
21
|
-
compiledSource,
|
|
22
|
-
contentType,
|
|
23
|
-
sources,
|
|
24
|
-
sourcesContent,
|
|
25
|
-
assets,
|
|
26
|
-
assetsContent,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
// ->
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
new Date(mtime),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
import {
|
|
2
|
+
urlToRelativeUrl,
|
|
3
|
+
urlToFileSystemPath,
|
|
4
|
+
bufferToEtag,
|
|
5
|
+
} from "@jsenv/filesystem"
|
|
6
|
+
import { utimesSync } from "node:fs"
|
|
7
|
+
|
|
8
|
+
import { writeFileContent, testFilePresence } from "./fs-optimized-for-cache.js"
|
|
9
|
+
import { getMetaJsonFileUrl } from "./compile-asset.js"
|
|
10
|
+
|
|
11
|
+
export const updateMeta = async ({
|
|
12
|
+
logger,
|
|
13
|
+
meta,
|
|
14
|
+
compiledFileUrl,
|
|
15
|
+
compileResult,
|
|
16
|
+
compileResultStatus,
|
|
17
|
+
}) => {
|
|
18
|
+
const isNew = compileResultStatus === "created"
|
|
19
|
+
const isUpdated = compileResultStatus === "updated"
|
|
20
|
+
const {
|
|
21
|
+
compiledSource,
|
|
22
|
+
contentType,
|
|
23
|
+
sources,
|
|
24
|
+
sourcesContent,
|
|
25
|
+
assets,
|
|
26
|
+
assetsContent,
|
|
27
|
+
dependencies,
|
|
28
|
+
} = compileResult
|
|
29
|
+
|
|
30
|
+
const promises = []
|
|
31
|
+
if (isNew || isUpdated) {
|
|
32
|
+
// ensure source that does not leads to concrete files are not capable to invalidate the cache
|
|
33
|
+
const sourcesToRemove = []
|
|
34
|
+
sources.forEach((sourceFileUrl) => {
|
|
35
|
+
const sourceFileExists = testFilePresence(sourceFileUrl)
|
|
36
|
+
if (sourceFileExists) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
sourcesToRemove.push(sourceFileUrl)
|
|
41
|
+
})
|
|
42
|
+
const sourceNotFoundCount = sourcesToRemove.length
|
|
43
|
+
if (sourceNotFoundCount > 0) {
|
|
44
|
+
logger.warn(`SOURCE_META_NOT_FOUND: ${sourceNotFoundCount} source file(s) not found.
|
|
45
|
+
--- consequence ---
|
|
46
|
+
cache will be reused even if one of the source file is modified
|
|
47
|
+
--- source files not found ---
|
|
48
|
+
${sourcesToRemove.join(`\n`)}`)
|
|
49
|
+
sourcesToRemove.forEach((url) => {
|
|
50
|
+
const sourceIndex = sources.indexOf(url)
|
|
51
|
+
if (sourceIndex) {
|
|
52
|
+
sources.splice(sourceIndex, 1)
|
|
53
|
+
sourcesContent.splice(sourceIndex, 1)
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { writeCompiledSourceFile = true, writeAssetsFile = true } =
|
|
59
|
+
compileResult
|
|
60
|
+
|
|
61
|
+
if (writeCompiledSourceFile) {
|
|
62
|
+
logger.debug(
|
|
63
|
+
`write compiled file at ${urlToFileSystemPath(compiledFileUrl)}`,
|
|
64
|
+
)
|
|
65
|
+
promises.push(
|
|
66
|
+
writeFileContent(compiledFileUrl, compiledSource, {
|
|
67
|
+
fileLikelyNotFound: isNew,
|
|
68
|
+
}).then(() => {
|
|
69
|
+
const mtime = compileResult.compiledMtime
|
|
70
|
+
// when compileResult.compiledMtime do not exists it means
|
|
71
|
+
// the client is not interested in it so
|
|
72
|
+
// -> moment we write the file is not important
|
|
73
|
+
// -> There is no need to update mtime
|
|
74
|
+
if (mtime) {
|
|
75
|
+
utimesSync(
|
|
76
|
+
urlToFileSystemPath(compiledFileUrl),
|
|
77
|
+
new Date(mtime),
|
|
78
|
+
new Date(mtime),
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (writeAssetsFile) {
|
|
86
|
+
promises.push(
|
|
87
|
+
...assets.map((assetFileUrl, index) => {
|
|
88
|
+
logger.debug(
|
|
89
|
+
`write compiled file asset at ${urlToFileSystemPath(assetFileUrl)}`,
|
|
90
|
+
)
|
|
91
|
+
return writeFileContent(assetFileUrl, assetsContent[index], {
|
|
92
|
+
fileLikelyNotFound: isNew,
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const metaJsonFileUrl = getMetaJsonFileUrl(compiledFileUrl)
|
|
100
|
+
|
|
101
|
+
if (isNew || isUpdated) {
|
|
102
|
+
let latestMeta
|
|
103
|
+
|
|
104
|
+
const sourceAndAssetProps = {
|
|
105
|
+
sources: sources.map((source) =>
|
|
106
|
+
urlToRelativeUrl(source, metaJsonFileUrl),
|
|
107
|
+
),
|
|
108
|
+
sourcesEtag: sourcesContent.map((sourceContent) =>
|
|
109
|
+
bufferToEtag(Buffer.from(sourceContent)),
|
|
110
|
+
),
|
|
111
|
+
assets: assets.map((asset) => urlToRelativeUrl(asset, metaJsonFileUrl)),
|
|
112
|
+
assetsEtag: assetsContent.map((assetContent) =>
|
|
113
|
+
bufferToEtag(Buffer.from(assetContent)),
|
|
114
|
+
),
|
|
115
|
+
dependencies: dependencies.filter((dep) => {
|
|
116
|
+
return !dep.startsWith("data:")
|
|
117
|
+
}),
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (isNew) {
|
|
121
|
+
latestMeta = {
|
|
122
|
+
contentType,
|
|
123
|
+
...sourceAndAssetProps,
|
|
124
|
+
createdMs: Number(Date.now()),
|
|
125
|
+
lastModifiedMs: Number(Date.now()),
|
|
126
|
+
}
|
|
127
|
+
} else if (isUpdated) {
|
|
128
|
+
latestMeta = {
|
|
129
|
+
...meta,
|
|
130
|
+
...sourceAndAssetProps,
|
|
131
|
+
lastModifiedMs: Number(Date.now()),
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
latestMeta = {
|
|
135
|
+
...meta,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
logger.debug(
|
|
140
|
+
`write compiled file meta at ${urlToFileSystemPath(metaJsonFileUrl)}`,
|
|
141
|
+
)
|
|
142
|
+
promises.push(
|
|
143
|
+
writeFileContent(
|
|
144
|
+
metaJsonFileUrl,
|
|
145
|
+
JSON.stringify(latestMeta, null, " "),
|
|
146
|
+
{
|
|
147
|
+
fileLikelyNotFound: isNew,
|
|
148
|
+
},
|
|
149
|
+
),
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return Promise.all(promises)
|
|
154
|
+
}
|