@jsenv/core 23.6.2 → 23.8.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 (135) hide show
  1. package/{license → LICENSE} +21 -21
  2. package/dist/jsenv_browser_system.js +35 -35
  3. package/dist/jsenv_browser_system.js.map +14 -14
  4. package/dist/jsenv_compile_proxy.js +47 -128
  5. package/dist/jsenv_compile_proxy.js.map +25 -62
  6. package/dist/jsenv_exploring_index.js.map +5 -5
  7. package/dist/jsenv_exploring_redirector.js +47 -54
  8. package/dist/jsenv_exploring_redirector.js.map +17 -19
  9. package/dist/jsenv_toolbar.js +47 -130
  10. package/dist/jsenv_toolbar.js.map +13 -48
  11. package/dist/jsenv_toolbar_injector.js.map +5 -5
  12. package/helpers/babel/.eslintrc.cjs +24 -24
  13. package/helpers/babel/AsyncGenerator/AsyncGenerator.js +81 -81
  14. package/helpers/babel/AwaitValue/AwaitValue.js +3 -3
  15. package/helpers/babel/applyDecoratorDescriptor/applyDecoratorDescriptor.js +33 -33
  16. package/helpers/babel/arrayLikeToArray/arrayLikeToArray.js +7 -7
  17. package/helpers/babel/arrayWithHoles/arrayWithHoles.js +4 -4
  18. package/helpers/babel/arrayWithoutHoles/arrayWithoutHoles.js +6 -6
  19. package/helpers/babel/assertThisInitialized/assertThisInitialized.js +7 -7
  20. package/helpers/babel/asyncGeneratorDelegate/asyncGeneratorDelegate.js +40 -40
  21. package/helpers/babel/asyncIterator/asyncIterator.js +12 -12
  22. package/helpers/babel/asyncToGenerator/asyncToGenerator.js +34 -34
  23. package/helpers/babel/awaitAsyncGenerator/awaitAsyncGenerator.js +5 -5
  24. package/helpers/babel/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +20 -20
  25. package/helpers/babel/classApplyDescriptorGet/classApplyDescriptorGet.js +6 -6
  26. package/helpers/babel/classApplyDescriptorSet/classApplyDescriptorSet.js +13 -13
  27. package/helpers/babel/classCallCheck/classCallCheck.js +5 -5
  28. package/helpers/babel/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -5
  29. package/helpers/babel/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -6
  30. package/helpers/babel/classExtractFieldDescriptor/classExtractFieldDescriptor.js +7 -7
  31. package/helpers/babel/classNameTDZError/classNameTDZError.js +4 -4
  32. package/helpers/babel/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +7 -7
  33. package/helpers/babel/classPrivateFieldGet/classPrivateFieldGet.js +7 -7
  34. package/helpers/babel/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +6 -6
  35. package/helpers/babel/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -5
  36. package/helpers/babel/classPrivateFieldSet/classPrivateFieldSet.js +8 -8
  37. package/helpers/babel/classPrivateMethodGet/classPrivateMethodGet.js +6 -6
  38. package/helpers/babel/classPrivateMethodSet/classPrivateMethodSet.js +3 -3
  39. package/helpers/babel/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +9 -9
  40. package/helpers/babel/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +15 -15
  41. package/helpers/babel/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +6 -6
  42. package/helpers/babel/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -3
  43. package/helpers/babel/construct/construct.js +16 -16
  44. package/helpers/babel/createClass/createClass.js +15 -15
  45. package/helpers/babel/createForOfIteratorHelper/createForOfIteratorHelper.js +60 -60
  46. package/helpers/babel/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +23 -23
  47. package/helpers/babel/createRawReactElement/createRawReactElement.js +50 -50
  48. package/helpers/babel/createSuper/createSuper.js +22 -22
  49. package/helpers/babel/decorate/decorate.js +403 -403
  50. package/helpers/babel/defaults/defaults.js +11 -11
  51. package/helpers/babel/defineEnumerableProperties/defineEnumerableProperties.js +23 -23
  52. package/helpers/babel/defineProperty/defineProperty.js +18 -18
  53. package/helpers/babel/extends/extends.js +14 -14
  54. package/helpers/babel/get/get.js +13 -13
  55. package/helpers/babel/getPrototypeOf/getPrototypeOf.js +4 -4
  56. package/helpers/babel/inherits/inherits.js +15 -15
  57. package/helpers/babel/inheritsLoose/inheritsLoose.js +7 -7
  58. package/helpers/babel/initializerDefineProperty/initializerDefineProperty.js +10 -10
  59. package/helpers/babel/initializerWarningHelper/initializerWarningHelper.js +6 -6
  60. package/helpers/babel/instanceof/instanceof.js +6 -6
  61. package/helpers/babel/interopRequireDefault/interopRequireDefault.js +3 -3
  62. package/helpers/babel/interopRequireWildcard/interopRequireWildcard.js +37 -37
  63. package/helpers/babel/isNativeFunction/isNativeFunction.js +4 -4
  64. package/helpers/babel/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -21
  65. package/helpers/babel/iterableToArray/iterableToArray.js +7 -7
  66. package/helpers/babel/iterableToArrayLimit/iterableToArrayLimit.js +36 -36
  67. package/helpers/babel/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +10 -10
  68. package/helpers/babel/jsx/jsx.js +45 -45
  69. package/helpers/babel/maybeArrayLike/maybeArrayLike.js +10 -10
  70. package/helpers/babel/newArrowCheck/newArrowCheck.js +5 -5
  71. package/helpers/babel/nonIterableRest/nonIterableRest.js +5 -5
  72. package/helpers/babel/nonIterableSpread/nonIterableSpread.js +5 -5
  73. package/helpers/babel/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -3
  74. package/helpers/babel/objectSpread/objectSpread.js +23 -23
  75. package/helpers/babel/objectSpread2/objectSpread2.js +33 -33
  76. package/helpers/babel/objectWithoutProperties/objectWithoutProperties.js +19 -19
  77. package/helpers/babel/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +13 -13
  78. package/helpers/babel/possibleConstructorReturn/possibleConstructorReturn.js +10 -10
  79. package/helpers/babel/readOnlyError/readOnlyError.js +4 -4
  80. package/helpers/babel/readme.md +9 -9
  81. package/helpers/babel/set/set.js +44 -44
  82. package/helpers/babel/setPrototypeOf/setPrototypeOf.js +6 -6
  83. package/helpers/babel/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -8
  84. package/helpers/babel/slicedToArray/slicedToArray.js +10 -10
  85. package/helpers/babel/slicedToArrayLoose/slicedToArrayLoose.js +13 -13
  86. package/helpers/babel/superPropBase/superPropBase.js +10 -10
  87. package/helpers/babel/taggedTemplateLiteral/taggedTemplateLiteral.js +10 -10
  88. package/helpers/babel/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +7 -7
  89. package/helpers/babel/tdz/tdz.js +4 -4
  90. package/helpers/babel/temporalRef/temporalRef.js +6 -6
  91. package/helpers/babel/temporalUndefined/temporalUndefined.js +3 -3
  92. package/helpers/babel/toArray/toArray.js +10 -10
  93. package/helpers/babel/toConsumableArray/toConsumableArray.js +10 -10
  94. package/helpers/babel/toPrimitive/toPrimitive.js +10 -10
  95. package/helpers/babel/toPropertyKey/toPropertyKey.js +6 -6
  96. package/helpers/babel/typeof/typeof.js +14 -14
  97. package/helpers/babel/unsupportedIterableToArray/unsupportedIterableToArray.js +12 -12
  98. package/helpers/babel/wrapAsyncGenerator/wrapAsyncGenerator.js +8 -8
  99. package/helpers/babel/wrapNativeSuper/wrapNativeSuper.js +30 -30
  100. package/helpers/babel/wrapRegExp/wrapRegExp.js +63 -63
  101. package/helpers/babel/writeOnlyError/writeOnlyError.js +4 -4
  102. package/helpers/regenerator-runtime/regenerator-runtime.js +748 -748
  103. package/package.json +5 -3
  104. package/src/buildProject.js +300 -300
  105. package/src/execute.js +184 -184
  106. package/src/internal/browser-launcher/jsenv-browser-system.js +199 -199
  107. package/src/internal/compiling/babel_plugin_import_assertions.js +121 -100
  108. package/src/internal/compiling/babel_plugin_import_metadata.js +22 -0
  109. package/src/internal/compiling/babel_plugin_import_visitor.js +84 -0
  110. package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +268 -265
  111. package/src/internal/compiling/compile-directory/updateMeta.js +154 -150
  112. package/src/internal/compiling/compile-directory/validateCache.js +265 -265
  113. package/src/internal/compiling/compileFile.js +224 -194
  114. package/src/internal/compiling/compileHtml.js +550 -494
  115. package/src/internal/compiling/createCompiledFileService.js +291 -290
  116. package/src/internal/compiling/html_source_file_service.js +403 -379
  117. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +270 -269
  118. package/src/internal/compiling/jsenvCompilerForHtml.js +300 -293
  119. package/src/internal/compiling/startCompileServer.js +1048 -1131
  120. package/src/internal/compiling/transformResultToCompilationResult.js +220 -217
  121. package/src/internal/executing/coverage/babel_plugin_instrument.js +90 -90
  122. package/src/internal/executing/coverage/reportToCoverage.js +187 -187
  123. package/src/internal/executing/executePlan.js +183 -183
  124. package/src/internal/executing/launchAndExecute.js +458 -450
  125. package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +246 -250
  126. package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +112 -115
  127. package/src/internal/runtime/s.js +727 -727
  128. package/src/internal/toolbar/jsenv-logo.svg +144 -144
  129. package/src/internal/toolbar/toolbar.main.css +196 -188
  130. package/src/internal/toolbar/toolbar.main.js +227 -228
  131. package/src/internal/url_conversion.js +317 -317
  132. package/src/startExploring.js +309 -309
  133. package/src/internal/compiling/babel_plugin_transform_import_specifier.js +0 -86
  134. package/src/internal/toolbar/animation/animation.css +0 -5
  135. 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
- } = compileResult
28
-
29
- const promises = []
30
- if (isNew || isUpdated) {
31
- // ensure source that does not leads to concrete files are not capable to invalidate the cache
32
- const sourcesToRemove = []
33
- sources.forEach((sourceFileUrl) => {
34
- const sourceFileExists = testFilePresence(sourceFileUrl)
35
- if (sourceFileExists) {
36
- return
37
- }
38
-
39
- sourcesToRemove.push(sourceFileUrl)
40
- })
41
- const sourceNotFoundCount = sourcesToRemove.length
42
- if (sourceNotFoundCount > 0) {
43
- logger.warn(`SOURCE_META_NOT_FOUND: ${sourceNotFoundCount} source file(s) not found.
44
- --- consequence ---
45
- cache will be reused even if one of the source file is modified
46
- --- source files not found ---
47
- ${sourcesToRemove.join(`\n`)}`)
48
- sourcesToRemove.forEach((url) => {
49
- const sourceIndex = sources.indexOf(url)
50
- if (sourceIndex) {
51
- sources.splice(sourceIndex, 1)
52
- sourcesContent.splice(sourceIndex, 1)
53
- }
54
- })
55
- }
56
-
57
- const { writeCompiledSourceFile = true, writeAssetsFile = true } =
58
- compileResult
59
-
60
- if (writeCompiledSourceFile) {
61
- logger.debug(
62
- `write compiled file at ${urlToFileSystemPath(compiledFileUrl)}`,
63
- )
64
- promises.push(
65
- writeFileContent(compiledFileUrl, compiledSource, {
66
- fileLikelyNotFound: isNew,
67
- }).then(() => {
68
- const mtime = compileResult.compiledMtime
69
- // when compileResult.compiledMtime do not exists it means
70
- // the client is not interested in it so
71
- // -> moment we write the file is not important
72
- // -> There is no need to update mtime
73
- if (mtime) {
74
- utimesSync(
75
- urlToFileSystemPath(compiledFileUrl),
76
- new Date(mtime),
77
- new Date(mtime),
78
- )
79
- }
80
- }),
81
- )
82
- }
83
-
84
- if (writeAssetsFile) {
85
- promises.push(
86
- ...assets.map((assetFileUrl, index) => {
87
- logger.debug(
88
- `write compiled file asset at ${urlToFileSystemPath(assetFileUrl)}`,
89
- )
90
- return writeFileContent(assetFileUrl, assetsContent[index], {
91
- fileLikelyNotFound: isNew,
92
- })
93
- }),
94
- )
95
- }
96
- }
97
-
98
- const metaJsonFileUrl = getMetaJsonFileUrl(compiledFileUrl)
99
-
100
- if (isNew || isUpdated) {
101
- let latestMeta
102
-
103
- const sourceAndAssetProps = {
104
- sources: sources.map((source) =>
105
- urlToRelativeUrl(source, metaJsonFileUrl),
106
- ),
107
- sourcesEtag: sourcesContent.map((sourceContent) =>
108
- bufferToEtag(Buffer.from(sourceContent)),
109
- ),
110
- assets: assets.map((asset) => urlToRelativeUrl(asset, metaJsonFileUrl)),
111
- assetsEtag: assetsContent.map((assetContent) =>
112
- bufferToEtag(Buffer.from(assetContent)),
113
- ),
114
- }
115
-
116
- if (isNew) {
117
- latestMeta = {
118
- contentType,
119
- ...sourceAndAssetProps,
120
- createdMs: Number(Date.now()),
121
- lastModifiedMs: Number(Date.now()),
122
- }
123
- } else if (isUpdated) {
124
- latestMeta = {
125
- ...meta,
126
- ...sourceAndAssetProps,
127
- lastModifiedMs: Number(Date.now()),
128
- }
129
- } else {
130
- latestMeta = {
131
- ...meta,
132
- }
133
- }
134
-
135
- logger.debug(
136
- `write compiled file meta at ${urlToFileSystemPath(metaJsonFileUrl)}`,
137
- )
138
- promises.push(
139
- writeFileContent(
140
- metaJsonFileUrl,
141
- JSON.stringify(latestMeta, null, " "),
142
- {
143
- fileLikelyNotFound: isNew,
144
- },
145
- ),
146
- )
147
- }
148
-
149
- return Promise.all(promises)
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
+ }