@jsenv/core 39.3.9 → 39.3.11
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_core.js
CHANGED
|
@@ -17104,17 +17104,44 @@ const jsenvPluginInlineContentFetcher = () => {
|
|
|
17104
17104
|
if (!urlInfo.isInline) {
|
|
17105
17105
|
return null;
|
|
17106
17106
|
}
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17107
|
+
let isDirectRequestToFile;
|
|
17108
|
+
if (urlInfo.context.request) {
|
|
17109
|
+
const requestedUrl = new URL(
|
|
17110
|
+
urlInfo.context.request.resource.slice(1),
|
|
17111
|
+
urlInfo.context.rootDirectoryUrl,
|
|
17112
|
+
).href;
|
|
17113
|
+
isDirectRequestToFile = requestedUrl === urlInfo.url;
|
|
17114
|
+
}
|
|
17115
|
+
/*
|
|
17116
|
+
* We want to find inline content but it's not straightforward
|
|
17117
|
+
*
|
|
17118
|
+
* For some reason (that would be great to investigate)
|
|
17119
|
+
* urlInfo corresponding to inline content has several referenceFromOthersSet
|
|
17120
|
+
* so the latest version is the last reference
|
|
17121
|
+
* BUT the last reference is the "http_request"
|
|
17122
|
+
* so it's more likely the before last reference that contains the latest version
|
|
17123
|
+
*
|
|
17124
|
+
* BUT the is an exception when using supervisor as the before last reference
|
|
17125
|
+
* is the one fetched by the browser that is already cooked
|
|
17126
|
+
* we must re-cook from the original content, not from the already cooked content
|
|
17127
|
+
* Otherwise references are already resolved and
|
|
17128
|
+
* - "/node_modules/package/file.js" instead of "package/file.js"
|
|
17129
|
+
* - meaning we would not create the implicit dependency to package.json
|
|
17130
|
+
* - resulting in a reload of the browser (as implicit reference to package.json is gone)
|
|
17131
|
+
* -> can create infinite loop of reloads
|
|
17132
|
+
*/
|
|
17110
17133
|
let lastInlineReference;
|
|
17111
17134
|
let originalContent = urlInfo.originalContent;
|
|
17112
17135
|
for (const reference of urlInfo.referenceFromOthersSet) {
|
|
17113
|
-
if (reference.isInline) {
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17136
|
+
if (!reference.isInline) {
|
|
17137
|
+
continue;
|
|
17138
|
+
}
|
|
17139
|
+
if (urlInfo.originalContent === undefined) {
|
|
17140
|
+
originalContent = reference.content;
|
|
17141
|
+
}
|
|
17142
|
+
lastInlineReference = reference;
|
|
17143
|
+
if (isDirectRequestToFile) {
|
|
17144
|
+
break;
|
|
17118
17145
|
}
|
|
17119
17146
|
}
|
|
17120
17147
|
const { prev } = lastInlineReference;
|
|
@@ -17136,12 +17163,6 @@ const jsenvPluginInlineContentFetcher = () => {
|
|
|
17136
17163
|
return {
|
|
17137
17164
|
originalContent,
|
|
17138
17165
|
content:
|
|
17139
|
-
// we must favor original content to re-apply the same plugin logic
|
|
17140
|
-
// so that the same references are generated
|
|
17141
|
-
// without this we would try to resolve references like
|
|
17142
|
-
// "/node_modules/package/file.js" instead of "package/file.js"
|
|
17143
|
-
// meaning we would not create the implicit dependency to package.json
|
|
17144
|
-
// resulting in a reload of the browser (as implicit reference to package.json is gone)
|
|
17145
17166
|
originalContent === undefined
|
|
17146
17167
|
? lastInlineReference.content
|
|
17147
17168
|
: originalContent,
|
package/package.json
CHANGED
|
@@ -41,17 +41,44 @@ const jsenvPluginInlineContentFetcher = () => {
|
|
|
41
41
|
if (!urlInfo.isInline) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
let isDirectRequestToFile;
|
|
45
|
+
if (urlInfo.context.request) {
|
|
46
|
+
const requestedUrl = new URL(
|
|
47
|
+
urlInfo.context.request.resource.slice(1),
|
|
48
|
+
urlInfo.context.rootDirectoryUrl,
|
|
49
|
+
).href;
|
|
50
|
+
isDirectRequestToFile = requestedUrl === urlInfo.url;
|
|
51
|
+
}
|
|
52
|
+
/*
|
|
53
|
+
* We want to find inline content but it's not straightforward
|
|
54
|
+
*
|
|
55
|
+
* For some reason (that would be great to investigate)
|
|
56
|
+
* urlInfo corresponding to inline content has several referenceFromOthersSet
|
|
57
|
+
* so the latest version is the last reference
|
|
58
|
+
* BUT the last reference is the "http_request"
|
|
59
|
+
* so it's more likely the before last reference that contains the latest version
|
|
60
|
+
*
|
|
61
|
+
* BUT the is an exception when using supervisor as the before last reference
|
|
62
|
+
* is the one fetched by the browser that is already cooked
|
|
63
|
+
* we must re-cook from the original content, not from the already cooked content
|
|
64
|
+
* Otherwise references are already resolved and
|
|
65
|
+
* - "/node_modules/package/file.js" instead of "package/file.js"
|
|
66
|
+
* - meaning we would not create the implicit dependency to package.json
|
|
67
|
+
* - resulting in a reload of the browser (as implicit reference to package.json is gone)
|
|
68
|
+
* -> can create infinite loop of reloads
|
|
69
|
+
*/
|
|
47
70
|
let lastInlineReference;
|
|
48
71
|
let originalContent = urlInfo.originalContent;
|
|
49
72
|
for (const reference of urlInfo.referenceFromOthersSet) {
|
|
50
|
-
if (reference.isInline) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
73
|
+
if (!reference.isInline) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (urlInfo.originalContent === undefined) {
|
|
77
|
+
originalContent = reference.content;
|
|
78
|
+
}
|
|
79
|
+
lastInlineReference = reference;
|
|
80
|
+
if (isDirectRequestToFile) {
|
|
81
|
+
break;
|
|
55
82
|
}
|
|
56
83
|
}
|
|
57
84
|
const { prev } = lastInlineReference;
|
|
@@ -73,12 +100,6 @@ const jsenvPluginInlineContentFetcher = () => {
|
|
|
73
100
|
return {
|
|
74
101
|
originalContent,
|
|
75
102
|
content:
|
|
76
|
-
// we must favor original content to re-apply the same plugin logic
|
|
77
|
-
// so that the same references are generated
|
|
78
|
-
// without this we would try to resolve references like
|
|
79
|
-
// "/node_modules/package/file.js" instead of "package/file.js"
|
|
80
|
-
// meaning we would not create the implicit dependency to package.json
|
|
81
|
-
// resulting in a reload of the browser (as implicit reference to package.json is gone)
|
|
82
103
|
originalContent === undefined
|
|
83
104
|
? lastInlineReference.content
|
|
84
105
|
: originalContent,
|