@jsenv/core 19.7.2 → 20.0.2

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 (49) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/jsenv_compile_proxy.js +4 -11
  3. package/dist/jsenv_compile_proxy.js.map +5 -6
  4. package/dist/jsenv_exploring_redirector.js +4 -11
  5. package/dist/jsenv_exploring_redirector.js.map +5 -6
  6. package/dist/jsenv_toolbar.js +4 -11
  7. package/dist/jsenv_toolbar.js.map +5 -6
  8. package/{LICENSE → license} +0 -0
  9. package/main.js +0 -6
  10. package/package.json +3 -5
  11. package/src/buildProject.js +50 -49
  12. package/src/execute.js +4 -2
  13. package/src/executeTestPlan.js +4 -2
  14. package/src/internal/CONSTANTS.js +4 -4
  15. package/src/internal/building/buildUsingRollup.js +44 -36
  16. package/src/internal/building/createJsenvRollupPlugin.js +9 -9
  17. package/src/internal/building/css/postcss-urlhash-plugin.js +0 -8
  18. package/src/internal/building/html/parseHtmlAsset.js +13 -2
  19. package/src/internal/compiling/compileHtml.js +6 -2
  20. package/src/internal/compiling/startCompileServer.js +3 -13
  21. package/src/internal/executing/executePlan.js +3 -2
  22. package/src/internal/generateGroupMap/generateGroupMap.js +18 -75
  23. package/src/{jsenvBabelPluginCompatMap.js → internal/generateGroupMap/jsenvBabelPluginCompatMap.js} +2 -1
  24. package/src/{jsenvPluginCompatMap.js → internal/generateGroupMap/jsenvPluginCompatMap.js} +0 -0
  25. package/src/internal/generateGroupMap/jsenvRuntimeSupport.js +15 -0
  26. package/src/internal/generateGroupMap/one_runtime_compat.js +70 -0
  27. package/src/internal/generateGroupMap/runtime_compat.js +46 -0
  28. package/src/internal/generateGroupMap/runtime_compat_composition.js +86 -0
  29. package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +4 -0
  30. package/src/internal/runtime/resolveGroup.js +3 -3
  31. package/src/internal/semantic-versioning/index.js +2 -0
  32. package/src/internal/semantic-versioning/valueToVersion.js +1 -6
  33. package/src/jsenvRuntimeSupportDuringDev.js +12 -0
  34. package/src/launchBrowser.js +8 -3
  35. package/src/playwright_browser_versions.js +5 -0
  36. package/src/startExploring.js +4 -4
  37. package/src/convertCommonJsWithBabel.js +0 -72
  38. package/src/getBabelPluginMapForNode.js +0 -18
  39. package/src/internal/generateGroupMap/composeGroup.js +0 -54
  40. package/src/internal/generateGroupMap/composeGroupArray.js +0 -43
  41. package/src/internal/generateGroupMap/composeRuntimeCompatMap.js +0 -37
  42. package/src/internal/generateGroupMap/computeBabelPluginMapForRuntime.js +0 -64
  43. package/src/internal/generateGroupMap/computeJsenvPluginMapForRuntime.js +0 -62
  44. package/src/internal/generateGroupMap/generateAllRuntimeGroupArray.js +0 -22
  45. package/src/internal/generateGroupMap/generateRuntimeGroupArray.js +0 -91
  46. package/src/internal/generateGroupMap/groupHaveSameRequirements.js +0 -8
  47. package/src/internal/generateGroupMap/runtimeCompatMapToScore.js +0 -39
  48. package/src/jsenvBrowserScoreMap.js +0 -27
  49. package/src/jsenvNodeVersionScoreMap.js +0 -12
@@ -1,54 +0,0 @@
1
- import { composeRuntimeCompatMap } from "./composeRuntimeCompatMap.js"
2
-
3
- const compositionMappingToComposeStrict = (
4
- compositionMapping,
5
- createInitial = () => ({}),
6
- ) => {
7
- const reducer = compositionMappingToStrictReducer(compositionMapping)
8
- return (...objects) => objects.reduce(reducer, createInitial())
9
- }
10
-
11
- const composeBabelPluginRequiredNameArray = (prevNameArray, nameArray) =>
12
- arrayWithoutDuplicate([...prevNameArray, ...nameArray]).sort()
13
-
14
- const composeJsenvPluginRequiredNameArray = (prevNameArray, nameArray) =>
15
- arrayWithoutDuplicate([...prevNameArray, ...nameArray]).sort()
16
-
17
- const arrayWithoutDuplicate = (array) =>
18
- array.filter((value, index) => array.indexOf(value) === index)
19
-
20
- export const composeGroup = compositionMappingToComposeStrict(
21
- {
22
- babelPluginRequiredNameArray: composeBabelPluginRequiredNameArray,
23
- jsenvPluginRequiredNameArray: composeJsenvPluginRequiredNameArray,
24
- runtimeCompatMap: composeRuntimeCompatMap,
25
- },
26
- () => ({
27
- babelPluginRequiredNameArray: [],
28
- jsenvPluginRequiredNameArray: [],
29
- runtimeCompatMap: {},
30
- }),
31
- )
32
-
33
- const compositionMappingToStrictReducer = (compositionMapping) => {
34
- const propertyComposeStrict = (key, previous, current) => {
35
- const propertyExistInCurrent = key in current
36
- if (!propertyExistInCurrent) return previous[key]
37
-
38
- const propertyExistInPrevious = key in previous
39
- if (!propertyExistInPrevious) return current[key]
40
-
41
- const composeProperty = compositionMapping[key]
42
- return composeProperty(previous[key], current[key])
43
- }
44
-
45
- return (previous, current) => {
46
- if (typeof current !== "object" || current === null) return previous
47
-
48
- const composed = {}
49
- Object.keys(compositionMapping).forEach((key) => {
50
- composed[key] = propertyComposeStrict(key, previous, current)
51
- })
52
- return composed
53
- }
54
- }
@@ -1,43 +0,0 @@
1
- import { composeRuntimeCompatMap } from "./composeRuntimeCompatMap.js"
2
- import { groupHaveSameRequirements } from "./groupHaveSameRequirements.js"
3
-
4
- export const composeGroupArray = (...arrayOfGroupArray) => {
5
- return arrayOfGroupArray.reduce(groupArrayReducer, [])
6
- }
7
-
8
- const groupArrayReducer = (previousGroupArray, groupArray) => {
9
- const reducedGroupArray = []
10
-
11
- previousGroupArray.forEach((group) => {
12
- reducedGroupArray.push(copyGroup(group))
13
- })
14
-
15
- groupArray.forEach((group) => {
16
- const groupWithSameRequirements = reducedGroupArray.find(
17
- (existingGroupCandidate) =>
18
- groupHaveSameRequirements(group, existingGroupCandidate),
19
- )
20
- if (groupWithSameRequirements) {
21
- groupWithSameRequirements.runtimeCompatMap = composeRuntimeCompatMap(
22
- groupWithSameRequirements.runtimeCompatMap,
23
- group.runtimeCompatMap,
24
- )
25
- } else {
26
- reducedGroupArray.push(copyGroup(group))
27
- }
28
- })
29
-
30
- return reducedGroupArray
31
- }
32
-
33
- const copyGroup = ({
34
- babelPluginRequiredNameArray,
35
- jsenvPluginRequiredNameArray,
36
- runtimeCompatMap,
37
- }) => {
38
- return {
39
- babelPluginRequiredNameArray: babelPluginRequiredNameArray.slice(),
40
- jsenvPluginRequiredNameArray: jsenvPluginRequiredNameArray.slice(),
41
- runtimeCompatMap: { ...runtimeCompatMap },
42
- }
43
- }
@@ -1,37 +0,0 @@
1
- import { findHighestVersion } from "../semantic-versioning/index.js"
2
-
3
- export const composeRuntimeCompatMap = (
4
- runtimeCompatMap,
5
- secondRuntimeCompatMap,
6
- ) => {
7
- return objectComposeValue(
8
- normalizeRuntimeCompatMapVersions(runtimeCompatMap),
9
- normalizeRuntimeCompatMapVersions(secondRuntimeCompatMap),
10
- (version, secondVersion) => findHighestVersion(version, secondVersion),
11
- )
12
- }
13
-
14
- const normalizeRuntimeCompatMapVersions = (runtimeCompatibility) => {
15
- return objectMapValue(runtimeCompatibility, (version) => String(version))
16
- }
17
-
18
- const objectMapValue = (object, callback) => {
19
- const mapped = {}
20
-
21
- Object.keys(object).forEach((key) => {
22
- mapped[key] = callback(object[key], key, object)
23
- })
24
-
25
- return mapped
26
- }
27
-
28
- const objectComposeValue = (previous, object, callback) => {
29
- const composed = { ...previous }
30
-
31
- Object.keys(object).forEach((key) => {
32
- composed[key] =
33
- key in composed ? callback(composed[key], object[key]) : object[key]
34
- })
35
-
36
- return composed
37
- }
@@ -1,64 +0,0 @@
1
- import { findHighestVersion } from "../semantic-versioning/index.js"
2
- import { jsenvBabelPluginCompatMap } from "../../jsenvBabelPluginCompatMap.js"
3
-
4
- export const computeBabelPluginMapForRuntime = ({
5
- babelPluginMap,
6
- babelPluginCompatMap = jsenvBabelPluginCompatMap,
7
- runtimeName,
8
- runtimeVersion,
9
- }) => {
10
- if (typeof babelPluginMap !== "object") {
11
- throw new TypeError(
12
- `babelPluginMap must be an object, got ${babelPluginMap}`,
13
- )
14
- }
15
- if (typeof babelPluginCompatMap !== "object") {
16
- throw new TypeError(
17
- `babelPluginCompatMap must be an object, got ${babelPluginCompatMap}`,
18
- )
19
- }
20
- if (typeof runtimeName !== "string") {
21
- throw new TypeError(`runtimeName must be a string, got ${runtimeName}`)
22
- }
23
- if (typeof runtimeVersion !== "string") {
24
- throw new TypeError(
25
- `runtimeVersion must be a string, got ${runtimeVersion}`,
26
- )
27
- }
28
-
29
- const babelPluginMapForRuntime = {}
30
- Object.keys(babelPluginMap).forEach((key) => {
31
- const compatible = runtimeIsCompatibleWithFeature({
32
- runtimeName,
33
- runtimeVersion,
34
- runtimeCompatMap:
35
- key in babelPluginCompatMap ? babelPluginCompatMap[key] : {},
36
- })
37
- if (!compatible) {
38
- babelPluginMapForRuntime[key] = babelPluginMap[key]
39
- }
40
- })
41
- return babelPluginMapForRuntime
42
- }
43
-
44
- const runtimeIsCompatibleWithFeature = ({
45
- runtimeName,
46
- runtimeVersion,
47
- runtimeCompatMap,
48
- }) => {
49
- const runtimeCompatibleVersion = computeRuntimeCompatibleVersion({
50
- runtimeCompatMap,
51
- runtimeName,
52
- })
53
- const highestVersion = findHighestVersion(
54
- runtimeVersion,
55
- runtimeCompatibleVersion,
56
- )
57
- return highestVersion === runtimeVersion
58
- }
59
-
60
- const computeRuntimeCompatibleVersion = ({ runtimeCompatMap, runtimeName }) => {
61
- return runtimeName in runtimeCompatMap
62
- ? runtimeCompatMap[runtimeName]
63
- : "Infinity"
64
- }
@@ -1,62 +0,0 @@
1
- import { findHighestVersion } from "../semantic-versioning/index.js"
2
- import { jsenvPluginCompatMap as jsenvPluginCompatMapFallback } from "../../jsenvPluginCompatMap.js"
3
-
4
- export const computeJsenvPluginMapForRuntime = ({
5
- jsenvPluginMap,
6
- jsenvPluginCompatMap = jsenvPluginCompatMapFallback,
7
- runtimeName,
8
- runtimeVersion,
9
- }) => {
10
- if (typeof jsenvPluginMap !== "object") {
11
- throw new TypeError(
12
- `jsenvPluginMap must be a object, got ${jsenvPluginMap}`,
13
- )
14
- }
15
- if (typeof jsenvPluginCompatMap !== "object") {
16
- throw new TypeError(
17
- `jsenvPluginCompatMap must be a string, got ${jsenvPluginCompatMap}`,
18
- )
19
- }
20
- if (typeof runtimeName !== "string") {
21
- throw new TypeError(`runtimeName must be a string, got ${runtimeName}`)
22
- }
23
- if (typeof runtimeVersion !== "string") {
24
- throw new TypeError(
25
- `runtimeVersion must be a string, got ${runtimeVersion}`,
26
- )
27
- }
28
-
29
- const jsenvPluginMapForRuntime = {}
30
- Object.keys(jsenvPluginMap).forEach((key) => {
31
- const compatible = runtimeIsCompatibleWithFeature({
32
- runtimeName,
33
- runtimeVersion,
34
- featureCompat:
35
- key in jsenvPluginCompatMap ? jsenvPluginCompatMap[key] : {},
36
- })
37
- if (!compatible) {
38
- jsenvPluginMapForRuntime[key] = jsenvPluginMap[key]
39
- }
40
- })
41
- return jsenvPluginMapForRuntime
42
- }
43
-
44
- const runtimeIsCompatibleWithFeature = ({
45
- runtimeName,
46
- runtimeVersion,
47
- featureCompat,
48
- }) => {
49
- const runtimeCompatibleVersion = computeRuntimeCompatibleVersion({
50
- featureCompat,
51
- runtimeName,
52
- })
53
- const highestVersion = findHighestVersion(
54
- runtimeVersion,
55
- runtimeCompatibleVersion,
56
- )
57
- return highestVersion === runtimeVersion
58
- }
59
-
60
- const computeRuntimeCompatibleVersion = ({ featureCompat, runtimeName }) => {
61
- return runtimeName in featureCompat ? featureCompat[runtimeName] : "Infinity"
62
- }
@@ -1,22 +0,0 @@
1
- import { generateRuntimeGroupArray } from "./generateRuntimeGroupArray.js"
2
- import { composeGroupArray } from "./composeGroupArray.js"
3
-
4
- export const generateAllRuntimeGroupArray = ({
5
- babelPluginMap,
6
- jsenvPluginMap,
7
- babelPluginCompatMap,
8
- jsenvPluginCompatMap,
9
- runtimeNames,
10
- }) => {
11
- const arrayOfGroupArray = runtimeNames.map((runtimeName) =>
12
- generateRuntimeGroupArray({
13
- babelPluginMap,
14
- jsenvPluginMap,
15
- babelPluginCompatMap,
16
- jsenvPluginCompatMap,
17
- runtimeName,
18
- }),
19
- )
20
- const groupArray = composeGroupArray(...arrayOfGroupArray)
21
- return groupArray
22
- }
@@ -1,91 +0,0 @@
1
- import {
2
- findHighestVersion,
3
- versionCompare,
4
- } from "../semantic-versioning/index.js"
5
- import { jsenvBabelPluginCompatMap } from "../../jsenvBabelPluginCompatMap.js"
6
- import { jsenvPluginCompatMap as jsenvPluginCompatMapFallback } from "../../jsenvPluginCompatMap.js"
7
- import { computeBabelPluginMapForRuntime } from "./computeBabelPluginMapForRuntime.js"
8
- import { computeJsenvPluginMapForRuntime } from "./computeJsenvPluginMapForRuntime.js"
9
- import { groupHaveSameRequirements } from "./groupHaveSameRequirements.js"
10
-
11
- export const generateRuntimeGroupArray = ({
12
- babelPluginMap,
13
- jsenvPluginMap,
14
- babelPluginCompatMap = jsenvBabelPluginCompatMap,
15
- jsenvPluginCompatMap = jsenvPluginCompatMapFallback,
16
- runtimeName,
17
- }) => {
18
- const versionArray = []
19
- Object.keys(babelPluginMap).forEach((babelPluginKey) => {
20
- if (babelPluginKey in babelPluginCompatMap) {
21
- const babelPluginCompat = babelPluginCompatMap[babelPluginKey]
22
- if (runtimeName in babelPluginCompat) {
23
- const version = String(babelPluginCompat[runtimeName])
24
- if (!versionArray.includes(version)) {
25
- versionArray.push(version)
26
- }
27
- }
28
- }
29
- })
30
- Object.keys(jsenvPluginMap).forEach((jsenvPluginKey) => {
31
- if (jsenvPluginKey in jsenvPluginCompatMap) {
32
- const jsenvPluginCompat = jsenvPluginCompatMap[jsenvPluginKey]
33
- if (runtimeName in jsenvPluginCompat) {
34
- const version = String(jsenvPluginCompat[runtimeName])
35
- if (!versionArray.includes(version)) {
36
- versionArray.push(version)
37
- }
38
- }
39
- }
40
- })
41
- versionArray.push("0.0.0")
42
- versionArray.sort(versionCompare)
43
-
44
- const runtimeGroupArray = []
45
-
46
- versionArray.forEach((version) => {
47
- const babelPluginMapForRuntime = computeBabelPluginMapForRuntime({
48
- babelPluginMap,
49
- babelPluginCompatMap,
50
- runtimeName,
51
- runtimeVersion: version,
52
- })
53
- const babelPluginRequiredNameArray = Object.keys(babelPluginMap)
54
- .filter((babelPluginKey) => babelPluginKey in babelPluginMapForRuntime)
55
- .sort()
56
- const jsenvPluginMapForRuntime = computeJsenvPluginMapForRuntime({
57
- jsenvPluginMap,
58
- jsenvPluginCompatMap,
59
- runtimeName,
60
- runtimeVersion: version,
61
- })
62
- const jsenvPluginRequiredNameArray = Object.keys(jsenvPluginMap)
63
- .filter((jsenvPluginKey) => jsenvPluginKey in jsenvPluginMapForRuntime)
64
- .sort()
65
-
66
- const group = {
67
- babelPluginRequiredNameArray,
68
- jsenvPluginRequiredNameArray,
69
- runtimeCompatMap: {
70
- [runtimeName]: version,
71
- },
72
- }
73
-
74
- const groupWithSameRequirements = runtimeGroupArray.find(
75
- (runtimeGroupCandidate) =>
76
- groupHaveSameRequirements(runtimeGroupCandidate, group),
77
- )
78
-
79
- if (groupWithSameRequirements) {
80
- groupWithSameRequirements.runtimeCompatMap[runtimeName] =
81
- findHighestVersion(
82
- groupWithSameRequirements.runtimeCompatMap[runtimeName],
83
- version,
84
- )
85
- } else {
86
- runtimeGroupArray.push(group)
87
- }
88
- })
89
-
90
- return runtimeGroupArray
91
- }
@@ -1,8 +0,0 @@
1
- export const groupHaveSameRequirements = (leftGroup, rightGroup) => {
2
- return (
3
- leftGroup.babelPluginRequiredNameArray.join("") ===
4
- rightGroup.babelPluginRequiredNameArray.join("") &&
5
- leftGroup.jsenvPluginRequiredNameArray.join("") ===
6
- rightGroup.jsenvPluginRequiredNameArray.join("")
7
- )
8
- }
@@ -1,39 +0,0 @@
1
- import {
2
- versionCompare,
3
- findHighestVersion,
4
- } from "../semantic-versioning/index.js"
5
-
6
- export const runtimeCompatMapToScore = (runtimeCompatMap, runtimeScoreMap) => {
7
- return Object.keys(runtimeCompatMap).reduce((previous, runtimeName) => {
8
- const runtimeVersion = runtimeCompatMap[runtimeName]
9
- return (
10
- previous + runtimeToScore(runtimeName, runtimeVersion, runtimeScoreMap)
11
- )
12
- }, 0)
13
- }
14
-
15
- const runtimeToScore = (runtimeName, runtimeVersion, runtimeScoreMap) => {
16
- if (runtimeName in runtimeScoreMap === false)
17
- return runtimeScoreMap.other || 0
18
-
19
- const versionUsageMap = runtimeScoreMap[runtimeName]
20
- const versionArray = Object.keys(versionUsageMap)
21
- if (versionArray.length === 0) return runtimeScoreMap.other || 0
22
-
23
- const versionArrayAscending = versionArray.sort(versionCompare)
24
- const highestVersion = versionArrayAscending[versionArray.length - 1]
25
-
26
- if (findHighestVersion(runtimeVersion, highestVersion) === runtimeVersion)
27
- return versionUsageMap[highestVersion]
28
-
29
- const closestVersion = versionArrayAscending
30
- .reverse()
31
- .find(
32
- (version) =>
33
- findHighestVersion(runtimeVersion, version) === runtimeVersion,
34
- )
35
-
36
- if (!closestVersion) return runtimeScoreMap.other || 0
37
-
38
- return versionUsageMap[closestVersion]
39
- }
@@ -1,27 +0,0 @@
1
- // https://www.statista.com/statistics/268299/most-popular-internet-browsers/
2
- // this source of stat is what I found in 5min
3
- // we could improve these default usage score using better stats
4
- // and keep in mind this should be updated time to time or even better
5
- // come from a project specific audience
6
-
7
- export const jsenvBrowserScoreMap = {
8
- android: 0.001,
9
- chrome: {
10
- 71: 0.3,
11
- 69: 0.19,
12
- 0: 0.01, // it means oldest version of chrome will get a score of 0.01
13
- },
14
- firefox: {
15
- 61: 0.3,
16
- },
17
- edge: {
18
- 12: 0.1,
19
- },
20
- electron: 0.001,
21
- ios: 0.001,
22
- opera: 0.001,
23
- other: 0.001,
24
- safari: {
25
- 10: 0.1,
26
- },
27
- }
@@ -1,12 +0,0 @@
1
- // https://nodejs.org/metrics/summaries/version/nodejs.org-access.log.csv
2
- export const jsenvNodeVersionScoreMap = {
3
- "0.10": 0.02,
4
- "0.12": 0.01,
5
- "4": 0.1,
6
- "6": 0.25,
7
- "7": 0.1,
8
- "8": 1,
9
- "9": 0.1,
10
- "10": 0.5,
11
- "11": 0.25,
12
- }