@marko/compiler 5.39.16 → 5.39.18
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.
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;
|
|
2
|
-
var _babelUtils = require("@marko/compiler/babel-utils");
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
3
2
|
var _crypto = require("crypto");
|
|
4
3
|
var _path = _interopRequireDefault(require("path"));
|
|
5
4
|
|
|
6
5
|
var t = _interopRequireWildcard(require("../babel-types"));
|
|
6
|
+
var _diagnostics = require("../babel-utils/diagnostics");
|
|
7
|
+
var _getFile = require("../babel-utils/get-file");
|
|
8
|
+
var _tags = require("../babel-utils/tags");
|
|
7
9
|
var _taglib = require("../taglib");
|
|
8
10
|
var _config = _interopRequireDefault(require("../taglib/config"));
|
|
9
11
|
var _buildCodeFrame = require("../util/build-code-frame");
|
|
@@ -15,8 +17,7 @@ var _parser = require("./parser");
|
|
|
15
17
|
var _migrate = require("./plugins/migrate");
|
|
16
18
|
var _transform = require("./plugins/transform");function _getRequireWildcardCache(e) {if ("function" != typeof WeakMap) return null;var r = new WeakMap(),t = new WeakMap();return (_getRequireWildcardCache = function (e) {return e ? t : r;})(e);}function _interopRequireWildcard(e, r) {if (!r && e && e.__esModule) return e;if (null === e || "object" != typeof e && "function" != typeof e) return { default: e };var t = _getRequireWildcardCache(r);if (t && t.has(e)) return t.get(e);var n = { __proto__: null },a = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];}return n.default = e, t && t.set(e, n), n;}
|
|
17
19
|
|
|
18
|
-
const SOURCE_FILES = new WeakMap();
|
|
19
|
-
let currentFile;var _default =
|
|
20
|
+
const SOURCE_FILES = new WeakMap();var _default =
|
|
20
21
|
|
|
21
22
|
(api, markoOpts) => {
|
|
22
23
|
api.assertVersion(7);
|
|
@@ -71,9 +72,9 @@ let currentFile;var _default =
|
|
|
71
72
|
const { buildError: prevBuildError } = file.hub;
|
|
72
73
|
const { buildCodeFrameError: prevCodeFrameError } = file;
|
|
73
74
|
const prevFS = _config.default.fs;
|
|
74
|
-
const prevFile =
|
|
75
|
+
const prevFile = (0, _getFile.getFileInternal)();
|
|
75
76
|
_config.default.fs = markoOpts.fileSystem;
|
|
76
|
-
|
|
77
|
+
(0, _getFile.setFileInternal)(file);
|
|
77
78
|
curOpts = undefined;
|
|
78
79
|
try {
|
|
79
80
|
const { ast, metadata } = file;
|
|
@@ -111,7 +112,7 @@ let currentFile;var _default =
|
|
|
111
112
|
file.path.scope.crawl(); // Ensure all scopes are accurate for subsequent babel plugins
|
|
112
113
|
} finally {
|
|
113
114
|
_config.default.fs = prevFS;
|
|
114
|
-
|
|
115
|
+
(0, _getFile.setFileInternal)(prevFile);
|
|
115
116
|
file.buildCodeFrameError = prevCodeFrameError;
|
|
116
117
|
file.hub.buildError = prevBuildError;
|
|
117
118
|
file.markoOpts =
|
|
@@ -145,22 +146,6 @@ let currentFile;var _default =
|
|
|
145
146
|
};
|
|
146
147
|
};exports.default = _default;
|
|
147
148
|
|
|
148
|
-
function getFile() {
|
|
149
|
-
if (currentFile) {
|
|
150
|
-
return currentFile;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
throw new Error("Unable to access Marko File outside of a compilation");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function getProgram() {
|
|
157
|
-
if (currentFile) {
|
|
158
|
-
return currentFile.path;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
throw new Error("Unable to access Marko Program outside of a compilation");
|
|
162
|
-
}
|
|
163
|
-
|
|
164
149
|
function getMarkoFile(code, fileOpts, markoOpts) {
|
|
165
150
|
const { translator } = markoOpts;
|
|
166
151
|
let compileCache = markoOpts.cache.get(translator);
|
|
@@ -173,7 +158,7 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
173
158
|
const isSource = markoOpts.output === "source";
|
|
174
159
|
const isMigrate = markoOpts.output === "migrate";
|
|
175
160
|
const canCache = !(isSource || isMigrate);
|
|
176
|
-
const id = (0,
|
|
161
|
+
const id = (0, _tags.getTemplateId)(markoOpts, filename);
|
|
177
162
|
const contentHash = canCache && (0, _crypto.createHash)("MD5").update(code).digest("hex");
|
|
178
163
|
const cacheKey = canCache && (0, _crypto.createHash)("MD5").update(id).digest("hex");
|
|
179
164
|
|
|
@@ -206,24 +191,26 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
206
191
|
}
|
|
207
192
|
|
|
208
193
|
const prevFs = _config.default.fs;
|
|
209
|
-
const prevFile =
|
|
194
|
+
const prevFile = (0, _getFile.getFileInternal)();
|
|
210
195
|
_config.default.fs = markoOpts.fileSystem;
|
|
211
196
|
|
|
212
197
|
try {
|
|
213
198
|
const taglibLookup = (0, _taglib.buildLookup)(_path.default.dirname(filename), translator);
|
|
214
|
-
const file =
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
199
|
+
const file = (0, _getFile.setFileInternal)(
|
|
200
|
+
new _file.MarkoFile(fileOpts, {
|
|
201
|
+
code,
|
|
202
|
+
ast: {
|
|
203
|
+
type: "File",
|
|
204
|
+
program: {
|
|
205
|
+
type: "Program",
|
|
206
|
+
sourceType: "module",
|
|
207
|
+
body: [],
|
|
208
|
+
directives: [],
|
|
209
|
+
params: [t.identifier("input")]
|
|
210
|
+
}
|
|
224
211
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
212
|
+
})
|
|
213
|
+
);
|
|
227
214
|
|
|
228
215
|
const meta = file.metadata.marko = {
|
|
229
216
|
id,
|
|
@@ -261,7 +248,7 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
261
248
|
if (markoOpts.errorRecovery) {
|
|
262
249
|
t.traverseFast(file.path.node, (node) => {
|
|
263
250
|
if (node.type === "MarkoParseError") {
|
|
264
|
-
(0,
|
|
251
|
+
(0, _diagnostics.diagnosticError)(file.path, {
|
|
265
252
|
label: node.label,
|
|
266
253
|
loc: node.errorLoc || node.loc
|
|
267
254
|
});
|
|
@@ -334,7 +321,7 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
334
321
|
return file;
|
|
335
322
|
} finally {
|
|
336
323
|
_config.default.fs = prevFs;
|
|
337
|
-
|
|
324
|
+
(0, _getFile.setFileInternal)(prevFile);
|
|
338
325
|
}
|
|
339
326
|
}
|
|
340
327
|
|
|
@@ -24,6 +24,8 @@ function computeNode(node) {
|
|
|
24
24
|
}
|
|
25
25
|
case "BigIntLiteral":
|
|
26
26
|
return { value: BigInt(node.value) };
|
|
27
|
+
case "ParenthesizedExpression":
|
|
28
|
+
return computeNode(node.expression);
|
|
27
29
|
case "BinaryExpression":{
|
|
28
30
|
const left = computeNode(node.left);
|
|
29
31
|
if (!left) return;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";exports.__esModule = true;exports.getFile = getFile;exports.getFileInternal = getFileInternal;exports.getProgram = getProgram;exports.setFileInternal = setFileInternal;let currentFile;
|
|
2
|
+
|
|
3
|
+
function getFile() {
|
|
4
|
+
if (currentFile) {
|
|
5
|
+
return currentFile;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
throw new Error("Unable to access Marko File outside of a compilation");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getProgram() {
|
|
12
|
+
if (currentFile) {
|
|
13
|
+
return currentFile.path;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
throw new Error("Unable to access Marko Program outside of a compilation");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getFileInternal() {
|
|
20
|
+
return currentFile;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function setFileInternal(file) {
|
|
24
|
+
return currentFile = file;
|
|
25
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"use strict";exports.__esModule = true;exports.computeNode = exports.assertNoVar = exports.assertNoParams = exports.assertNoAttributes = exports.assertNoAttributeTags = exports.assertNoArgs = exports.assertAttributesOrSingleArg = exports.assertAttributesOrArgs = exports.assertAllowedAttributes = exports.DiagnosticType = void 0;exports.defineTag = defineTag;exports.withLoc = exports.resolveTagImport = exports.resolveRelativePath = exports.registerMacro = exports.parseVar = exports.parseTypeParams = exports.parseTypeArgs = exports.parseTemplateLiteral = exports.parseStatements = exports.parseParams = exports.parseExpression = exports.parseArgs = exports.normalizeTemplateString = exports.loadFileForTag = exports.loadFileForImport = exports.isTransparentTag = exports.isNativeTag = exports.isMacroTag = exports.isLoopTag = exports.isDynamicTag = exports.isAttributeTag = exports.importStar = exports.importNamed = exports.importDefault = exports.hasMacro = exports.getTemplateId = exports.getTaglibLookup = exports.getTagTemplate = exports.getTagDefForTagName = exports.getTagDef = exports.getStart = exports.getProgram = exports.getMacroIdentifierForName = exports.getMacroIdentifier = exports.getLocRange = exports.getLoc = exports.getFullyResolvedTagName = exports.getFile = exports.getEnd = exports.getArgOrSequence = exports.findParentTag = exports.findAttributeTags = exports.diagnosticWarn = exports.diagnosticSuggest = exports.diagnosticError = exports.diagnosticDeprecate = void 0;var
|
|
2
|
-
var _assert = require("./assert");exports.assertAllowedAttributes = _assert.assertAllowedAttributes;exports.assertAttributesOrArgs = _assert.assertAttributesOrArgs;exports.assertAttributesOrSingleArg = _assert.assertAttributesOrSingleArg;exports.assertNoArgs = _assert.assertNoArgs;exports.assertNoAttributes = _assert.assertNoAttributes;exports.assertNoAttributeTags = _assert.assertNoAttributeTags;exports.assertNoParams = _assert.assertNoParams;exports.assertNoVar = _assert.assertNoVar;
|
|
1
|
+
"use strict";exports.__esModule = true;exports.computeNode = exports.assertNoVar = exports.assertNoParams = exports.assertNoAttributes = exports.assertNoAttributeTags = exports.assertNoArgs = exports.assertAttributesOrSingleArg = exports.assertAttributesOrArgs = exports.assertAllowedAttributes = exports.DiagnosticType = void 0;exports.defineTag = defineTag;exports.withLoc = exports.resolveTagImport = exports.resolveRelativePath = exports.registerMacro = exports.parseVar = exports.parseTypeParams = exports.parseTypeArgs = exports.parseTemplateLiteral = exports.parseStatements = exports.parseParams = exports.parseExpression = exports.parseArgs = exports.normalizeTemplateString = exports.loadFileForTag = exports.loadFileForImport = exports.isTransparentTag = exports.isNativeTag = exports.isMacroTag = exports.isLoopTag = exports.isDynamicTag = exports.isAttributeTag = exports.importStar = exports.importNamed = exports.importDefault = exports.hasMacro = exports.getTemplateId = exports.getTaglibLookup = exports.getTagTemplate = exports.getTagDefForTagName = exports.getTagDef = exports.getStart = exports.getProgram = exports.getMacroIdentifierForName = exports.getMacroIdentifier = exports.getLocRange = exports.getLoc = exports.getFullyResolvedTagName = exports.getFile = exports.getEnd = exports.getArgOrSequence = exports.findParentTag = exports.findAttributeTags = exports.diagnosticWarn = exports.diagnosticSuggest = exports.diagnosticError = exports.diagnosticDeprecate = void 0;var _assert = require("./assert");exports.assertAllowedAttributes = _assert.assertAllowedAttributes;exports.assertAttributesOrArgs = _assert.assertAttributesOrArgs;exports.assertAttributesOrSingleArg = _assert.assertAttributesOrSingleArg;exports.assertNoArgs = _assert.assertNoArgs;exports.assertNoAttributes = _assert.assertNoAttributes;exports.assertNoAttributeTags = _assert.assertNoAttributeTags;exports.assertNoParams = _assert.assertNoParams;exports.assertNoVar = _assert.assertNoVar;
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
|
|
@@ -17,6 +16,7 @@ var _diagnostics = require("./diagnostics");exports.diagnosticDeprecate = _diagn
|
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
|
|
19
|
+
var _getFile = require("./get-file");exports.getFile = _getFile.getFile;exports.getProgram = _getFile.getProgram;
|
|
20
20
|
var _imports = require("./imports");exports.importDefault = _imports.importDefault;exports.importNamed = _imports.importNamed;exports.importStar = _imports.importStar;exports.resolveRelativePath = _imports.resolveRelativePath;
|
|
21
21
|
|
|
22
22
|
|