marko 6.1.3 → 6.1.4
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/common/accessor.d.ts +5 -0
- package/dist/common/accessor.debug.d.ts +5 -0
- package/dist/common/compat-meta.d.ts +0 -1
- package/dist/common/opt.d.ts +3 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/debug/dom.js +283 -111
- package/dist/debug/dom.mjs +275 -112
- package/dist/debug/html.js +846 -576
- package/dist/debug/html.mjs +844 -577
- package/dist/dom/compat.d.ts +3 -2
- package/dist/dom/control-flow.d.ts +2 -1
- package/dist/dom/load.d.ts +23 -0
- package/dist/dom/queue.d.ts +3 -2
- package/dist/dom/resume.d.ts +10 -8
- package/dist/dom.d.ts +2 -1
- package/dist/dom.js +178 -58
- package/dist/dom.mjs +178 -58
- package/dist/html/assets.d.ts +47 -0
- package/dist/html/compat.d.ts +3 -2
- package/dist/html/serializer.d.ts +14 -9
- package/dist/html/writer.d.ts +34 -15
- package/dist/html.d.ts +1 -0
- package/dist/html.js +439 -268
- package/dist/html.mjs +439 -268
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +286 -38
- package/dist/translator/interop/index.d.ts +1 -0
- package/dist/translator/util/marko-config.d.ts +2 -0
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/tag-name-type.d.ts +2 -0
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/visitors/import-declaration.d.ts +10 -1
- package/dist/translator/visitors/tag/custom-tag.d.ts +7 -0
- package/package.json +2 -2
package/dist/translator/index.js
CHANGED
|
@@ -118,6 +118,7 @@ let AccessorProp$1 = /* @__PURE__ */ function(AccessorProp) {
|
|
|
118
118
|
AccessorProp["DetachedAwait"] = "#DetachedAwait";
|
|
119
119
|
AccessorProp["EndNode"] = "#EndNode";
|
|
120
120
|
AccessorProp["Id"] = "#Id";
|
|
121
|
+
AccessorProp["Load"] = "#Load";
|
|
121
122
|
AccessorProp["LoopKey"] = "#LoopKey";
|
|
122
123
|
AccessorProp["ParentBranch"] = "#ParentBranch";
|
|
123
124
|
AccessorProp["PendingEffects"] = "#PendingEffects";
|
|
@@ -248,8 +249,9 @@ function normalizeDynamicRenderer(value) {
|
|
|
248
249
|
const decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36);
|
|
249
250
|
//#endregion
|
|
250
251
|
//#region src/html/serializer.ts
|
|
252
|
+
const K_SCOPE_ID = Symbol("Scope ID");
|
|
251
253
|
const kTouchedIterator = Symbol.for("marko.touchedIterator");
|
|
252
|
-
const { hasOwnProperty } = {};
|
|
254
|
+
const { hasOwnProperty: hasOwnProperty$1 } = {};
|
|
253
255
|
const Generator = (function* () {})().constructor;
|
|
254
256
|
const AsyncGenerator = (async function* () {})().constructor;
|
|
255
257
|
patchIteratorNext(Generator.prototype);
|
|
@@ -1078,6 +1080,7 @@ let AccessorProp = /* @__PURE__ */ function(AccessorProp) {
|
|
|
1078
1080
|
AccessorProp["DetachedAwait"] = "V";
|
|
1079
1081
|
AccessorProp["EndNode"] = "K";
|
|
1080
1082
|
AccessorProp["Id"] = "L";
|
|
1083
|
+
AccessorProp["Load"] = "X";
|
|
1081
1084
|
AccessorProp["LoopKey"] = "M";
|
|
1082
1085
|
AccessorProp["ParentBranch"] = "N";
|
|
1083
1086
|
AccessorProp["PendingEffects"] = "J";
|
|
@@ -1104,6 +1107,11 @@ function getMarkoOpts() {
|
|
|
1104
1107
|
function isOptimize() {
|
|
1105
1108
|
return getMarkoOpts().optimize;
|
|
1106
1109
|
}
|
|
1110
|
+
function getReadyId(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
1111
|
+
const { markoOpts } = file;
|
|
1112
|
+
if (!markoOpts.linkAssets) return void 0;
|
|
1113
|
+
return (markoOpts.optimize ? "_" : "ready:") + (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, file.opts.filename);
|
|
1114
|
+
}
|
|
1107
1115
|
//#endregion
|
|
1108
1116
|
//#region src/translator/util/get-accessor-char.ts
|
|
1109
1117
|
function getAccessorPrefix() {
|
|
@@ -1340,6 +1348,7 @@ function analyzeExpressionTagName(name, extra) {
|
|
|
1340
1348
|
let type;
|
|
1341
1349
|
let nullable = false;
|
|
1342
1350
|
let tagNameImported;
|
|
1351
|
+
let tagNameLoad;
|
|
1343
1352
|
while ((path = pending.pop()) && type !== 2) if (path.isConditionalExpression()) {
|
|
1344
1353
|
pending.push(path.get("consequent"));
|
|
1345
1354
|
if (path.node.alternate) pending.push(path.get("alternate"));
|
|
@@ -1368,6 +1377,7 @@ function analyzeExpressionTagName(name, extra) {
|
|
|
1368
1377
|
if (type === void 0) {
|
|
1369
1378
|
type = 1;
|
|
1370
1379
|
tagNameImported = resolvedImport;
|
|
1380
|
+
tagNameLoad = decl.extra?.loadImport;
|
|
1371
1381
|
} else if (type === 0) {
|
|
1372
1382
|
type = 2;
|
|
1373
1383
|
tagNameImported = void 0;
|
|
@@ -1392,7 +1402,10 @@ function analyzeExpressionTagName(name, extra) {
|
|
|
1392
1402
|
} else type = 2;
|
|
1393
1403
|
extra.tagNameType = type ?? 2;
|
|
1394
1404
|
extra.tagNameNullable = nullable;
|
|
1395
|
-
if (type === 1 && tagNameImported)
|
|
1405
|
+
if (type === 1 && tagNameImported) {
|
|
1406
|
+
extra.tagNameImported = tagNameImported;
|
|
1407
|
+
extra.tagNameLoad = tagNameLoad;
|
|
1408
|
+
}
|
|
1396
1409
|
}
|
|
1397
1410
|
//#endregion
|
|
1398
1411
|
//#region src/translator/util/sections.ts
|
|
@@ -1851,7 +1864,6 @@ function _escape_comment(val) {
|
|
|
1851
1864
|
//#endregion
|
|
1852
1865
|
//#region src/html/writer.ts
|
|
1853
1866
|
let $chunk;
|
|
1854
|
-
const K_SCOPE_ID = Symbol("Scope ID");
|
|
1855
1867
|
function getContext(key) {
|
|
1856
1868
|
return $chunk.context?.[key];
|
|
1857
1869
|
}
|
|
@@ -1862,7 +1874,7 @@ function _html(html) {
|
|
|
1862
1874
|
$chunk.writeHTML(html);
|
|
1863
1875
|
}
|
|
1864
1876
|
function _script(scopeId, registryId) {
|
|
1865
|
-
if ($chunk.context?.[kIsAsync]) _resume_branch(scopeId);
|
|
1877
|
+
if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
|
|
1866
1878
|
$chunk.boundary.state.needsMainRuntime = true;
|
|
1867
1879
|
$chunk.writeEffect(scopeId, registryId);
|
|
1868
1880
|
}
|
|
@@ -1901,20 +1913,21 @@ function withBranchId(branchId, cb) {
|
|
|
1901
1913
|
return withContext(kBranchId, branchId, cb);
|
|
1902
1914
|
}
|
|
1903
1915
|
let writeScope = (scopeId, partialScope) => {
|
|
1904
|
-
|
|
1916
|
+
const { state } = $chunk.boundary;
|
|
1917
|
+
const target = $chunk.serializeState;
|
|
1918
|
+
const scope = scopeWithId(state, scopeId);
|
|
1919
|
+
const pending = target.writeScopes[scopeId];
|
|
1920
|
+
state.needsMainRuntime = true;
|
|
1921
|
+
Object.assign(scope, partialScope);
|
|
1922
|
+
if (pending && pending !== partialScope) Object.assign(pending, partialScope);
|
|
1923
|
+
else target.writeScopes[scopeId] = partialScope;
|
|
1924
|
+
target.flushScopes = true;
|
|
1925
|
+
return scope;
|
|
1905
1926
|
};
|
|
1906
|
-
function
|
|
1927
|
+
function scopeWithId(state, scopeId) {
|
|
1907
1928
|
const { scopes } = state;
|
|
1908
1929
|
let scope = scopes.get(scopeId);
|
|
1909
|
-
|
|
1910
|
-
if (scope) Object.assign(scope, partialScope);
|
|
1911
|
-
else {
|
|
1912
|
-
scope = partialScope;
|
|
1913
|
-
scope[K_SCOPE_ID] = scopeId;
|
|
1914
|
-
state.scopes.set(scopeId, scope);
|
|
1915
|
-
}
|
|
1916
|
-
if (state.writeScopes) state.writeScopes[scopeId] = scope;
|
|
1917
|
-
else state.writeScopes = { [scopeId]: scope };
|
|
1930
|
+
if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
|
|
1918
1931
|
return scope;
|
|
1919
1932
|
}
|
|
1920
1933
|
globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
|
|
@@ -2103,7 +2116,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2103
2116
|
const childScope = getScopeById(branchId);
|
|
2104
2117
|
const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
|
|
2105
2118
|
if (needsScript) {
|
|
2106
|
-
|
|
2119
|
+
writeScope(branchId, { ["#Renderer"]: renderer });
|
|
2107
2120
|
_script(branchId, "d");
|
|
2108
2121
|
}
|
|
2109
2122
|
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
@@ -2138,6 +2151,9 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2138
2151
|
};
|
|
2139
2152
|
})(_dynamic_tag);
|
|
2140
2153
|
//#endregion
|
|
2154
|
+
//#region src/html/assets.ts
|
|
2155
|
+
const { hasOwnProperty } = {};
|
|
2156
|
+
//#endregion
|
|
2141
2157
|
//#region src/translator/util/runtime.ts
|
|
2142
2158
|
const pureDOMFunctions = new Set([
|
|
2143
2159
|
"_await_promise",
|
|
@@ -2160,7 +2176,15 @@ const pureDOMFunctions = new Set([
|
|
|
2160
2176
|
"_for_until",
|
|
2161
2177
|
"_let",
|
|
2162
2178
|
"_let_change",
|
|
2163
|
-
"_const"
|
|
2179
|
+
"_const",
|
|
2180
|
+
"_load_signal",
|
|
2181
|
+
"_load_setup",
|
|
2182
|
+
"_load_template",
|
|
2183
|
+
"_load_visible_trigger",
|
|
2184
|
+
"_load_event_trigger",
|
|
2185
|
+
"_load_idle_trigger",
|
|
2186
|
+
"_load_media_trigger",
|
|
2187
|
+
"_load_race_trigger"
|
|
2164
2188
|
]);
|
|
2165
2189
|
function importRuntime(name) {
|
|
2166
2190
|
const { output } = getMarkoOpts();
|
|
@@ -3880,19 +3904,60 @@ var program_default = {
|
|
|
3880
3904
|
translate: {
|
|
3881
3905
|
enter(program) {
|
|
3882
3906
|
scopeIdentifier = isOutputDOM() ? generateUidIdentifier("scope") : null;
|
|
3883
|
-
|
|
3884
|
-
const
|
|
3885
|
-
const
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3907
|
+
{
|
|
3908
|
+
const markoOpts = getMarkoOpts();
|
|
3909
|
+
const { output, entry, runtimeId } = markoOpts;
|
|
3910
|
+
const isLoadEntry = entry === "load";
|
|
3911
|
+
const isDOMPageEntry = output === "dom" && entry === "page" || output === "hydrate";
|
|
3912
|
+
const isServerEntry = output === "html" && entry === "page";
|
|
3913
|
+
if (entry && !markoOpts.linkAssets) throw program.buildCodeFrameError("The \"entry\" option requires the `linkAssets` compiler option to be configured.");
|
|
3914
|
+
if (runtimeId && !/^[_$a-z][_$a-z0-9]*$/i.test(runtimeId)) throw program.buildCodeFrameError(`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`);
|
|
3915
|
+
if (isLoadEntry) {
|
|
3916
|
+
const entryFile = program.hub.file;
|
|
3917
|
+
const { filename } = entryFile.opts;
|
|
3918
|
+
const readyArgs = [_marko_compiler.types.stringLiteral(getReadyId(entryFile))];
|
|
3919
|
+
if (runtimeId) readyArgs.push(_marko_compiler.types.stringLiteral(runtimeId));
|
|
3920
|
+
program.node.body = [_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("ready"), _marko_compiler.types.identifier("ready"))], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))), _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename))]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("ready"), readyArgs))]))];
|
|
3921
|
+
program.skip();
|
|
3922
|
+
return;
|
|
3923
|
+
}
|
|
3924
|
+
if (isDOMPageEntry) {
|
|
3925
|
+
const entryFile = program.hub.file;
|
|
3926
|
+
const { filename } = entryFile.opts;
|
|
3927
|
+
const visitedFiles = new Set([(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename)]);
|
|
3928
|
+
entry_builder_default.visit(entryFile, entryFile, function visitChild(resolved) {
|
|
3929
|
+
if (!visitedFiles.has(resolved)) {
|
|
3930
|
+
visitedFiles.add(resolved);
|
|
3931
|
+
const file = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
|
|
3932
|
+
if (file) entry_builder_default.visit(file, entryFile, (id) => visitChild(resolveRelativeToEntry(entryFile, file, id)));
|
|
3933
|
+
}
|
|
3934
|
+
});
|
|
3935
|
+
program.node.body = entry_builder_default.build(entryFile);
|
|
3936
|
+
program.skip();
|
|
3937
|
+
return;
|
|
3938
|
+
}
|
|
3939
|
+
if (isServerEntry) {
|
|
3940
|
+
const entryFile = program.hub.file;
|
|
3941
|
+
const { filename } = entryFile.opts;
|
|
3942
|
+
const relativeImport = (0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename);
|
|
3943
|
+
const templateId = (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename);
|
|
3944
|
+
const pageAssetArgs = [
|
|
3945
|
+
_marko_compiler.types.identifier("template"),
|
|
3946
|
+
_marko_compiler.types.identifier("flush"),
|
|
3947
|
+
_marko_compiler.types.stringLiteral(templateId)
|
|
3948
|
+
];
|
|
3949
|
+
if (runtimeId) pageAssetArgs.push(_marko_compiler.types.stringLiteral(runtimeId));
|
|
3950
|
+
markoOpts.linkAssets.onAsset("page", filename, templateId);
|
|
3951
|
+
program.node.body = [
|
|
3952
|
+
_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("flush"), _marko_compiler.types.identifier("flush"))], _marko_compiler.types.stringLiteral(markoOpts.linkAssets.runtime)),
|
|
3953
|
+
_marko_compiler.types.importDeclaration([_marko_compiler.types.importDefaultSpecifier(_marko_compiler.types.identifier("template"))], _marko_compiler.types.stringLiteral(relativeImport)),
|
|
3954
|
+
_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("withPageAssets"), _marko_compiler.types.identifier("withPageAssets"))], _marko_compiler.types.stringLiteral(getRuntimePath("html"))),
|
|
3955
|
+
_marko_compiler.types.exportAllDeclaration(_marko_compiler.types.stringLiteral(relativeImport)),
|
|
3956
|
+
_marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("withPageAssets"), pageAssetArgs))
|
|
3957
|
+
];
|
|
3958
|
+
program.skip();
|
|
3959
|
+
return;
|
|
3960
|
+
}
|
|
3896
3961
|
}
|
|
3897
3962
|
if (isOutputHTML()) html_default.translate.enter();
|
|
3898
3963
|
else dom_default.translate.enter(program);
|
|
@@ -4289,7 +4354,10 @@ var native_tag_default = {
|
|
|
4289
4354
|
for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoText(child)) write`${child.value}`;
|
|
4290
4355
|
else if (_marko_compiler.types.isMarkoPlaceholder(child)) write`${callRuntime(getTextOnlyEscapeHelper(tagName), child.value)}`;
|
|
4291
4356
|
} else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
|
4292
|
-
if (!tagExtra[kSkipEndTag] && !isOpenOnly && !selectArgs)
|
|
4357
|
+
if (!tagExtra[kSkipEndTag] && !isOpenOnly && !selectArgs) {
|
|
4358
|
+
if (tagName === "head" && getMarkoOpts().linkAssets) write`${callRuntime("_flush_head")}`;
|
|
4359
|
+
write`</${tagName}>`;
|
|
4360
|
+
}
|
|
4293
4361
|
if (markerSerializeReason) markNode(tag, nodeBinding, markerSerializeReason);
|
|
4294
4362
|
tag.remove();
|
|
4295
4363
|
}
|
|
@@ -7875,6 +7943,8 @@ var document_type_default = { translate: { exit(documentType) {
|
|
|
7875
7943
|
} } };
|
|
7876
7944
|
//#endregion
|
|
7877
7945
|
//#region src/translator/visitors/import-declaration.ts
|
|
7946
|
+
const triggerRegExp = /\s*([\w-]+)\s*([^?|]+?)?\s*(?:\?([^|]*?))?\s*(?:\||$)/g;
|
|
7947
|
+
const [getHtmlLoadWrapped] = createProgramState(() => /* @__PURE__ */ new Map());
|
|
7878
7948
|
var import_declaration_default = {
|
|
7879
7949
|
analyze(importDecl) {
|
|
7880
7950
|
const { node } = importDecl;
|
|
@@ -7882,19 +7952,118 @@ var import_declaration_default = {
|
|
|
7882
7952
|
const { value } = source;
|
|
7883
7953
|
const tagImport = (0, _marko_compiler_babel_utils.resolveTagImport)(importDecl, value);
|
|
7884
7954
|
if (tagImport) {
|
|
7885
|
-
node.extra ??= {};
|
|
7886
|
-
node.extra.tagImport = tagImport;
|
|
7955
|
+
(node.extra ??= {}).tagImport = tagImport;
|
|
7887
7956
|
const tags = importDecl.hub.file.metadata.marko.tags;
|
|
7888
7957
|
if (!tags.includes(tagImport)) tags.push(tagImport);
|
|
7889
7958
|
}
|
|
7959
|
+
const loadAttrValuePath = importDecl.get("attributes").find((p) => (p.node.key.type === "Identifier" ? p.node.key.name : p.node.key.value) === "load")?.get("value");
|
|
7960
|
+
if (loadAttrValuePath) {
|
|
7961
|
+
(node.extra ??= {}).loadImport = getLoadImportConfig(loadAttrValuePath);
|
|
7962
|
+
const { file } = importDecl.hub;
|
|
7963
|
+
if (!getMarkoOpts().linkAssets) throw importDecl.buildCodeFrameError("The `load` import attribute requires the `linkAssets` compiler option to be configured.");
|
|
7964
|
+
if (!(tagImport && (0, _marko_compiler_babel_utils.loadFileForImport)(file, value))) throw importDecl.buildCodeFrameError("Unable to resolve marko file for load import.");
|
|
7965
|
+
if ((node.importKind || "value") !== "value") throw importDecl.buildCodeFrameError("Invalid load import.");
|
|
7966
|
+
for (const specifier of importDecl.get("specifiers")) if (!_marko_compiler.types.isImportDefaultSpecifier(specifier.node)) throw specifier.buildCodeFrameError("Invalid load import, only a default specifier is allowed.");
|
|
7967
|
+
}
|
|
7890
7968
|
},
|
|
7891
7969
|
translate: { exit(importDecl) {
|
|
7892
7970
|
const { node } = importDecl;
|
|
7893
7971
|
const { extra } = node;
|
|
7894
7972
|
const tagImport = extra?.tagImport;
|
|
7895
|
-
|
|
7973
|
+
const loadImport = extra?.loadImport;
|
|
7974
|
+
if (tagImport) {
|
|
7975
|
+
if (loadImport) {
|
|
7976
|
+
const { local } = node.specifiers.find(_marko_compiler.types.isImportDefaultSpecifier);
|
|
7977
|
+
const binding = importDecl.scope.getBinding(local.name);
|
|
7978
|
+
if (isOutputHTML()) {
|
|
7979
|
+
const { file } = importDecl.hub;
|
|
7980
|
+
const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
|
|
7981
|
+
const wrappedName = getOrCreateHtmlLoadWrapped(getReadyId(loadFile), _marko_compiler.types.identifier(local.name), loadFile.opts.filename, loadImport.render ? void 0 : loadImport.triggers);
|
|
7982
|
+
for (const ref of binding.referencePaths) ref.replaceWith(_marko_compiler.types.identifier(wrappedName));
|
|
7983
|
+
node.source.value = tagImport;
|
|
7984
|
+
return;
|
|
7985
|
+
} else if (binding.referencePaths.every((ref) => _marko_compiler.types.isMarkoTag(ref.parent) && ref.parent.extra?.tagNameLoad)) importDecl.remove();
|
|
7986
|
+
else {
|
|
7987
|
+
const { file } = importDecl.hub;
|
|
7988
|
+
const loadFile = (0, _marko_compiler_babel_utils.loadFileForImport)(file, node.source.value);
|
|
7989
|
+
const resolvedPath = (0, _marko_compiler_babel_utils.resolveRelativePath)(file, loadFile.opts.filename);
|
|
7990
|
+
importDecl.replaceWith(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(local, callRuntime("_load_template", _marko_compiler.types.stringLiteral(loadFile.metadata.marko.id), _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral(resolvedPath)]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier("mod")], toMemberExpression(_marko_compiler.types.identifier("mod"), "default"))]))))]));
|
|
7991
|
+
}
|
|
7992
|
+
return;
|
|
7993
|
+
}
|
|
7994
|
+
node.source.value = tagImport;
|
|
7995
|
+
}
|
|
7896
7996
|
} }
|
|
7897
7997
|
};
|
|
7998
|
+
function getOrCreateHtmlLoadWrapped(readyId, originalIdentifier, filename, triggers) {
|
|
7999
|
+
const markoOpts = getMarkoOpts();
|
|
8000
|
+
const loadWrapped = getHtmlLoadWrapped();
|
|
8001
|
+
const existing = loadWrapped.get(readyId);
|
|
8002
|
+
if (existing) return existing;
|
|
8003
|
+
markoOpts.linkAssets?.onAsset("load", filename, readyId);
|
|
8004
|
+
const wrappedName = generateUid(`${originalIdentifier.name ?? "tag"}_withLoadAssets`);
|
|
8005
|
+
loadWrapped.set(readyId, wrappedName);
|
|
8006
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(wrappedName), callRuntime("withLoadAssets", originalIdentifier, _marko_compiler.types.stringLiteral(readyId), triggers ? _marko_compiler.types.valueToNode(triggers) : void 0))])], true));
|
|
8007
|
+
return wrappedName;
|
|
8008
|
+
}
|
|
8009
|
+
function getLoadImportConfig(attrValue) {
|
|
8010
|
+
const raw = attrValue.node.value;
|
|
8011
|
+
if (raw === "render") return { render: true };
|
|
8012
|
+
const triggers = [];
|
|
8013
|
+
for (const match of raw.matchAll(triggerRegExp)) {
|
|
8014
|
+
const type = parseTriggerType(match[1]);
|
|
8015
|
+
const selector = match[2];
|
|
8016
|
+
const query = match[3];
|
|
8017
|
+
if (!type) throw attrValue.buildCodeFrameError(`Unknown trigger type "${match[1]}". Supported triggers are "visible", "idle", "media", and "on*".`);
|
|
8018
|
+
if (type === "render") throw attrValue.buildCodeFrameError("The \"render\" trigger must be used alone.");
|
|
8019
|
+
if (type === "idle") {
|
|
8020
|
+
if (selector) throw attrValue.buildCodeFrameError(`Selector is not supported for the "idle" trigger.`);
|
|
8021
|
+
} else if (!selector) throw attrValue.buildCodeFrameError(type === "media" ? `A media query is required for the "media" trigger. (e.g. "media(max-width:768px)")` : `A selector is required for the "${type}" trigger. (e.g. "${type}.my-element")`);
|
|
8022
|
+
const trigger = selector ? {
|
|
8023
|
+
type,
|
|
8024
|
+
selector
|
|
8025
|
+
} : { type };
|
|
8026
|
+
if (query) {
|
|
8027
|
+
const params = new URLSearchParams(query);
|
|
8028
|
+
switch (type) {
|
|
8029
|
+
case "visible": {
|
|
8030
|
+
let rootMargin;
|
|
8031
|
+
for (const [key, value] of params) {
|
|
8032
|
+
if (key !== "rootMargin") throw attrValue.buildCodeFrameError(`Unknown param "${key}" for the "visible" trigger. Supported params: "rootMargin".`);
|
|
8033
|
+
rootMargin = value;
|
|
8034
|
+
}
|
|
8035
|
+
if (rootMargin) trigger.options = { rootMargin };
|
|
8036
|
+
break;
|
|
8037
|
+
}
|
|
8038
|
+
case "idle": {
|
|
8039
|
+
let timeout;
|
|
8040
|
+
for (const [key, value] of params) {
|
|
8041
|
+
if (key !== "timeout") throw attrValue.buildCodeFrameError(`Unknown param "${key}" for the "idle" trigger. Supported params: "timeout".`);
|
|
8042
|
+
timeout = Number(value);
|
|
8043
|
+
}
|
|
8044
|
+
if (timeout) trigger.options = { timeout };
|
|
8045
|
+
break;
|
|
8046
|
+
}
|
|
8047
|
+
default: throw attrValue.buildCodeFrameError(`Params are not supported for the "${type}" trigger.`);
|
|
8048
|
+
}
|
|
8049
|
+
}
|
|
8050
|
+
triggers.push(trigger);
|
|
8051
|
+
}
|
|
8052
|
+
if (!triggers.length) throw attrValue.buildCodeFrameError("The \"load\" attribute requires \"render\" or at least one trigger (e.g. \"visible.my-element\").");
|
|
8053
|
+
return {
|
|
8054
|
+
render: false,
|
|
8055
|
+
triggers
|
|
8056
|
+
};
|
|
8057
|
+
}
|
|
8058
|
+
function parseTriggerType(type) {
|
|
8059
|
+
switch (type) {
|
|
8060
|
+
case "idle":
|
|
8061
|
+
case "media":
|
|
8062
|
+
case "render":
|
|
8063
|
+
case "visible": return type;
|
|
8064
|
+
default: return isEventHandler(type) ? `on-${getEventHandlerName(type)}` : void 0;
|
|
8065
|
+
}
|
|
8066
|
+
}
|
|
7898
8067
|
//#endregion
|
|
7899
8068
|
//#region src/translator/visitors/placeholder.ts
|
|
7900
8069
|
const kNodeBinding = Symbol("placeholder node binding");
|
|
@@ -8103,17 +8272,24 @@ var attribute_tag_default = {
|
|
|
8103
8272
|
};
|
|
8104
8273
|
//#endregion
|
|
8105
8274
|
//#region src/translator/visitors/tag/custom-tag.ts
|
|
8275
|
+
const kLoadTagBinding = Symbol("load tag binding");
|
|
8276
|
+
const [getLoadIdentifiers] = createProgramState(() => ({
|
|
8277
|
+
triggers: /* @__PURE__ */ new Map(),
|
|
8278
|
+
signals: /* @__PURE__ */ new Map()
|
|
8279
|
+
}));
|
|
8106
8280
|
var custom_tag_default = {
|
|
8107
8281
|
analyze: { enter(tag) {
|
|
8108
8282
|
if (!(0, _marko_compiler_babel_utils.getTagTemplate)(tag)) throw tagNotFoundError(tag);
|
|
8109
8283
|
(0, _marko_compiler_babel_utils.assertAttributesOrSingleArg)(tag);
|
|
8110
8284
|
const childFile = (0, _marko_compiler_babel_utils.loadFileForTag)(tag);
|
|
8111
8285
|
if (!childFile) throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
8286
|
+
const tagExtra = tag.node.extra ??= {};
|
|
8112
8287
|
const programExtra = (0, _marko_compiler_babel_utils.getProgram)().node.extra;
|
|
8113
8288
|
const programSection = programExtra.section;
|
|
8114
8289
|
const childExtra = childFile.ast.program.extra;
|
|
8115
8290
|
const childSection = childExtra.section;
|
|
8116
8291
|
if (childExtra.page) programExtra.page ??= true;
|
|
8292
|
+
if (tagExtra.tagNameLoad) tagExtra[kLoadTagBinding] = createBinding("#text", 0, getOrCreateSection(tag));
|
|
8117
8293
|
knownTagAnalyze(tag, childSection, programSection === childSection ? programSection.params && getBindingPropTree(programSection.params) : childExtra.domExports?.params);
|
|
8118
8294
|
} },
|
|
8119
8295
|
translate: {
|
|
@@ -8142,11 +8318,46 @@ function translateDOM(tag) {
|
|
|
8142
8318
|
const write = writeTo(tag);
|
|
8143
8319
|
const relativePath = getTagRelativePath(tag);
|
|
8144
8320
|
const programSection = (0, _marko_compiler_babel_utils.getProgram)().node.extra.section;
|
|
8145
|
-
const
|
|
8321
|
+
const childFile = (0, _marko_compiler_babel_utils.loadFileForTag)(tag);
|
|
8322
|
+
const childExtra = childFile.ast.program.extra;
|
|
8146
8323
|
const childExports = childExtra.domExports;
|
|
8147
8324
|
const childSection = childExtra.section;
|
|
8325
|
+
const loadConfig = node.extra?.tagNameLoad;
|
|
8326
|
+
const isLoad = !!loadConfig;
|
|
8148
8327
|
const tagName = _marko_compiler.types.isIdentifier(node.name) ? node.name.name : _marko_compiler.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
8149
|
-
if (
|
|
8328
|
+
if (isLoad) {
|
|
8329
|
+
const childFileName = childFile.opts.filename;
|
|
8330
|
+
const { triggers, signals } = getLoadIdentifiers();
|
|
8331
|
+
let triggerIdent = triggers.get(loadConfig);
|
|
8332
|
+
if (!triggerIdent) {
|
|
8333
|
+
const triggerExpr = loadTriggersToExpression(loadConfig);
|
|
8334
|
+
if (triggerExpr) {
|
|
8335
|
+
triggerIdent = generateUidIdentifier(`load_${tagName}_trigger`);
|
|
8336
|
+
triggers.set(loadConfig, triggerIdent);
|
|
8337
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(triggerIdent, triggerExpr)]));
|
|
8338
|
+
}
|
|
8339
|
+
}
|
|
8340
|
+
knownTagTranslateDOM(tag, childExports.params, (binding) => {
|
|
8341
|
+
const signalKey = `${triggerIdent ? triggerIdent.name : ""}\0${childFileName}\0${binding.export}`;
|
|
8342
|
+
let signalIdent = signals.get(signalKey);
|
|
8343
|
+
if (!signalIdent) {
|
|
8344
|
+
signalIdent = generateUidIdentifier(`load_${tagName}_tag_${binding.name}`);
|
|
8345
|
+
signals.set(signalKey, signalIdent);
|
|
8346
|
+
const loadExpr = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral(buildLoadSignalVirtualModule(file, childFileName, binding.export, binding.name))]));
|
|
8347
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.variableDeclaration("let", [_marko_compiler.types.variableDeclarator(signalIdent, callRuntime("_load_signal", triggerIdent ? _marko_compiler.types.addComment(_marko_compiler.types.callExpression(triggerIdent, [loadExpr]), "leading", "@__PURE__") : loadExpr))]));
|
|
8348
|
+
}
|
|
8349
|
+
return signalIdent;
|
|
8350
|
+
}, (section, childBinding) => {
|
|
8351
|
+
const setupIdent = generateUidIdentifier(`load_${tagName}_setup`);
|
|
8352
|
+
const setupLoadExpr = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral(buildLoadSetupVirtualModule(file, childFileName, childExports))]));
|
|
8353
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.variableDeclaration("let", [_marko_compiler.types.variableDeclarator(setupIdent, callRuntime("_load_setup", getScopeAccessorLiteral(node.extra[kLoadTagBinding], true), getScopeAccessorLiteral(childBinding, true), triggerIdent ? _marko_compiler.types.addComment(_marko_compiler.types.callExpression(triggerIdent, [setupLoadExpr]), "leading", "@__PURE__") : setupLoadExpr))]));
|
|
8354
|
+
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(setupIdent, [scopeIdentifier])));
|
|
8355
|
+
});
|
|
8356
|
+
write`<!>`;
|
|
8357
|
+
visit(tag, 37);
|
|
8358
|
+
injectWalks(tag, tagName);
|
|
8359
|
+
enterShallow(tag);
|
|
8360
|
+
} else if (programSection === childSection) {
|
|
8150
8361
|
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName) => getSignal(programSection, binding, preferredName).identifier, (section, childBinding) => {
|
|
8151
8362
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
|
|
8152
8363
|
});
|
|
@@ -8189,6 +8400,35 @@ function isCircularRequest(file, request) {
|
|
|
8189
8400
|
const { filename } = file.opts;
|
|
8190
8401
|
return request === filename || request[0] === "." && path.default.resolve(filename, "..", request) === filename;
|
|
8191
8402
|
}
|
|
8403
|
+
function buildLoadSetupVirtualModule(file, childFileName, childExports) {
|
|
8404
|
+
const parts = `${childExports.template}, ${childExports.walks}, ${childExports.setup}`;
|
|
8405
|
+
return getMarkoOpts().resolveVirtualDependency(file.opts.filename, {
|
|
8406
|
+
virtualPath: `${(0, _marko_compiler_babel_utils.resolveRelativePath)(file, childFileName)}.setup.js`,
|
|
8407
|
+
code: `import { ${parts} } from "./${path.default.basename(childFileName)}"\nexport const _ = [${parts}]`
|
|
8408
|
+
});
|
|
8409
|
+
}
|
|
8410
|
+
function buildLoadSignalVirtualModule(file, childFileName, childExport, childBinding) {
|
|
8411
|
+
return getMarkoOpts().resolveVirtualDependency(file.opts.filename, {
|
|
8412
|
+
virtualPath: `${(0, _marko_compiler_babel_utils.resolveRelativePath)(file, childFileName)}.${childBinding}.js`,
|
|
8413
|
+
code: `export { ${childExport} as _ } from "./${path.default.basename(childFileName)}"`
|
|
8414
|
+
});
|
|
8415
|
+
}
|
|
8416
|
+
function loadTriggersToExpression(loadConfig) {
|
|
8417
|
+
if (!loadConfig || loadConfig.render) return;
|
|
8418
|
+
const triggers = loadConfig.triggers.map(toDOMTriggerExpression);
|
|
8419
|
+
return triggers.length === 1 ? triggers[0] : callRuntime("_load_race_trigger", ...triggers);
|
|
8420
|
+
}
|
|
8421
|
+
function toDOMTriggerExpression(trigger) {
|
|
8422
|
+
switch (trigger.type) {
|
|
8423
|
+
case "visible": return callRuntime("_load_visible_trigger", _marko_compiler.types.stringLiteral(trigger.selector), optionalValueToNode(trigger.options));
|
|
8424
|
+
case "idle": return callRuntime("_load_idle_trigger", optionalValueToNode(trigger.options));
|
|
8425
|
+
case "media": return callRuntime("_load_media_trigger", _marko_compiler.types.stringLiteral(trigger.selector));
|
|
8426
|
+
default: return callRuntime("_load_event_trigger", _marko_compiler.types.stringLiteral(trigger.type.slice(3)), _marko_compiler.types.stringLiteral(trigger.selector));
|
|
8427
|
+
}
|
|
8428
|
+
}
|
|
8429
|
+
function optionalValueToNode(value) {
|
|
8430
|
+
return value ? _marko_compiler.types.valueToNode(value) : void 0;
|
|
8431
|
+
}
|
|
8192
8432
|
//#endregion
|
|
8193
8433
|
//#region src/translator/visitors/tag/dynamic-tag.ts
|
|
8194
8434
|
const kDOMBinding = Symbol("dynamic tag dom binding");
|
|
@@ -8260,7 +8500,7 @@ var dynamic_tag_default = {
|
|
|
8260
8500
|
let tagExpression = node.name;
|
|
8261
8501
|
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
|
|
8262
8502
|
if (isClassAPI) if ((0, _marko_compiler_babel_utils.getTagTemplate)(tag)) {
|
|
8263
|
-
if (getSerializeReason(tagSection, nodeBinding)) if (isOutputHTML()) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [_marko_compiler.types.
|
|
8503
|
+
if (getSerializeReason(tagSection, nodeBinding)) if (isOutputHTML()) (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name)]))], true));
|
|
8264
8504
|
else (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.expressionStatement(callRuntime("_resume", _marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.loadFileForTag)(tag).metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name))));
|
|
8265
8505
|
} else (0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(tagExpression.name), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(tagExpression.name)))], true));
|
|
8266
8506
|
const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
|
|
@@ -8564,6 +8804,7 @@ function addFeature(state, type, name, path) {
|
|
|
8564
8804
|
//#region src/translator/interop/index.ts
|
|
8565
8805
|
function createInteropTranslator(translate5) {
|
|
8566
8806
|
return {
|
|
8807
|
+
version: translate5.version ?? "0.0.0",
|
|
8567
8808
|
preferAPI: translate5.preferAPI,
|
|
8568
8809
|
transform: mergeVisitors(translate5.transform, transform),
|
|
8569
8810
|
analyze: mergeVisitors(translate5.analyze, analyze),
|
|
@@ -8624,7 +8865,8 @@ function createInteropTranslator(translate5) {
|
|
|
8624
8865
|
Program: {
|
|
8625
8866
|
enter(program, state) {
|
|
8626
8867
|
const entryFile = program.hub.file;
|
|
8627
|
-
|
|
8868
|
+
const { output, entry } = entryFile.markoOpts;
|
|
8869
|
+
if (!(output === "dom" && entry === "page" || output === "hydrate")) return enterProgram?.call(this, program, state);
|
|
8628
8870
|
const visitedFiles = new Set([(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename)]);
|
|
8629
8871
|
entryBuilder.visit(entryFile, entryFile, function visitChild(resolved) {
|
|
8630
8872
|
if (!visitedFiles.has(resolved)) {
|
|
@@ -8765,3 +9007,9 @@ exports.tagDiscoveryDirs = tagDiscoveryDirs;
|
|
|
8765
9007
|
exports.taglibs = taglibs;
|
|
8766
9008
|
exports.transform = transform;
|
|
8767
9009
|
exports.translate = translate;
|
|
9010
|
+
Object.defineProperty(exports, "version", {
|
|
9011
|
+
enumerable: true,
|
|
9012
|
+
get: function() {
|
|
9013
|
+
return package_json.version;
|
|
9014
|
+
}
|
|
9015
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Config, types as t } from "@marko/compiler";
|
|
2
2
|
type Taglibs = [taglibId: string, taglib: Record<string, unknown>][];
|
|
3
3
|
export declare function createInteropTranslator(translate5: any): {
|
|
4
|
+
version: any;
|
|
4
5
|
preferAPI: any;
|
|
5
6
|
transform: Record<"Function" | "MarkoTag" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayExpression" | "ArrayPattern" | "ArrayTypeAnnotation" | "ArrowFunctionExpression" | "AssignmentExpression" | "AssignmentPattern" | "AwaitExpression" | "BigIntLiteral" | "BinaryExpression" | "BindExpression" | "BlockStatement" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "BreakStatement" | "CallExpression" | "CatchClause" | "ClassAccessorProperty" | "ClassBody" | "ClassDeclaration" | "ClassExpression" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "ConditionalExpression" | "ContinueStatement" | "DebuggerStatement" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "DoWhileStatement" | "EmptyStatement" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportAllDeclaration" | "ExportDefaultDeclaration" | "ExportDefaultSpecifier" | "ExportNamedDeclaration" | "ExportNamespaceSpecifier" | "ExportSpecifier" | "ExpressionStatement" | "File" | "ForInStatement" | "ForOfStatement" | "ForStatement" | "FunctionDeclaration" | "FunctionExpression" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Identifier" | "IfStatement" | "Import" | "ImportAttribute" | "ImportDeclaration" | "ImportDefaultSpecifier" | "ImportExpression" | "ImportNamespaceSpecifier" | "ImportSpecifier" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXAttribute" | "JSXClosingElement" | "JSXClosingFragment" | "JSXElement" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXFragment" | "JSXIdentifier" | "JSXMemberExpression" | "JSXNamespacedName" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXSpreadAttribute" | "JSXSpreadChild" | "JSXText" | "LabeledStatement" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "MixedTypeAnnotation" | "ModuleExpression" | "NewExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectExpression" | "ObjectMethod" | "ObjectPattern" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "Program" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "RestElement" | "RestProperty" | "ReturnStatement" | "SequenceExpression" | "SpreadElement" | "SpreadProperty" | "StaticBlock" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "Super" | "SwitchCase" | "SwitchStatement" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumBody" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSTemplateLiteralType" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "TaggedTemplateExpression" | "TemplateElement" | "TemplateLiteral" | "ThisExpression" | "ThisTypeAnnotation" | "ThrowStatement" | "TopicReference" | "TryStatement" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnaryExpression" | "UnionTypeAnnotation" | "UpdateExpression" | "V8IntrinsicIdentifier" | "VariableDeclaration" | "VariableDeclarator" | "Variance" | "VoidPattern" | "VoidTypeAnnotation" | "WhileStatement" | "WithStatement" | "YieldExpression" | "MarkoParseError" | "MarkoDocumentType" | "MarkoDeclaration" | "MarkoCDATA" | "MarkoComment" | "MarkoText" | "MarkoPlaceholder" | "MarkoScriptlet" | "MarkoClass" | "MarkoAttribute" | "MarkoSpreadAttribute" | "MarkoTagBody" | "Standardized" | "Expression" | "Binary" | "Scopable" | "BlockParent" | "Block" | "Statement" | "Terminatorless" | "CompletionStatement" | "Conditional" | "Loop" | "While" | "ExpressionWrapper" | "For" | "ForXStatement" | "FunctionParent" | "Pureish" | "Declaration" | "FunctionParameter" | "PatternLike" | "LVal" | "TSEntityName" | "Literal" | "Immutable" | "UserWhitespacable" | "Method" | "ObjectMember" | "Property" | "UnaryLike" | "Pattern" | "Class" | "ImportOrExportDeclaration" | "ExportDeclaration" | "ModuleSpecifier" | "Accessor" | "Private" | "Flow" | "FlowType" | "FlowBaseAnnotation" | "FlowDeclaration" | "FlowPredicate" | "EnumBody" | "EnumMember" | "JSX" | "Miscellaneous" | "TypeScript" | "TSTypeElement" | "TSType" | "TSBaseType" | "ModuleDeclaration" | "Marko" | "Scope" | "BindingIdentifier" | "BlockScoped" | "ExistentialTypeParam" | "ForAwaitStatement" | "Generated" | "NumericLiteralTypeAnnotation" | "Pure" | "Referenced" | "ReferencedIdentifier" | "ReferencedMemberExpression" | "User" | "Var" | "enter" | "exit" | `${string}|${string}`, t.VisitNode<unknown, t.Node> | undefined>;
|
|
6
7
|
analyze: Record<"Function" | "MarkoTag" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayExpression" | "ArrayPattern" | "ArrayTypeAnnotation" | "ArrowFunctionExpression" | "AssignmentExpression" | "AssignmentPattern" | "AwaitExpression" | "BigIntLiteral" | "BinaryExpression" | "BindExpression" | "BlockStatement" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "BreakStatement" | "CallExpression" | "CatchClause" | "ClassAccessorProperty" | "ClassBody" | "ClassDeclaration" | "ClassExpression" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "ConditionalExpression" | "ContinueStatement" | "DebuggerStatement" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "DoWhileStatement" | "EmptyStatement" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportAllDeclaration" | "ExportDefaultDeclaration" | "ExportDefaultSpecifier" | "ExportNamedDeclaration" | "ExportNamespaceSpecifier" | "ExportSpecifier" | "ExpressionStatement" | "File" | "ForInStatement" | "ForOfStatement" | "ForStatement" | "FunctionDeclaration" | "FunctionExpression" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Identifier" | "IfStatement" | "Import" | "ImportAttribute" | "ImportDeclaration" | "ImportDefaultSpecifier" | "ImportExpression" | "ImportNamespaceSpecifier" | "ImportSpecifier" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXAttribute" | "JSXClosingElement" | "JSXClosingFragment" | "JSXElement" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXFragment" | "JSXIdentifier" | "JSXMemberExpression" | "JSXNamespacedName" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXSpreadAttribute" | "JSXSpreadChild" | "JSXText" | "LabeledStatement" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "MixedTypeAnnotation" | "ModuleExpression" | "NewExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectExpression" | "ObjectMethod" | "ObjectPattern" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "Program" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "RestElement" | "RestProperty" | "ReturnStatement" | "SequenceExpression" | "SpreadElement" | "SpreadProperty" | "StaticBlock" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "Super" | "SwitchCase" | "SwitchStatement" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumBody" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSTemplateLiteralType" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "TaggedTemplateExpression" | "TemplateElement" | "TemplateLiteral" | "ThisExpression" | "ThisTypeAnnotation" | "ThrowStatement" | "TopicReference" | "TryStatement" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnaryExpression" | "UnionTypeAnnotation" | "UpdateExpression" | "V8IntrinsicIdentifier" | "VariableDeclaration" | "VariableDeclarator" | "Variance" | "VoidPattern" | "VoidTypeAnnotation" | "WhileStatement" | "WithStatement" | "YieldExpression" | "MarkoParseError" | "MarkoDocumentType" | "MarkoDeclaration" | "MarkoCDATA" | "MarkoComment" | "MarkoText" | "MarkoPlaceholder" | "MarkoScriptlet" | "MarkoClass" | "MarkoAttribute" | "MarkoSpreadAttribute" | "MarkoTagBody" | "Standardized" | "Expression" | "Binary" | "Scopable" | "BlockParent" | "Block" | "Statement" | "Terminatorless" | "CompletionStatement" | "Conditional" | "Loop" | "While" | "ExpressionWrapper" | "For" | "ForXStatement" | "FunctionParent" | "Pureish" | "Declaration" | "FunctionParameter" | "PatternLike" | "LVal" | "TSEntityName" | "Literal" | "Immutable" | "UserWhitespacable" | "Method" | "ObjectMember" | "Property" | "UnaryLike" | "Pattern" | "Class" | "ImportOrExportDeclaration" | "ExportDeclaration" | "ModuleSpecifier" | "Accessor" | "Private" | "Flow" | "FlowType" | "FlowBaseAnnotation" | "FlowDeclaration" | "FlowPredicate" | "EnumBody" | "EnumMember" | "JSX" | "Miscellaneous" | "TypeScript" | "TSTypeElement" | "TSType" | "TSBaseType" | "ModuleDeclaration" | "Marko" | "Scope" | "BindingIdentifier" | "BlockScoped" | "ExistentialTypeParam" | "ForAwaitStatement" | "Generated" | "NumericLiteralTypeAnnotation" | "Pure" | "Referenced" | "ReferencedIdentifier" | "ReferencedMemberExpression" | "User" | "Var" | "enter" | "exit" | `${string}|${string}`, t.VisitNode<unknown, t.Node> | undefined>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { types as t } from "@marko/compiler";
|
|
1
2
|
export declare function isOutputHTML(): boolean;
|
|
2
3
|
export declare function isOutputDOM(): boolean;
|
|
3
4
|
export declare function getMarkoOpts(): Required<import("@marko/compiler").Config>;
|
|
4
5
|
export declare function isOptimize(): boolean;
|
|
6
|
+
export declare function getReadyId(file?: t.BabelFile): string | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
|
2
|
+
import type { LoadImportConfig } from "../visitors/import-declaration";
|
|
2
3
|
declare module "@marko/compiler/dist/types" {
|
|
3
4
|
interface ProgramExtra {
|
|
4
5
|
featureType?: "class" | "tags";
|
|
@@ -8,6 +9,7 @@ declare module "@marko/compiler/dist/types" {
|
|
|
8
9
|
tagNameNullable?: boolean;
|
|
9
10
|
tagNameDynamic?: boolean;
|
|
10
11
|
tagNameImported?: string;
|
|
12
|
+
tagNameLoad?: LoadImportConfig;
|
|
11
13
|
featureType?: ProgramExtra["featureType"];
|
|
12
14
|
}
|
|
13
15
|
}
|
|
@@ -10,7 +10,7 @@ type VisitCodes = WalkCode.Get | WalkCode.Inside | WalkCode.Replace | WalkCode.D
|
|
|
10
10
|
export declare function enter(path: t.NodePath<any>): void;
|
|
11
11
|
export declare function exit(path: t.NodePath<any>): void;
|
|
12
12
|
export declare function enterShallow(path: t.NodePath<any>): void;
|
|
13
|
-
export declare function injectWalks(tag: t.NodePath<t.MarkoTag>, name: string, expr
|
|
13
|
+
export declare function injectWalks(tag: t.NodePath<t.MarkoTag>, name: string, expr?: Walk): void;
|
|
14
14
|
export declare function visit(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder | t.Program>, code: VisitCodes): void;
|
|
15
15
|
export declare function getWalkString(section: Section): t.Expression | undefined;
|
|
16
16
|
export {};
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { types as t } from "@marko/compiler";
|
|
2
|
+
import type { LoadTrigger } from "../../html/assets";
|
|
2
3
|
declare module "@marko/compiler/dist/types" {
|
|
3
4
|
interface NodeExtra {
|
|
4
5
|
tagImport?: string;
|
|
6
|
+
loadImport?: LoadImportConfig;
|
|
5
7
|
}
|
|
6
8
|
}
|
|
9
|
+
export type LoadImportConfig = {
|
|
10
|
+
render: true;
|
|
11
|
+
triggers?: never;
|
|
12
|
+
} | {
|
|
13
|
+
render: false;
|
|
14
|
+
triggers: LoadTrigger[];
|
|
15
|
+
};
|
|
7
16
|
declare const _default: {
|
|
8
17
|
analyze(this: unknown, importDecl: t.NodePath<t.ImportDeclaration>): void;
|
|
9
18
|
translate: {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
|
2
|
+
import type { Binding } from "../../util/references";
|
|
3
|
+
declare const kLoadTagBinding: unique symbol;
|
|
4
|
+
declare module "@marko/compiler/dist/types" {
|
|
5
|
+
interface MarkoTagExtra {
|
|
6
|
+
[kLoadTagBinding]?: Binding;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
2
9
|
declare const _default: {
|
|
3
10
|
analyze: {
|
|
4
11
|
enter(this: unknown, tag: t.NodePath<t.MarkoTag>): void;
|