ses 2.3.0 → 2.3.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.
- package/CHANGELOG.md +8 -0
- package/dist/lockdown.cjs +93 -8
- package/dist/lockdown.mjs +93 -8
- package/dist/lockdown.umd.js +93 -8
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses-hermes.cjs +93 -8
- package/dist/ses.cjs +93 -8
- package/dist/ses.mjs +93 -8
- package/dist/ses.umd.js +93 -8
- package/dist/ses.umd.min.js +1 -1
- package/package.json +1 -1
- package/src/transforms.js +91 -6
package/dist/ses-hermes.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ses@2.3.
|
|
1
|
+
// ses@2.3.1
|
|
2
2
|
(functors => options => {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -9017,7 +9017,8 @@ const sourceMetaEntriesRegExp = freezeRegexp(
|
|
|
9017
9017
|
})()
|
|
9018
9018
|
,
|
|
9019
9019
|
// === 35. ses ./src/transforms.js ===
|
|
9020
|
-
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9020
|
+
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpExec,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9021
|
+
|
|
9021
9022
|
|
|
9022
9023
|
|
|
9023
9024
|
|
|
@@ -9129,9 +9130,79 @@ const htmlCommentPattern = sealRegexp(
|
|
|
9129
9130
|
// /////////////////////////////////////////////////////////////////////////////
|
|
9130
9131
|
$h͏_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
9131
9132
|
const importPattern = sealRegexp(
|
|
9132
|
-
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(
|
|
9133
|
+
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|\\.|/[/*]))', 'g'),
|
|
9134
|
+
);
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* Matches one line of a run of `//# sourceURL=` and `//# sourceMappingURL=`
|
|
9138
|
+
* comments at the very end of the source (`sourceMetaTrailerStart` finds
|
|
9139
|
+
* the run), as module-source, compartment-mapper and
|
|
9140
|
+
* bundlers append to evaluated code (a module's location may well contain
|
|
9141
|
+
* `import.`, as in `conditional-import.js`).
|
|
9142
|
+
*
|
|
9143
|
+
* Each line must begin at a line start and its value must hold no whitespace
|
|
9144
|
+
* and none of `*`, backtick, `$`, quotes or backslash. Such a line is inert
|
|
9145
|
+
* wherever it stands: outside any literal it is a line comment; a regular
|
|
9146
|
+
* expression literal cannot span lines; and inside a block comment, a string
|
|
9147
|
+
* continued from the line before or a template literal, the line can neither
|
|
9148
|
+
* close that context (no `*`, quote or backtick) nor open a substitution (no
|
|
9149
|
+
* `$`). Since nothing but whitespace follows the run, an unclosed context
|
|
9150
|
+
* there is a SyntaxError. So `rejectImportExpressions` need not scan it.
|
|
9151
|
+
*
|
|
9152
|
+
* A `/*# sourceMappingURL=` block comment is not skipped but scanned like
|
|
9153
|
+
* any other code, which can only make the check stricter.
|
|
9154
|
+
*/
|
|
9155
|
+
const sourceMetaLinePattern = freezeRegexp(
|
|
9156
|
+
new FERAL_REG_EXP('^//# source(?:Mapping)?URL=[^\\s*`$\'"\\\\]*$'),
|
|
9157
|
+
);
|
|
9158
|
+
|
|
9159
|
+
const whitespacePattern = freezeRegexp(new FERAL_REG_EXP('^\\s$'));
|
|
9160
|
+
|
|
9161
|
+
const lineTerminatorPattern = freezeRegexp(
|
|
9162
|
+
new FERAL_REG_EXP('^[\\n\\r\\u2028\\u2029]$'),
|
|
9133
9163
|
);
|
|
9134
9164
|
|
|
9165
|
+
/**
|
|
9166
|
+
* Returns the index at which the trailing run of source meta comments
|
|
9167
|
+
* begins, at its leading line terminator if it has one, or the length of
|
|
9168
|
+
* the source if there is no such run. It reads the source backward, one
|
|
9169
|
+
* line at a time, and tests each line with `sourceMetaLinePattern` alone,
|
|
9170
|
+
* so it takes time linear in the length of the source. A single regular
|
|
9171
|
+
* expression for the whole run, `(?:(?:^|[\n\r\u2028\u2029])<line>)+\s*$`,
|
|
9172
|
+
* finds the same run, but a search retries it at every line terminator,
|
|
9173
|
+
* which takes time quadratic in the number of lines of the run.
|
|
9174
|
+
*
|
|
9175
|
+
* @param {string} src
|
|
9176
|
+
* @returns {number}
|
|
9177
|
+
*/
|
|
9178
|
+
const sourceMetaTrailerStart = src => {
|
|
9179
|
+
let end = src.length;
|
|
9180
|
+
while (end > 0 && regexpExec(whitespacePattern, src[end - 1]) !== null) {
|
|
9181
|
+
end -= 1;
|
|
9182
|
+
}
|
|
9183
|
+
let start = src.length;
|
|
9184
|
+
for (;;) {
|
|
9185
|
+
let lineStart = end;
|
|
9186
|
+
while (
|
|
9187
|
+
lineStart > 0 &&
|
|
9188
|
+
regexpExec(lineTerminatorPattern, src[lineStart - 1]) === null
|
|
9189
|
+
) {
|
|
9190
|
+
lineStart -= 1;
|
|
9191
|
+
}
|
|
9192
|
+
if (
|
|
9193
|
+
regexpExec(sourceMetaLinePattern, stringSlice(src, lineStart, end)) ===
|
|
9194
|
+
null
|
|
9195
|
+
) {
|
|
9196
|
+
return start;
|
|
9197
|
+
}
|
|
9198
|
+
if (lineStart === 0) {
|
|
9199
|
+
return 0;
|
|
9200
|
+
}
|
|
9201
|
+
start = lineStart - 1;
|
|
9202
|
+
end = lineStart - 1;
|
|
9203
|
+
}
|
|
9204
|
+
};
|
|
9205
|
+
|
|
9135
9206
|
/**
|
|
9136
9207
|
* Conservatively reject the source text if it may contain a dynamic
|
|
9137
9208
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
@@ -9147,10 +9218,23 @@ const importPattern = sealRegexp(
|
|
|
9147
9218
|
* apparent import expressions in literal strings or comments.
|
|
9148
9219
|
*
|
|
9149
9220
|
* The current conservative rule looks for the identifier "import"
|
|
9150
|
-
* followed by either an open paren or something that looks like
|
|
9151
|
-
* beginning of a comment.
|
|
9152
|
-
*
|
|
9153
|
-
*
|
|
9221
|
+
* followed by either an open paren, a dot, or something that looks like
|
|
9222
|
+
* the beginning of a comment. The dot case rejects not just a
|
|
9223
|
+
* phase-qualified call such as `import.source(...)` or `import.defer(...)`,
|
|
9224
|
+
* but any property access under `import` at all, including `import.meta`,
|
|
9225
|
+
* regardless of whether the property is then called. This is broader than
|
|
9226
|
+
* strictly necessary: the substring "import." can occur incidentally, for
|
|
9227
|
+
* example in a module path or a comment, and such source text is rejected
|
|
9228
|
+
* too. That tradeoff is intentional: covering every `import.<name>` form,
|
|
9229
|
+
* called or not, without naming specific property names, is judged simpler
|
|
9230
|
+
* and safer than narrowing the match to the shape of a call. We assume that
|
|
9231
|
+
* we do not need to worry about html comment syntax because that was
|
|
9232
|
+
* already rejected by rejectHtmlComments.
|
|
9233
|
+
*
|
|
9234
|
+
* The scan stops short of a trailing run of `//# sourceURL=` or
|
|
9235
|
+
* `//# sourceMappingURL=` comments whose values could not end a comment,
|
|
9236
|
+
* string or template (see `sourceMetaTrailerStart`), so that a module
|
|
9237
|
+
* whose location contains `import.` still loads.
|
|
9154
9238
|
*
|
|
9155
9239
|
* this \s *must* match all kinds of syntax-defined whitespace. If e.g.
|
|
9156
9240
|
* U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) is treated as
|
|
@@ -9163,7 +9247,8 @@ const importPattern = sealRegexp(
|
|
|
9163
9247
|
* @returns {string}
|
|
9164
9248
|
*/
|
|
9165
9249
|
const rejectImportExpressions = src => {
|
|
9166
|
-
const
|
|
9250
|
+
const scanned = stringSlice(src, 0, sourceMetaTrailerStart(src));
|
|
9251
|
+
const lineNumber = getLineNumber(scanned, importPattern);
|
|
9167
9252
|
if (lineNumber < 0) {
|
|
9168
9253
|
return src;
|
|
9169
9254
|
}
|
package/dist/ses.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ses@2.3.
|
|
1
|
+
// ses@2.3.1
|
|
2
2
|
(functors => options => {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -9017,7 +9017,8 @@ const sourceMetaEntriesRegExp = freezeRegexp(
|
|
|
9017
9017
|
})()
|
|
9018
9018
|
,
|
|
9019
9019
|
// === 35. ses ./src/transforms.js ===
|
|
9020
|
-
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9020
|
+
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpExec,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9021
|
+
|
|
9021
9022
|
|
|
9022
9023
|
|
|
9023
9024
|
|
|
@@ -9129,9 +9130,79 @@ const htmlCommentPattern = sealRegexp(
|
|
|
9129
9130
|
// /////////////////////////////////////////////////////////////////////////////
|
|
9130
9131
|
$h͏_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
9131
9132
|
const importPattern = sealRegexp(
|
|
9132
|
-
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(
|
|
9133
|
+
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|\\.|/[/*]))', 'g'),
|
|
9134
|
+
);
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* Matches one line of a run of `//# sourceURL=` and `//# sourceMappingURL=`
|
|
9138
|
+
* comments at the very end of the source (`sourceMetaTrailerStart` finds
|
|
9139
|
+
* the run), as module-source, compartment-mapper and
|
|
9140
|
+
* bundlers append to evaluated code (a module's location may well contain
|
|
9141
|
+
* `import.`, as in `conditional-import.js`).
|
|
9142
|
+
*
|
|
9143
|
+
* Each line must begin at a line start and its value must hold no whitespace
|
|
9144
|
+
* and none of `*`, backtick, `$`, quotes or backslash. Such a line is inert
|
|
9145
|
+
* wherever it stands: outside any literal it is a line comment; a regular
|
|
9146
|
+
* expression literal cannot span lines; and inside a block comment, a string
|
|
9147
|
+
* continued from the line before or a template literal, the line can neither
|
|
9148
|
+
* close that context (no `*`, quote or backtick) nor open a substitution (no
|
|
9149
|
+
* `$`). Since nothing but whitespace follows the run, an unclosed context
|
|
9150
|
+
* there is a SyntaxError. So `rejectImportExpressions` need not scan it.
|
|
9151
|
+
*
|
|
9152
|
+
* A `/*# sourceMappingURL=` block comment is not skipped but scanned like
|
|
9153
|
+
* any other code, which can only make the check stricter.
|
|
9154
|
+
*/
|
|
9155
|
+
const sourceMetaLinePattern = freezeRegexp(
|
|
9156
|
+
new FERAL_REG_EXP('^//# source(?:Mapping)?URL=[^\\s*`$\'"\\\\]*$'),
|
|
9157
|
+
);
|
|
9158
|
+
|
|
9159
|
+
const whitespacePattern = freezeRegexp(new FERAL_REG_EXP('^\\s$'));
|
|
9160
|
+
|
|
9161
|
+
const lineTerminatorPattern = freezeRegexp(
|
|
9162
|
+
new FERAL_REG_EXP('^[\\n\\r\\u2028\\u2029]$'),
|
|
9133
9163
|
);
|
|
9134
9164
|
|
|
9165
|
+
/**
|
|
9166
|
+
* Returns the index at which the trailing run of source meta comments
|
|
9167
|
+
* begins, at its leading line terminator if it has one, or the length of
|
|
9168
|
+
* the source if there is no such run. It reads the source backward, one
|
|
9169
|
+
* line at a time, and tests each line with `sourceMetaLinePattern` alone,
|
|
9170
|
+
* so it takes time linear in the length of the source. A single regular
|
|
9171
|
+
* expression for the whole run, `(?:(?:^|[\n\r\u2028\u2029])<line>)+\s*$`,
|
|
9172
|
+
* finds the same run, but a search retries it at every line terminator,
|
|
9173
|
+
* which takes time quadratic in the number of lines of the run.
|
|
9174
|
+
*
|
|
9175
|
+
* @param {string} src
|
|
9176
|
+
* @returns {number}
|
|
9177
|
+
*/
|
|
9178
|
+
const sourceMetaTrailerStart = src => {
|
|
9179
|
+
let end = src.length;
|
|
9180
|
+
while (end > 0 && regexpExec(whitespacePattern, src[end - 1]) !== null) {
|
|
9181
|
+
end -= 1;
|
|
9182
|
+
}
|
|
9183
|
+
let start = src.length;
|
|
9184
|
+
for (;;) {
|
|
9185
|
+
let lineStart = end;
|
|
9186
|
+
while (
|
|
9187
|
+
lineStart > 0 &&
|
|
9188
|
+
regexpExec(lineTerminatorPattern, src[lineStart - 1]) === null
|
|
9189
|
+
) {
|
|
9190
|
+
lineStart -= 1;
|
|
9191
|
+
}
|
|
9192
|
+
if (
|
|
9193
|
+
regexpExec(sourceMetaLinePattern, stringSlice(src, lineStart, end)) ===
|
|
9194
|
+
null
|
|
9195
|
+
) {
|
|
9196
|
+
return start;
|
|
9197
|
+
}
|
|
9198
|
+
if (lineStart === 0) {
|
|
9199
|
+
return 0;
|
|
9200
|
+
}
|
|
9201
|
+
start = lineStart - 1;
|
|
9202
|
+
end = lineStart - 1;
|
|
9203
|
+
}
|
|
9204
|
+
};
|
|
9205
|
+
|
|
9135
9206
|
/**
|
|
9136
9207
|
* Conservatively reject the source text if it may contain a dynamic
|
|
9137
9208
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
@@ -9147,10 +9218,23 @@ const importPattern = sealRegexp(
|
|
|
9147
9218
|
* apparent import expressions in literal strings or comments.
|
|
9148
9219
|
*
|
|
9149
9220
|
* The current conservative rule looks for the identifier "import"
|
|
9150
|
-
* followed by either an open paren or something that looks like
|
|
9151
|
-
* beginning of a comment.
|
|
9152
|
-
*
|
|
9153
|
-
*
|
|
9221
|
+
* followed by either an open paren, a dot, or something that looks like
|
|
9222
|
+
* the beginning of a comment. The dot case rejects not just a
|
|
9223
|
+
* phase-qualified call such as `import.source(...)` or `import.defer(...)`,
|
|
9224
|
+
* but any property access under `import` at all, including `import.meta`,
|
|
9225
|
+
* regardless of whether the property is then called. This is broader than
|
|
9226
|
+
* strictly necessary: the substring "import." can occur incidentally, for
|
|
9227
|
+
* example in a module path or a comment, and such source text is rejected
|
|
9228
|
+
* too. That tradeoff is intentional: covering every `import.<name>` form,
|
|
9229
|
+
* called or not, without naming specific property names, is judged simpler
|
|
9230
|
+
* and safer than narrowing the match to the shape of a call. We assume that
|
|
9231
|
+
* we do not need to worry about html comment syntax because that was
|
|
9232
|
+
* already rejected by rejectHtmlComments.
|
|
9233
|
+
*
|
|
9234
|
+
* The scan stops short of a trailing run of `//# sourceURL=` or
|
|
9235
|
+
* `//# sourceMappingURL=` comments whose values could not end a comment,
|
|
9236
|
+
* string or template (see `sourceMetaTrailerStart`), so that a module
|
|
9237
|
+
* whose location contains `import.` still loads.
|
|
9154
9238
|
*
|
|
9155
9239
|
* this \s *must* match all kinds of syntax-defined whitespace. If e.g.
|
|
9156
9240
|
* U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) is treated as
|
|
@@ -9163,7 +9247,8 @@ const importPattern = sealRegexp(
|
|
|
9163
9247
|
* @returns {string}
|
|
9164
9248
|
*/
|
|
9165
9249
|
const rejectImportExpressions = src => {
|
|
9166
|
-
const
|
|
9250
|
+
const scanned = stringSlice(src, 0, sourceMetaTrailerStart(src));
|
|
9251
|
+
const lineNumber = getLineNumber(scanned, importPattern);
|
|
9167
9252
|
if (lineNumber < 0) {
|
|
9168
9253
|
return src;
|
|
9169
9254
|
}
|
package/dist/ses.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ses@2.3.
|
|
1
|
+
// ses@2.3.1
|
|
2
2
|
(functors => options => {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -9017,7 +9017,8 @@ const sourceMetaEntriesRegExp = freezeRegexp(
|
|
|
9017
9017
|
})()
|
|
9018
9018
|
,
|
|
9019
9019
|
// === 35. ses ./src/transforms.js ===
|
|
9020
|
-
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9020
|
+
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpExec,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9021
|
+
|
|
9021
9022
|
|
|
9022
9023
|
|
|
9023
9024
|
|
|
@@ -9129,9 +9130,79 @@ const htmlCommentPattern = sealRegexp(
|
|
|
9129
9130
|
// /////////////////////////////////////////////////////////////////////////////
|
|
9130
9131
|
$h͏_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
9131
9132
|
const importPattern = sealRegexp(
|
|
9132
|
-
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(
|
|
9133
|
+
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|\\.|/[/*]))', 'g'),
|
|
9134
|
+
);
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* Matches one line of a run of `//# sourceURL=` and `//# sourceMappingURL=`
|
|
9138
|
+
* comments at the very end of the source (`sourceMetaTrailerStart` finds
|
|
9139
|
+
* the run), as module-source, compartment-mapper and
|
|
9140
|
+
* bundlers append to evaluated code (a module's location may well contain
|
|
9141
|
+
* `import.`, as in `conditional-import.js`).
|
|
9142
|
+
*
|
|
9143
|
+
* Each line must begin at a line start and its value must hold no whitespace
|
|
9144
|
+
* and none of `*`, backtick, `$`, quotes or backslash. Such a line is inert
|
|
9145
|
+
* wherever it stands: outside any literal it is a line comment; a regular
|
|
9146
|
+
* expression literal cannot span lines; and inside a block comment, a string
|
|
9147
|
+
* continued from the line before or a template literal, the line can neither
|
|
9148
|
+
* close that context (no `*`, quote or backtick) nor open a substitution (no
|
|
9149
|
+
* `$`). Since nothing but whitespace follows the run, an unclosed context
|
|
9150
|
+
* there is a SyntaxError. So `rejectImportExpressions` need not scan it.
|
|
9151
|
+
*
|
|
9152
|
+
* A `/*# sourceMappingURL=` block comment is not skipped but scanned like
|
|
9153
|
+
* any other code, which can only make the check stricter.
|
|
9154
|
+
*/
|
|
9155
|
+
const sourceMetaLinePattern = freezeRegexp(
|
|
9156
|
+
new FERAL_REG_EXP('^//# source(?:Mapping)?URL=[^\\s*`$\'"\\\\]*$'),
|
|
9157
|
+
);
|
|
9158
|
+
|
|
9159
|
+
const whitespacePattern = freezeRegexp(new FERAL_REG_EXP('^\\s$'));
|
|
9160
|
+
|
|
9161
|
+
const lineTerminatorPattern = freezeRegexp(
|
|
9162
|
+
new FERAL_REG_EXP('^[\\n\\r\\u2028\\u2029]$'),
|
|
9133
9163
|
);
|
|
9134
9164
|
|
|
9165
|
+
/**
|
|
9166
|
+
* Returns the index at which the trailing run of source meta comments
|
|
9167
|
+
* begins, at its leading line terminator if it has one, or the length of
|
|
9168
|
+
* the source if there is no such run. It reads the source backward, one
|
|
9169
|
+
* line at a time, and tests each line with `sourceMetaLinePattern` alone,
|
|
9170
|
+
* so it takes time linear in the length of the source. A single regular
|
|
9171
|
+
* expression for the whole run, `(?:(?:^|[\n\r\u2028\u2029])<line>)+\s*$`,
|
|
9172
|
+
* finds the same run, but a search retries it at every line terminator,
|
|
9173
|
+
* which takes time quadratic in the number of lines of the run.
|
|
9174
|
+
*
|
|
9175
|
+
* @param {string} src
|
|
9176
|
+
* @returns {number}
|
|
9177
|
+
*/
|
|
9178
|
+
const sourceMetaTrailerStart = src => {
|
|
9179
|
+
let end = src.length;
|
|
9180
|
+
while (end > 0 && regexpExec(whitespacePattern, src[end - 1]) !== null) {
|
|
9181
|
+
end -= 1;
|
|
9182
|
+
}
|
|
9183
|
+
let start = src.length;
|
|
9184
|
+
for (;;) {
|
|
9185
|
+
let lineStart = end;
|
|
9186
|
+
while (
|
|
9187
|
+
lineStart > 0 &&
|
|
9188
|
+
regexpExec(lineTerminatorPattern, src[lineStart - 1]) === null
|
|
9189
|
+
) {
|
|
9190
|
+
lineStart -= 1;
|
|
9191
|
+
}
|
|
9192
|
+
if (
|
|
9193
|
+
regexpExec(sourceMetaLinePattern, stringSlice(src, lineStart, end)) ===
|
|
9194
|
+
null
|
|
9195
|
+
) {
|
|
9196
|
+
return start;
|
|
9197
|
+
}
|
|
9198
|
+
if (lineStart === 0) {
|
|
9199
|
+
return 0;
|
|
9200
|
+
}
|
|
9201
|
+
start = lineStart - 1;
|
|
9202
|
+
end = lineStart - 1;
|
|
9203
|
+
}
|
|
9204
|
+
};
|
|
9205
|
+
|
|
9135
9206
|
/**
|
|
9136
9207
|
* Conservatively reject the source text if it may contain a dynamic
|
|
9137
9208
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
@@ -9147,10 +9218,23 @@ const importPattern = sealRegexp(
|
|
|
9147
9218
|
* apparent import expressions in literal strings or comments.
|
|
9148
9219
|
*
|
|
9149
9220
|
* The current conservative rule looks for the identifier "import"
|
|
9150
|
-
* followed by either an open paren or something that looks like
|
|
9151
|
-
* beginning of a comment.
|
|
9152
|
-
*
|
|
9153
|
-
*
|
|
9221
|
+
* followed by either an open paren, a dot, or something that looks like
|
|
9222
|
+
* the beginning of a comment. The dot case rejects not just a
|
|
9223
|
+
* phase-qualified call such as `import.source(...)` or `import.defer(...)`,
|
|
9224
|
+
* but any property access under `import` at all, including `import.meta`,
|
|
9225
|
+
* regardless of whether the property is then called. This is broader than
|
|
9226
|
+
* strictly necessary: the substring "import." can occur incidentally, for
|
|
9227
|
+
* example in a module path or a comment, and such source text is rejected
|
|
9228
|
+
* too. That tradeoff is intentional: covering every `import.<name>` form,
|
|
9229
|
+
* called or not, without naming specific property names, is judged simpler
|
|
9230
|
+
* and safer than narrowing the match to the shape of a call. We assume that
|
|
9231
|
+
* we do not need to worry about html comment syntax because that was
|
|
9232
|
+
* already rejected by rejectHtmlComments.
|
|
9233
|
+
*
|
|
9234
|
+
* The scan stops short of a trailing run of `//# sourceURL=` or
|
|
9235
|
+
* `//# sourceMappingURL=` comments whose values could not end a comment,
|
|
9236
|
+
* string or template (see `sourceMetaTrailerStart`), so that a module
|
|
9237
|
+
* whose location contains `import.` still loads.
|
|
9154
9238
|
*
|
|
9155
9239
|
* this \s *must* match all kinds of syntax-defined whitespace. If e.g.
|
|
9156
9240
|
* U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) is treated as
|
|
@@ -9163,7 +9247,8 @@ const importPattern = sealRegexp(
|
|
|
9163
9247
|
* @returns {string}
|
|
9164
9248
|
*/
|
|
9165
9249
|
const rejectImportExpressions = src => {
|
|
9166
|
-
const
|
|
9250
|
+
const scanned = stringSlice(src, 0, sourceMetaTrailerStart(src));
|
|
9251
|
+
const lineNumber = getLineNumber(scanned, importPattern);
|
|
9167
9252
|
if (lineNumber < 0) {
|
|
9168
9253
|
return src;
|
|
9169
9254
|
}
|
package/dist/ses.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ses@2.3.
|
|
1
|
+
// ses@2.3.1
|
|
2
2
|
(functors => options => {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -9017,7 +9017,8 @@ const sourceMetaEntriesRegExp = freezeRegexp(
|
|
|
9017
9017
|
})()
|
|
9018
9018
|
,
|
|
9019
9019
|
// === 35. ses ./src/transforms.js ===
|
|
9020
|
-
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9020
|
+
({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,freezeRegexp,regexpExec,regexpReplace,regexpSearch,sealRegexp,stringSlice,stringSplit,freeze,getSourceURL;$h͏_imports([["./commons.js", [["FERAL_REG_EXP",[$h͏_a => (FERAL_REG_EXP = $h͏_a)]],["SyntaxError",[$h͏_a => (SyntaxError = $h͏_a)]],["freezeRegexp",[$h͏_a => (freezeRegexp = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["regexpSearch",[$h͏_a => (regexpSearch = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringSplit",[$h͏_a => (stringSplit = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]]]],["./get-source-url.js", [["getSourceURL",[$h͏_a => (getSourceURL = $h͏_a)]]]]]);
|
|
9021
|
+
|
|
9021
9022
|
|
|
9022
9023
|
|
|
9023
9024
|
|
|
@@ -9129,9 +9130,79 @@ const htmlCommentPattern = sealRegexp(
|
|
|
9129
9130
|
// /////////////////////////////////////////////////////////////////////////////
|
|
9130
9131
|
$h͏_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
9131
9132
|
const importPattern = sealRegexp(
|
|
9132
|
-
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(
|
|
9133
|
+
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|\\.|/[/*]))', 'g'),
|
|
9134
|
+
);
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* Matches one line of a run of `//# sourceURL=` and `//# sourceMappingURL=`
|
|
9138
|
+
* comments at the very end of the source (`sourceMetaTrailerStart` finds
|
|
9139
|
+
* the run), as module-source, compartment-mapper and
|
|
9140
|
+
* bundlers append to evaluated code (a module's location may well contain
|
|
9141
|
+
* `import.`, as in `conditional-import.js`).
|
|
9142
|
+
*
|
|
9143
|
+
* Each line must begin at a line start and its value must hold no whitespace
|
|
9144
|
+
* and none of `*`, backtick, `$`, quotes or backslash. Such a line is inert
|
|
9145
|
+
* wherever it stands: outside any literal it is a line comment; a regular
|
|
9146
|
+
* expression literal cannot span lines; and inside a block comment, a string
|
|
9147
|
+
* continued from the line before or a template literal, the line can neither
|
|
9148
|
+
* close that context (no `*`, quote or backtick) nor open a substitution (no
|
|
9149
|
+
* `$`). Since nothing but whitespace follows the run, an unclosed context
|
|
9150
|
+
* there is a SyntaxError. So `rejectImportExpressions` need not scan it.
|
|
9151
|
+
*
|
|
9152
|
+
* A `/*# sourceMappingURL=` block comment is not skipped but scanned like
|
|
9153
|
+
* any other code, which can only make the check stricter.
|
|
9154
|
+
*/
|
|
9155
|
+
const sourceMetaLinePattern = freezeRegexp(
|
|
9156
|
+
new FERAL_REG_EXP('^//# source(?:Mapping)?URL=[^\\s*`$\'"\\\\]*$'),
|
|
9157
|
+
);
|
|
9158
|
+
|
|
9159
|
+
const whitespacePattern = freezeRegexp(new FERAL_REG_EXP('^\\s$'));
|
|
9160
|
+
|
|
9161
|
+
const lineTerminatorPattern = freezeRegexp(
|
|
9162
|
+
new FERAL_REG_EXP('^[\\n\\r\\u2028\\u2029]$'),
|
|
9133
9163
|
);
|
|
9134
9164
|
|
|
9165
|
+
/**
|
|
9166
|
+
* Returns the index at which the trailing run of source meta comments
|
|
9167
|
+
* begins, at its leading line terminator if it has one, or the length of
|
|
9168
|
+
* the source if there is no such run. It reads the source backward, one
|
|
9169
|
+
* line at a time, and tests each line with `sourceMetaLinePattern` alone,
|
|
9170
|
+
* so it takes time linear in the length of the source. A single regular
|
|
9171
|
+
* expression for the whole run, `(?:(?:^|[\n\r\u2028\u2029])<line>)+\s*$`,
|
|
9172
|
+
* finds the same run, but a search retries it at every line terminator,
|
|
9173
|
+
* which takes time quadratic in the number of lines of the run.
|
|
9174
|
+
*
|
|
9175
|
+
* @param {string} src
|
|
9176
|
+
* @returns {number}
|
|
9177
|
+
*/
|
|
9178
|
+
const sourceMetaTrailerStart = src => {
|
|
9179
|
+
let end = src.length;
|
|
9180
|
+
while (end > 0 && regexpExec(whitespacePattern, src[end - 1]) !== null) {
|
|
9181
|
+
end -= 1;
|
|
9182
|
+
}
|
|
9183
|
+
let start = src.length;
|
|
9184
|
+
for (;;) {
|
|
9185
|
+
let lineStart = end;
|
|
9186
|
+
while (
|
|
9187
|
+
lineStart > 0 &&
|
|
9188
|
+
regexpExec(lineTerminatorPattern, src[lineStart - 1]) === null
|
|
9189
|
+
) {
|
|
9190
|
+
lineStart -= 1;
|
|
9191
|
+
}
|
|
9192
|
+
if (
|
|
9193
|
+
regexpExec(sourceMetaLinePattern, stringSlice(src, lineStart, end)) ===
|
|
9194
|
+
null
|
|
9195
|
+
) {
|
|
9196
|
+
return start;
|
|
9197
|
+
}
|
|
9198
|
+
if (lineStart === 0) {
|
|
9199
|
+
return 0;
|
|
9200
|
+
}
|
|
9201
|
+
start = lineStart - 1;
|
|
9202
|
+
end = lineStart - 1;
|
|
9203
|
+
}
|
|
9204
|
+
};
|
|
9205
|
+
|
|
9135
9206
|
/**
|
|
9136
9207
|
* Conservatively reject the source text if it may contain a dynamic
|
|
9137
9208
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
@@ -9147,10 +9218,23 @@ const importPattern = sealRegexp(
|
|
|
9147
9218
|
* apparent import expressions in literal strings or comments.
|
|
9148
9219
|
*
|
|
9149
9220
|
* The current conservative rule looks for the identifier "import"
|
|
9150
|
-
* followed by either an open paren or something that looks like
|
|
9151
|
-
* beginning of a comment.
|
|
9152
|
-
*
|
|
9153
|
-
*
|
|
9221
|
+
* followed by either an open paren, a dot, or something that looks like
|
|
9222
|
+
* the beginning of a comment. The dot case rejects not just a
|
|
9223
|
+
* phase-qualified call such as `import.source(...)` or `import.defer(...)`,
|
|
9224
|
+
* but any property access under `import` at all, including `import.meta`,
|
|
9225
|
+
* regardless of whether the property is then called. This is broader than
|
|
9226
|
+
* strictly necessary: the substring "import." can occur incidentally, for
|
|
9227
|
+
* example in a module path or a comment, and such source text is rejected
|
|
9228
|
+
* too. That tradeoff is intentional: covering every `import.<name>` form,
|
|
9229
|
+
* called or not, without naming specific property names, is judged simpler
|
|
9230
|
+
* and safer than narrowing the match to the shape of a call. We assume that
|
|
9231
|
+
* we do not need to worry about html comment syntax because that was
|
|
9232
|
+
* already rejected by rejectHtmlComments.
|
|
9233
|
+
*
|
|
9234
|
+
* The scan stops short of a trailing run of `//# sourceURL=` or
|
|
9235
|
+
* `//# sourceMappingURL=` comments whose values could not end a comment,
|
|
9236
|
+
* string or template (see `sourceMetaTrailerStart`), so that a module
|
|
9237
|
+
* whose location contains `import.` still loads.
|
|
9154
9238
|
*
|
|
9155
9239
|
* this \s *must* match all kinds of syntax-defined whitespace. If e.g.
|
|
9156
9240
|
* U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) is treated as
|
|
@@ -9163,7 +9247,8 @@ const importPattern = sealRegexp(
|
|
|
9163
9247
|
* @returns {string}
|
|
9164
9248
|
*/
|
|
9165
9249
|
const rejectImportExpressions = src => {
|
|
9166
|
-
const
|
|
9250
|
+
const scanned = stringSlice(src, 0, sourceMetaTrailerStart(src));
|
|
9251
|
+
const lineNumber = getLineNumber(scanned, importPattern);
|
|
9167
9252
|
if (lineNumber < 0) {
|
|
9168
9253
|
return src;
|
|
9169
9254
|
}
|