marko 6.0.63 → 6.0.65
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/README.md +72 -0
- package/dist/debug/dom.js +9 -2
- package/dist/debug/dom.mjs +9 -2
- package/dist/dom/signals.d.ts +2 -2
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/translator/index.js +96 -77
- package/package.json +1 -1
- package/tags/id.d.marko +4 -0
- package/tags/let.d.marko +3 -3
package/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
<div align="center">
|
2
|
+
|
3
|
+
# [<img alt="Marko" src="https://raw.githubusercontent.com/marko-js/website-next/refs/heads/main/public/logo.svg" width="250">](https://markojs.com/)
|
4
|
+
|
5
|
+
**A declarative, HTML-based language that makes building web apps fun 🔥**
|
6
|
+
|
7
|
+
[](https://www.npmjs.com/package/marko)
|
8
|
+
[](https://discord.gg/RFGxYGs)
|
9
|
+
[](https://github.com/marko-js/marko/actions/workflows/ci.yml)
|
10
|
+
[](https://codecov.io/gh/marko-js/marko)
|
11
|
+
[](https://npm-stat.com/charts.html?package=marko)
|
12
|
+
[](https://bestpractices.coreinfrastructure.org/projects/7029)
|
13
|
+
|
14
|
+
[Docs](https://markojs.com/docs/introduction/getting-started) ∙ [Try Online](https://markojs.com/playground) ∙ [Contribute](#contributors) ∙ [Get Support](#community--support)
|
15
|
+
|
16
|
+
</div>
|
17
|
+
|
18
|
+
## Intro
|
19
|
+
|
20
|
+
Marko is HTML _reimagined_ as a language for building dynamic and reactive user interfaces. Almost any valid HTML is valid Marko, and Marko extends HTML for building modern applications more declaratively. Among these extensions are [components](https://markojs.com/docs/reference/custom-tag), [conditionals](https://markojs.com/docs/reference/core-tag#if--else) and [loops](https://markojs.com/docs/reference/core-tag#for), and a full [reactivity system](https://markojs.com/docs/reference/reactivity).
|
21
|
+
|
22
|
+
### Example Component
|
23
|
+
|
24
|
+
The following renders a button and a counter of how many times the button has been pressed:
|
25
|
+
|
26
|
+
**click-count.marko**
|
27
|
+
|
28
|
+
```marko
|
29
|
+
// HTML + JavaScript = 💜
|
30
|
+
<let/count=0>
|
31
|
+
<button onClick() { count++ }>
|
32
|
+
Clicked ${count} times
|
33
|
+
</button>
|
34
|
+
```
|
35
|
+
|
36
|
+
## Getting Started
|
37
|
+
|
38
|
+
1. `npm init marko`
|
39
|
+
2. Read the [docs](https://markojs.com/docs/introduction/getting-started)
|
40
|
+
|
41
|
+
## Community & Support
|
42
|
+
|
43
|
+
<table>
|
44
|
+
<thead><tr>
|
45
|
+
<th><svg viewBox="0 0 576 512"><path d="M492.5 69.8c-.2-.3-.4-.6-.8-.7-38.1-17.5-78.4-30-119.7-37.1-.4-.1-.8 0-1.1 .1s-.6 .4-.8 .8c-5.5 9.9-10.5 20.2-14.9 30.6-44.6-6.8-89.9-6.8-134.4 0-4.5-10.5-9.5-20.7-15.1-30.6-.2-.3-.5-.6-.8-.8s-.7-.2-1.1-.2c-41.3 7.1-81.6 19.6-119.7 37.1-.3 .1-.6 .4-.8 .7-76.2 113.8-97.1 224.9-86.9 334.5 0 .3 .1 .5 .2 .8s.3 .4 .5 .6c44.4 32.9 94 58 146.8 74.2 .4 .1 .8 .1 1.1 0s.7-.4 .9-.7c11.3-15.4 21.4-31.8 30-48.8 .1-.2 .2-.5 .2-.8s0-.5-.1-.8-.2-.5-.4-.6-.4-.3-.7-.4c-15.8-6.1-31.2-13.4-45.9-21.9-.3-.2-.5-.4-.7-.6s-.3-.6-.3-.9 0-.6 .2-.9 .3-.5 .6-.7c3.1-2.3 6.2-4.7 9.1-7.1 .3-.2 .6-.4 .9-.4s.7 0 1 .1c96.2 43.9 200.4 43.9 295.5 0 .3-.1 .7-.2 1-.2s.7 .2 .9 .4c2.9 2.4 6 4.9 9.1 7.2 .2 .2 .4 .4 .6 .7s.2 .6 .2 .9-.1 .6-.3 .9-.4 .5-.6 .6c-14.7 8.6-30 15.9-45.9 21.8-.2 .1-.5 .2-.7 .4s-.3 .4-.4 .7-.1 .5-.1 .8 .1 .5 .2 .8c8.8 17 18.8 33.3 30 48.8 .2 .3 .6 .6 .9 .7s.8 .1 1.1 0c52.9-16.2 102.6-41.3 147.1-74.2 .2-.2 .4-.4 .5-.6s.2-.5 .2-.8c12.3-126.8-20.5-236.9-86.9-334.5zm-302 267.7c-29 0-52.8-26.6-52.8-59.2s23.4-59.2 52.8-59.2c29.7 0 53.3 26.8 52.8 59.2 0 32.7-23.4 59.2-52.8 59.2zm195.4 0c-29 0-52.8-26.6-52.8-59.2s23.4-59.2 52.8-59.2c29.7 0 53.3 26.8 52.8 59.2 0 32.7-23.2 59.2-52.8 59.2z"></path></svg>
|
46
|
+
<th><svg viewBox="0 0 576 512"><path d="M407.8 294.7c-3.3-.4-6.7-.8-10-1.3 3.4 .4 6.7 .9 10 1.3zM288 227.1C261.9 176.4 190.9 81.9 124.9 35.3 61.6-9.4 37.5-1.7 21.6 5.5 3.3 13.8 0 41.9 0 58.4S9.1 194 15 213.9c19.5 65.7 89.1 87.9 153.2 80.7 3.3-.5 6.6-.9 10-1.4-3.3 .5-6.6 1-10 1.4-93.9 14-177.3 48.2-67.9 169.9 120.3 124.6 164.8-26.7 187.7-103.4 22.9 76.7 49.2 222.5 185.6 103.4 102.4-103.4 28.1-156-65.8-169.9-3.3-.4-6.7-.8-10-1.3 3.4 .4 6.7 .9 10 1.3 64.1 7.1 133.6-15.1 153.2-80.7 5.9-19.9 15-138.9 15-155.5s-3.3-44.7-21.6-52.9c-15.8-7.1-40-14.9-103.2 29.8-66.1 46.6-137.1 141.1-163.2 191.8z"></path></svg>
|
47
|
+
<th><svg viewBox="0 0 448 512"><path d="M357.2 48L427.8 48 273.6 224.2 455 464 313 464 201.7 318.6 74.5 464 3.8 464 168.7 275.5-5.2 48 140.4 48 240.9 180.9 357.2 48zM332.4 421.8l39.1 0-252.4-333.8-42 0 255.3 333.8z"></path></svg>
|
48
|
+
<th><svg viewBox="0 0 512 512"><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM252.8 8c-138.7 0-244.8 105.3-244.8 244 0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1 100-33.2 167.8-128.1 167.8-239 0-138.7-112.5-244-251.2-244zM105.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg>
|
49
|
+
<tbody><tr><td>
|
50
|
+
|
51
|
+
Hang out in our [Discord server](https://discord.gg/marko) to ask questions & discuss marko<td>
|
52
|
+
|
53
|
+
Keep up with the community on Bluesky at [@markojs.com](https://bsky.app/profile/markojs.com)<td>
|
54
|
+
|
55
|
+
Tweet to [@MarkoDevTeam](https://twitter.com/MarkoDevTeam) or use the [#markojs](https://twitter.com/search?q=%23markojs%20OR%20%40markodevteam&f=live) hashtag<td>
|
56
|
+
|
57
|
+
Browse the code, open issues, & make pull requests on [GitHub](https://github.com/marko-js/marko)
|
58
|
+
|
59
|
+
</table>
|
60
|
+
|
61
|
+
### Contributors
|
62
|
+
|
63
|
+
Marko would not be what it is without all those who have contributed ✨
|
64
|
+
|
65
|
+
[](https://github.com/marko-js/marko/graphs/contributors)
|
66
|
+
|
67
|
+
### Get Involved!
|
68
|
+
|
69
|
+
- Pull requests are welcome!
|
70
|
+
- Submit [GitHub issues](https://github.com/marko-js/marko/issues) for any feature enhancements, bugs, or documentation problems
|
71
|
+
- [Read the Contribution Tips and Guidelines](.github/CONTRIBUTING.md)
|
72
|
+
- Participants in this project agree to abide by [its Code of Conduct](https://github.com/eBay/.github/blob/main/CODE_OF_CONDUCT.md)
|
package/dist/debug/dom.js
CHANGED
@@ -1059,9 +1059,16 @@ function _var(scope, childAccessor, signal) {
|
|
1059
1059
|
}
|
1060
1060
|
var _return = (scope, value) => scope["#TagVariable" /* TagVariable */]?.(value);
|
1061
1061
|
function _return_change(scope, changeHandler) {
|
1062
|
-
|
1062
|
+
if (changeHandler) {
|
1063
|
+
scope["#TagVariableChange" /* TagVariableChange */] = changeHandler;
|
1064
|
+
}
|
1063
1065
|
}
|
1064
|
-
var _var_change = (scope, value
|
1066
|
+
var _var_change = true ? (scope, value, name = "This") => {
|
1067
|
+
if (typeof scope["#TagVariableChange" /* TagVariableChange */] !== "function") {
|
1068
|
+
throw new TypeError(`${name} is a readonly tag variable.`);
|
1069
|
+
}
|
1070
|
+
scope["#TagVariableChange" /* TagVariableChange */](value);
|
1071
|
+
} : (scope, value) => scope["#TagVariableChange" /* TagVariableChange */]?.(value);
|
1065
1072
|
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1066
1073
|
function _id({ $global }) {
|
1067
1074
|
const id = tagIdsByGlobal.get($global) || 0;
|
package/dist/debug/dom.mjs
CHANGED
@@ -962,9 +962,16 @@ function _var(scope, childAccessor, signal) {
|
|
962
962
|
}
|
963
963
|
var _return = (scope, value) => scope["#TagVariable" /* TagVariable */]?.(value);
|
964
964
|
function _return_change(scope, changeHandler) {
|
965
|
-
|
965
|
+
if (changeHandler) {
|
966
|
+
scope["#TagVariableChange" /* TagVariableChange */] = changeHandler;
|
967
|
+
}
|
966
968
|
}
|
967
|
-
var _var_change = (scope, value
|
969
|
+
var _var_change = true ? (scope, value, name = "This") => {
|
970
|
+
if (typeof scope["#TagVariableChange" /* TagVariableChange */] !== "function") {
|
971
|
+
throw new TypeError(`${name} is a readonly tag variable.`);
|
972
|
+
}
|
973
|
+
scope["#TagVariableChange" /* TagVariableChange */](value);
|
974
|
+
} : (scope, value) => scope["#TagVariableChange" /* TagVariableChange */]?.(value);
|
968
975
|
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
969
976
|
function _id({ $global }) {
|
970
977
|
const id = tagIdsByGlobal.get($global) || 0;
|
package/dist/dom/signals.d.ts
CHANGED
@@ -17,8 +17,8 @@ export declare function _closure_get<T>(valueAccessor: Accessor, fn: Signal<T>,
|
|
17
17
|
};
|
18
18
|
export declare function _var(scope: Scope, childAccessor: Accessor, signal: Signal<unknown>): void;
|
19
19
|
export declare const _return: (scope: Scope, value: unknown) => any;
|
20
|
-
export declare function _return_change(scope: Scope, changeHandler
|
21
|
-
export declare const _var_change: (scope: Scope, value: unknown) =>
|
20
|
+
export declare function _return_change(scope: Scope, changeHandler?: ((value: unknown) => void) | null | false): void;
|
21
|
+
export declare const _var_change: (scope: Scope, value: unknown, name?: string) => void;
|
22
22
|
export declare function _id({ $global }: Scope): string;
|
23
23
|
export declare function _script(id: string, fn: (scope: Scope) => void): (scope: Scope) => void;
|
24
24
|
export declare function _hoist(...path: Accessor[]): (scope: Scope) => (...args: unknown[]) => any;
|
package/dist/dom.js
CHANGED
@@ -684,7 +684,7 @@ function _var(scope, childAccessor, signal) {
|
|
684
684
|
}
|
685
685
|
var _return = (scope, value) => scope.e?.(value);
|
686
686
|
function _return_change(scope, changeHandler) {
|
687
|
-
scope.f = changeHandler;
|
687
|
+
changeHandler && (scope.f = changeHandler);
|
688
688
|
}
|
689
689
|
var _var_change = (scope, value) => scope.f?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
690
690
|
function _id({ $global }) {
|
package/dist/dom.mjs
CHANGED
@@ -590,7 +590,7 @@ function _var(scope, childAccessor, signal) {
|
|
590
590
|
}
|
591
591
|
var _return = (scope, value) => scope.e?.(value);
|
592
592
|
function _return_change(scope, changeHandler) {
|
593
|
-
scope.f = changeHandler;
|
593
|
+
changeHandler && (scope.f = changeHandler);
|
594
594
|
}
|
595
595
|
var _var_change = (scope, value) => scope.f?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
596
596
|
function _id({ $global }) {
|
package/dist/translator/index.js
CHANGED
@@ -58,7 +58,7 @@ function assertNoSpreadAttrs(tag) {
|
|
58
58
|
if (attr.isMarkoSpreadAttribute()) {
|
59
59
|
const tagName = tag.get("name").node.value;
|
60
60
|
throw attr.buildCodeFrameError(
|
61
|
-
`The [\`<${tagName}>\`](https://
|
61
|
+
`The [\`<${tagName}>\`](https://markojs.com/docs/reference/core-tag#${tagName}) tag does not support \`...spread\` attributes.`
|
62
62
|
);
|
63
63
|
}
|
64
64
|
}
|
@@ -68,7 +68,7 @@ function assertNoBodyContent(tag) {
|
|
68
68
|
const tagName = tag.get("name");
|
69
69
|
const tagNameLiteral = tagName.node.value;
|
70
70
|
throw tagName.buildCodeFrameError(
|
71
|
-
`The [\`<${tagNameLiteral}>\`](https://
|
71
|
+
`The [\`<${tagNameLiteral}>\`](https://markojs.com/docs/reference/core-tag#${tagNameLiteral}) tag does not support body content.`
|
72
72
|
);
|
73
73
|
}
|
74
74
|
}
|
@@ -3096,17 +3096,17 @@ var return_default = {
|
|
3096
3096
|
if (parentTag) {
|
3097
3097
|
if ((0, import_babel_utils15.isNativeTag)(parentTag)) {
|
3098
3098
|
throw tag.get("name").buildCodeFrameError(
|
3099
|
-
"The [`<return>` tag](https://
|
3099
|
+
"The [`<return>` tag](https://markojs.com/docs/reference/core-tag#return) can not be used in a [native tag](https://markojs.com/docs/reference/native-tag)."
|
3100
3100
|
);
|
3101
3101
|
} else if (isControlFlowTag(parentTag)) {
|
3102
3102
|
throw tag.get("name").buildCodeFrameError(
|
3103
|
-
`The [\`<return>\` tag](https://
|
3103
|
+
`The [\`<return>\` tag](https://markojs.com/docs/reference/core-tag#return) can not be used under the \`<${parentTag.get("name").toString()}>\` tag.`
|
3104
3104
|
);
|
3105
3105
|
}
|
3106
3106
|
}
|
3107
3107
|
if (tagsWithReturn.has(tag.parentPath)) {
|
3108
3108
|
throw tag.get("name").buildCodeFrameError(
|
3109
|
-
`Cannot have multiple [\`<return>\` tags](https://
|
3109
|
+
`Cannot have multiple [\`<return>\` tags](https://markojs.com/docs/reference/core-tag#return) ${tag.parent.type === "Program" ? "for the template" : "within a tag's body content"}.`
|
3110
3110
|
);
|
3111
3111
|
} else {
|
3112
3112
|
tagsWithReturn.add(tag.parentPath);
|
@@ -3114,7 +3114,7 @@ var return_default = {
|
|
3114
3114
|
const attrs = getKnownAttrValues(tag.node);
|
3115
3115
|
if (!attrs.value) {
|
3116
3116
|
throw tag.get("name").buildCodeFrameError(
|
3117
|
-
"The [`<return>` tag](https://
|
3117
|
+
"The [`<return>` tag](https://markojs.com/docs/reference/core-tag#return) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
3118
3118
|
);
|
3119
3119
|
}
|
3120
3120
|
if (attrs.valueChange) {
|
@@ -3135,7 +3135,11 @@ var return_default = {
|
|
3135
3135
|
setSectionSerializedValue(
|
3136
3136
|
section,
|
3137
3137
|
getAccessorProp().TagVariableChange,
|
3138
|
-
|
3138
|
+
import_compiler18.types.logicalExpression(
|
3139
|
+
"||",
|
3140
|
+
attrs.valueChange,
|
3141
|
+
import_compiler18.types.unaryExpression("void", import_compiler18.types.numericLiteral(0))
|
3142
|
+
)
|
3139
3143
|
);
|
3140
3144
|
}
|
3141
3145
|
if (attrs.value) {
|
@@ -3185,7 +3189,7 @@ var return_default = {
|
|
3185
3189
|
displayText: "return=<value>",
|
3186
3190
|
description: "Provides a value for use in a parent template.",
|
3187
3191
|
snippet: "return=${1:value}",
|
3188
|
-
descriptionMoreURL: "https://
|
3192
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#return"
|
3189
3193
|
}
|
3190
3194
|
]
|
3191
3195
|
};
|
@@ -5858,22 +5862,22 @@ var await_default = {
|
|
5858
5862
|
tagExtra[kDOMBinding] = createBinding("#text", 0 /* dom */, section);
|
5859
5863
|
if (!valueAttr) {
|
5860
5864
|
throw tag.get("name").buildCodeFrameError(
|
5861
|
-
"The [`<await>` tag](https://
|
5865
|
+
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
5862
5866
|
);
|
5863
5867
|
}
|
5864
5868
|
if (node.attributes.length > 1 || !import_compiler26.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
|
5865
5869
|
throw tag.get("name").buildCodeFrameError(
|
5866
|
-
"The [`<await>` tag](https://
|
5870
|
+
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
5867
5871
|
);
|
5868
5872
|
}
|
5869
5873
|
if (!node.body.body.length) {
|
5870
5874
|
throw tag.get("name").buildCodeFrameError(
|
5871
|
-
"The [`<await>` tag](https://
|
5875
|
+
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires [content](https://markojs.com/docs/reference/language#tag-content)."
|
5872
5876
|
);
|
5873
5877
|
}
|
5874
5878
|
if (node.body.params.length && (node.body.params.length > 1 || import_compiler26.types.isSpreadElement(node.body.params[0]))) {
|
5875
5879
|
throw tag.get("name").buildCodeFrameError(
|
5876
|
-
"The [`<await>` tag](https://
|
5880
|
+
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports a single parameter."
|
5877
5881
|
);
|
5878
5882
|
}
|
5879
5883
|
const bodySection = startSection(tagBody);
|
@@ -5967,7 +5971,7 @@ var await_default = {
|
|
5967
5971
|
autocomplete: [
|
5968
5972
|
{
|
5969
5973
|
description: "Use to consume asynchronous an data.",
|
5970
|
-
descriptionMoreURL: "https://
|
5974
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#await"
|
5971
5975
|
}
|
5972
5976
|
],
|
5973
5977
|
types: runtime_info_default.name + "/tags/await.d.marko"
|
@@ -6058,17 +6062,17 @@ var const_default = {
|
|
6058
6062
|
const [valueAttr] = node.attributes;
|
6059
6063
|
if (!node.var) {
|
6060
6064
|
throw tag.get("name").buildCodeFrameError(
|
6061
|
-
"The [`<const>` tag](https://
|
6065
|
+
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
6062
6066
|
);
|
6063
6067
|
}
|
6064
6068
|
if (!valueAttr) {
|
6065
6069
|
throw tag.get("name").buildCodeFrameError(
|
6066
|
-
"The [`<const>` tag](https://
|
6070
|
+
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
6067
6071
|
);
|
6068
6072
|
}
|
6069
6073
|
if (node.attributes.length > 1 || !import_compiler29.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
6070
6074
|
throw tag.get("name").buildCodeFrameError(
|
6071
|
-
"The [`<const>` tag](https://
|
6075
|
+
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
6072
6076
|
);
|
6073
6077
|
}
|
6074
6078
|
const valueExtra = evaluate(valueAttr.value);
|
@@ -6115,7 +6119,7 @@ var const_default = {
|
|
6115
6119
|
autocomplete: [
|
6116
6120
|
{
|
6117
6121
|
description: "Use to create an constant binding.",
|
6118
|
-
descriptionMoreURL: "https://
|
6122
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#const"
|
6119
6123
|
}
|
6120
6124
|
],
|
6121
6125
|
types: runtime_info_default.name + "/tags/const.d.marko"
|
@@ -6133,7 +6137,7 @@ var debug_default = {
|
|
6133
6137
|
assertNoBodyContent(tag);
|
6134
6138
|
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler30.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
6135
6139
|
throw tag.get("name").buildCodeFrameError(
|
6136
|
-
"The [`<debug>` tag](https://
|
6140
|
+
"The [`<debug>` tag](https://markojs.com/docs/reference/core-tag#debug) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
6137
6141
|
);
|
6138
6142
|
}
|
6139
6143
|
},
|
@@ -6158,7 +6162,7 @@ var debug_default = {
|
|
6158
6162
|
autocomplete: [
|
6159
6163
|
{
|
6160
6164
|
description: "Debug on value change.",
|
6161
|
-
descriptionMoreURL: "https://
|
6165
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#debug"
|
6162
6166
|
}
|
6163
6167
|
],
|
6164
6168
|
types: runtime_info_default.name + "/tags/debug.d.marko"
|
@@ -6345,7 +6349,7 @@ var native_tag_default = {
|
|
6345
6349
|
const { node } = tag;
|
6346
6350
|
if (node.var && !import_compiler32.types.isIdentifier(node.var)) {
|
6347
6351
|
throw tag.get("var").buildCodeFrameError(
|
6348
|
-
"Tag variables on [native tags](https://
|
6352
|
+
"Tag variables on [native tags](https://markojs.com/docs/reference/native-tag) cannot be destructured."
|
6349
6353
|
);
|
6350
6354
|
}
|
6351
6355
|
const tagName = getTagName(tag);
|
@@ -7279,7 +7283,7 @@ var for_default = {
|
|
7279
7283
|
break;
|
7280
7284
|
default:
|
7281
7285
|
throw tag.buildCodeFrameError(
|
7282
|
-
"The [`<for>` tag](https://
|
7286
|
+
"The [`<for>` tag](https://markojs.com/docs/reference/core-tag#for) requires an `of=`, `in=`, or `to=` attribute."
|
7283
7287
|
);
|
7284
7288
|
}
|
7285
7289
|
if (!isAttrTag) {
|
@@ -7489,15 +7493,15 @@ var for_default = {
|
|
7489
7493
|
{
|
7490
7494
|
snippet: "for|${1:value, index}| of=${3:array}",
|
7491
7495
|
description: "Use to iterate over lists, object properties, or between ranges.",
|
7492
|
-
descriptionMoreURL: "https://
|
7496
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
|
7493
7497
|
},
|
7494
7498
|
{
|
7495
7499
|
snippet: "for|${1:name, value}| in=${3:object}",
|
7496
|
-
descriptionMoreURL: "https://
|
7500
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
|
7497
7501
|
},
|
7498
7502
|
{
|
7499
7503
|
snippet: "for|${1:index}| to=${2:number}",
|
7500
|
-
descriptionMoreURL: "https://
|
7504
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
|
7501
7505
|
}
|
7502
7506
|
]
|
7503
7507
|
};
|
@@ -7920,7 +7924,7 @@ var define_default = {
|
|
7920
7924
|
(0, import_babel_utils29.assertNoArgs)(tag);
|
7921
7925
|
if (!tag.node.var) {
|
7922
7926
|
throw tag.get("name").buildCodeFrameError(
|
7923
|
-
"The [`<define>` tag](https://
|
7927
|
+
"The [`<define>` tag](https://markojs.com/docs/reference/core-tag#define) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
7924
7928
|
);
|
7925
7929
|
}
|
7926
7930
|
const tagBody = tag.get("body");
|
@@ -7982,7 +7986,7 @@ var define_default = {
|
|
7982
7986
|
autocomplete: [
|
7983
7987
|
{
|
7984
7988
|
description: "Use to create a constant object binding that can be rendered.",
|
7985
|
-
descriptionMoreURL: "https://
|
7989
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#define"
|
7986
7990
|
}
|
7987
7991
|
],
|
7988
7992
|
types: runtime_info_default.name + "/tags/define.d.marko"
|
@@ -8058,7 +8062,7 @@ var html_comment_default = {
|
|
8058
8062
|
if (tagVar) {
|
8059
8063
|
if (!import_compiler38.types.isIdentifier(tagVar)) {
|
8060
8064
|
throw tag.get("var").buildCodeFrameError(
|
8061
|
-
"The [`<html-comment>` tag](https://
|
8065
|
+
"The [`<html-comment>` tag](https://markojs.com/docs/reference/core-tag#html-comment) tag variable cannot be destructured."
|
8062
8066
|
);
|
8063
8067
|
}
|
8064
8068
|
needsBinding = true;
|
@@ -8225,7 +8229,7 @@ var html_comment_default = {
|
|
8225
8229
|
autocomplete: [
|
8226
8230
|
{
|
8227
8231
|
description: "Use to create an html comment that is not stripped from the output.",
|
8228
|
-
descriptionMoreURL: "https://
|
8232
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-comment"
|
8229
8233
|
}
|
8230
8234
|
]
|
8231
8235
|
};
|
@@ -8607,7 +8611,7 @@ var html_script_default = {
|
|
8607
8611
|
autocomplete: [
|
8608
8612
|
{
|
8609
8613
|
description: "Use instead of `<script>` to render a native tag directly, without processing by Marko.",
|
8610
|
-
descriptionMoreURL: "https://
|
8614
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
8611
8615
|
}
|
8612
8616
|
]
|
8613
8617
|
};
|
@@ -9026,7 +9030,7 @@ var html_style_default = {
|
|
9026
9030
|
autocomplete: [
|
9027
9031
|
{
|
9028
9032
|
description: "Use instead of `<style>` to render a native tag directly, without processing by Marko.",
|
9029
|
-
descriptionMoreURL: "https://
|
9033
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
9030
9034
|
}
|
9031
9035
|
]
|
9032
9036
|
};
|
@@ -9086,17 +9090,17 @@ var id_default = {
|
|
9086
9090
|
const [valueAttr] = node.attributes;
|
9087
9091
|
if (!node.var) {
|
9088
9092
|
throw tag.get("name").buildCodeFrameError(
|
9089
|
-
"The [`<id>` tag](https://
|
9093
|
+
"The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
9090
9094
|
);
|
9091
9095
|
}
|
9092
9096
|
if (!import_compiler41.types.isIdentifier(node.var)) {
|
9093
9097
|
throw tag.get("var").buildCodeFrameError(
|
9094
|
-
"The [`<id>` tag](https://
|
9098
|
+
"The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) cannot be destructured."
|
9095
9099
|
);
|
9096
9100
|
}
|
9097
9101
|
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler41.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
9098
9102
|
throw tag.get("name").buildCodeFrameError(
|
9099
|
-
"The [`<id>` tag](https://
|
9103
|
+
"The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
9100
9104
|
);
|
9101
9105
|
}
|
9102
9106
|
const binding = trackVarReferences(tag, 5 /* derived */);
|
@@ -9145,7 +9149,7 @@ var id_default = {
|
|
9145
9149
|
displayText: "id/<name>",
|
9146
9150
|
description: "Use to create a unique identifier.",
|
9147
9151
|
snippet: "id/${1:name}",
|
9148
|
-
descriptionMoreURL: "https://
|
9152
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#id"
|
9149
9153
|
}
|
9150
9154
|
],
|
9151
9155
|
types: runtime_info_default.name + "/tags/id.d.marko"
|
@@ -9378,7 +9382,7 @@ var IfTag = {
|
|
9378
9382
|
{
|
9379
9383
|
snippet: "if=${1:condition}",
|
9380
9384
|
description: "Use to display content only if the condition is met.",
|
9381
|
-
descriptionMoreURL: "https://
|
9385
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#if--else"
|
9382
9386
|
}
|
9383
9387
|
]
|
9384
9388
|
};
|
@@ -9388,7 +9392,7 @@ var ElseIfTag = {
|
|
9388
9392
|
{
|
9389
9393
|
snippet: "else-if=${1:condition}",
|
9390
9394
|
description: "Use after an <if> or <else-if> tag to display content if those conditions do not match and this one does.",
|
9391
|
-
descriptionMoreURL: "https://
|
9395
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#if--else"
|
9392
9396
|
}
|
9393
9397
|
]
|
9394
9398
|
};
|
@@ -9397,7 +9401,7 @@ var ElseTag = {
|
|
9397
9401
|
autocomplete: [
|
9398
9402
|
{
|
9399
9403
|
description: "Use after an <if> or <else-if> tag to display content if those conditions do not match.",
|
9400
|
-
descriptionMoreURL: "https://
|
9404
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#if--else"
|
9401
9405
|
}
|
9402
9406
|
]
|
9403
9407
|
};
|
@@ -9426,14 +9430,14 @@ function assertHasPrecedingCondition(tag) {
|
|
9426
9430
|
while (prev.node && prev.isMarkoComment()) prev = prev.getPrevSibling();
|
9427
9431
|
if (!isConditionTag(prev) || getTagName(prev) !== "else" && !prev.node.attributes.length) {
|
9428
9432
|
throw tag.buildCodeFrameError(
|
9429
|
-
`The [\`<${getTagName(tag)}>\` tag](https://
|
9433
|
+
`The [\`<${getTagName(tag)}>\` tag](https://markojs.com/docs/reference/core-tag#if--else) must have a preceding \`<if=cond>\` or \`<else if=cond>\`.`
|
9430
9434
|
);
|
9431
9435
|
}
|
9432
9436
|
}
|
9433
9437
|
function assertHasBody(tag) {
|
9434
9438
|
if (!(tag.node.body.body.length || tag.node.attributeTags.length)) {
|
9435
9439
|
throw tag.get("name").buildCodeFrameError(
|
9436
|
-
`The [\`${getTagName(tag)}\` tag](https://
|
9440
|
+
`The [\`${getTagName(tag)}\` tag](https://markojs.com/docs/reference/core-tag#if--else) requires [body content](https://markojs.com/docs/reference/language#tag-content).`
|
9437
9441
|
);
|
9438
9442
|
}
|
9439
9443
|
}
|
@@ -9442,13 +9446,13 @@ function assertHasValueAttribute(tag) {
|
|
9442
9446
|
const [valueAttr] = node.attributes;
|
9443
9447
|
if (!import_compiler43.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
|
9444
9448
|
throw tag.get("name").buildCodeFrameError(
|
9445
|
-
`The [\`${getTagName(tag)}\` tag](https://
|
9449
|
+
`The [\`${getTagName(tag)}\` tag](https://markojs.com/docs/reference/core-tag#if--else) requires a [\`value=\` attribute](https://markojs.com/docs/reference/language#shorthand-value).`
|
9446
9450
|
);
|
9447
9451
|
}
|
9448
9452
|
if (node.attributes.length > 1) {
|
9449
9453
|
const start = node.attributes[1].loc?.start;
|
9450
9454
|
const end = node.attributes[node.attributes.length - 1].loc?.end;
|
9451
|
-
const msg = `The [\`${getTagName(tag)}\` tag](https://
|
9455
|
+
const msg = `The [\`${getTagName(tag)}\` tag](https://markojs.com/docs/reference/core-tag#if--else) only supports the [\`value=\` attribute](https://markojs.com/docs/reference/language#shorthand-value).`;
|
9452
9456
|
if (start == null || end == null) {
|
9453
9457
|
throw tag.get("name").buildCodeFrameError(msg);
|
9454
9458
|
} else {
|
@@ -9466,7 +9470,7 @@ function assertOptionalIfAttribute(tag) {
|
|
9466
9470
|
if (node.attributes.length > 1 || ifAttr && ifAttr.name !== "if") {
|
9467
9471
|
const start = node.attributes[1].loc?.start;
|
9468
9472
|
const end = node.attributes[node.attributes.length - 1].loc?.end;
|
9469
|
-
const msg = `The [\`${getTagName(tag)}\` tag](https://
|
9473
|
+
const msg = `The [\`${getTagName(tag)}\` tag](https://markojs.com/docs/reference/core-tag#if--else) only supports an \`if=\` attribute.`;
|
9470
9474
|
if (start == null || end == null) {
|
9471
9475
|
throw tag.get("name").buildCodeFrameError(msg);
|
9472
9476
|
} else {
|
@@ -9543,7 +9547,7 @@ var let_default = {
|
|
9543
9547
|
} else {
|
9544
9548
|
const start = attr.loc?.start;
|
9545
9549
|
const end = attr.loc?.end;
|
9546
|
-
const msg = "The [`<let>` tag](https://
|
9550
|
+
const msg = "The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value) and its change handler.";
|
9547
9551
|
if (start == null || end == null) {
|
9548
9552
|
throw tag.get("name").buildCodeFrameError(msg);
|
9549
9553
|
} else {
|
@@ -9562,17 +9566,17 @@ var let_default = {
|
|
9562
9566
|
assertNoSpreadAttrs(tag);
|
9563
9567
|
if (!tagVar) {
|
9564
9568
|
throw tag.get("name").buildCodeFrameError(
|
9565
|
-
"The [`<let>` tag](https://
|
9569
|
+
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
9566
9570
|
);
|
9567
9571
|
}
|
9568
9572
|
if (!import_compiler44.types.isIdentifier(tagVar)) {
|
9569
9573
|
throw tag.get("var").buildCodeFrameError(
|
9570
|
-
"The [`<let>` tag](https://
|
9574
|
+
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) variable cannot be destructured."
|
9571
9575
|
);
|
9572
9576
|
}
|
9573
|
-
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)) {
|
9577
|
+
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)?.value) {
|
9574
9578
|
throw tag.get("attributes").find((attr) => attr.node === valueChangeAttr).get("value").buildCodeFrameError(
|
9575
|
-
"The [`<let>` tag](https://
|
9579
|
+
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) [`valueChange=` attribute](https://markojs.com/docs/reference/core-tag#controllable-let) must be a function."
|
9576
9580
|
);
|
9577
9581
|
}
|
9578
9582
|
const tagSection = getOrCreateSection(tag);
|
@@ -9621,7 +9625,11 @@ var let_default = {
|
|
9621
9625
|
setBindingSerializedValue(
|
9622
9626
|
section,
|
9623
9627
|
binding,
|
9624
|
-
|
9628
|
+
import_compiler44.types.logicalExpression(
|
9629
|
+
"||",
|
9630
|
+
valueChangeAttr.value,
|
9631
|
+
import_compiler44.types.unaryExpression("void", import_compiler44.types.numericLiteral(0))
|
9632
|
+
),
|
9625
9633
|
getAccessorPrefix().TagVariableChange
|
9626
9634
|
);
|
9627
9635
|
}
|
@@ -9636,7 +9644,7 @@ var let_default = {
|
|
9636
9644
|
autocomplete: [
|
9637
9645
|
{
|
9638
9646
|
description: "Use to create a mutable binding.",
|
9639
|
-
descriptionMoreURL: "https://
|
9647
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#let"
|
9640
9648
|
}
|
9641
9649
|
],
|
9642
9650
|
types: runtime_info_default.name + "/tags/let.d.marko"
|
@@ -9667,13 +9675,13 @@ var lifecycle_default = {
|
|
9667
9675
|
binding.downstreamExpressions.add(tagExtra);
|
9668
9676
|
if (node.attributes.length === 0) {
|
9669
9677
|
throw tag.get("name").buildCodeFrameError(
|
9670
|
-
"The [`<lifecycle>` tag](https://
|
9678
|
+
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) requires at least one attribute."
|
9671
9679
|
);
|
9672
9680
|
}
|
9673
9681
|
for (const attr of node.attributes) {
|
9674
9682
|
if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
9675
9683
|
throw tag.get("name").buildCodeFrameError(
|
9676
|
-
"The [`<lifecycle>` tag](https://
|
9684
|
+
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) does not support [`...spread` attributes](https://markojs.com/docs/reference/language#spread-attributes)."
|
9677
9685
|
);
|
9678
9686
|
}
|
9679
9687
|
(attr.value.extra ??= {}).isEffect = true;
|
@@ -9718,7 +9726,7 @@ var lifecycle_default = {
|
|
9718
9726
|
autocomplete: [
|
9719
9727
|
{
|
9720
9728
|
description: "Use to create a side effects.",
|
9721
|
-
descriptionMoreURL: "https://
|
9729
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#lifecycle"
|
9722
9730
|
}
|
9723
9731
|
],
|
9724
9732
|
types: runtime_info_default.name + "/tags/lifecycle.d.marko"
|
@@ -9736,12 +9744,12 @@ var log_default = {
|
|
9736
9744
|
assertNoBodyContent(tag);
|
9737
9745
|
if (!valueAttr) {
|
9738
9746
|
throw tag.get("name").buildCodeFrameError(
|
9739
|
-
"The [`<log>` tag](https://
|
9747
|
+
"The [`<log>` tag](https://markojs.com/docs/reference/core-tag#log) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
9740
9748
|
);
|
9741
9749
|
}
|
9742
9750
|
if (tag.node.attributes.length > 1 || !import_compiler46.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
9743
9751
|
throw tag.get("name").buildCodeFrameError(
|
9744
|
-
"The [`<log>` tag](https://
|
9752
|
+
"The [`<log>` tag](https://markojs.com/docs/reference/core-tag#log) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
9745
9753
|
);
|
9746
9754
|
}
|
9747
9755
|
},
|
@@ -9772,7 +9780,7 @@ var log_default = {
|
|
9772
9780
|
autocomplete: [
|
9773
9781
|
{
|
9774
9782
|
description: "Use to log a value to the console.",
|
9775
|
-
descriptionMoreURL: "https://
|
9783
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#log"
|
9776
9784
|
}
|
9777
9785
|
],
|
9778
9786
|
types: runtime_info_default.name + "/tags/log.d.marko"
|
@@ -9781,7 +9789,7 @@ var log_default = {
|
|
9781
9789
|
// src/translator/core/script.ts
|
9782
9790
|
var import_compiler47 = require("@marko/compiler");
|
9783
9791
|
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
9784
|
-
var htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://
|
9792
|
+
var htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.";
|
9785
9793
|
var script_default = {
|
9786
9794
|
parse(tag) {
|
9787
9795
|
const { node } = tag;
|
@@ -9792,7 +9800,7 @@ var script_default = {
|
|
9792
9800
|
if (child.type !== "MarkoText") {
|
9793
9801
|
throw tag.hub.file.hub.buildError(
|
9794
9802
|
child,
|
9795
|
-
"Unexpected content in [`<script>` tag](https://
|
9803
|
+
"Unexpected content in [`<script>` tag](https://markojs.com/docs/reference/core-tag#script). Only javascript and typescript is supported." + htmlScriptTagAlternateMsg,
|
9796
9804
|
SyntaxError
|
9797
9805
|
);
|
9798
9806
|
}
|
@@ -9821,7 +9829,7 @@ var script_default = {
|
|
9821
9829
|
if (node.var) {
|
9822
9830
|
throw tag.hub.buildError(
|
9823
9831
|
node.var,
|
9824
|
-
"The [`<script>` tag](https://
|
9832
|
+
"The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support a tag variable reference." + htmlScriptTagAlternateMsg
|
9825
9833
|
);
|
9826
9834
|
}
|
9827
9835
|
let seenValueAttr = false;
|
@@ -9836,7 +9844,7 @@ var script_default = {
|
|
9836
9844
|
} else {
|
9837
9845
|
throw tag.hub.buildError(
|
9838
9846
|
attr,
|
9839
|
-
"The [`<script>` tag](https://
|
9847
|
+
"The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support html attributes." + htmlScriptTagAlternateMsg
|
9840
9848
|
);
|
9841
9849
|
}
|
9842
9850
|
}
|
@@ -9986,7 +9994,7 @@ var import_babel_utils44 = require("@marko/compiler/babel-utils");
|
|
9986
9994
|
var import_magic_string = __toESM(require("magic-string"));
|
9987
9995
|
var import_path3 = __toESM(require("path"));
|
9988
9996
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
9989
|
-
var htmlStyleTagAlternateMsg = " For a native html [`<style>` tag](https://
|
9997
|
+
var htmlStyleTagAlternateMsg = " For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.";
|
9990
9998
|
var style_default = {
|
9991
9999
|
analyze(tag) {
|
9992
10000
|
(0, import_babel_utils44.assertNoArgs)(tag);
|
@@ -10007,14 +10015,14 @@ var style_default = {
|
|
10007
10015
|
if (child.type !== "MarkoText") {
|
10008
10016
|
throw tag.hub.buildError(
|
10009
10017
|
child,
|
10010
|
-
"The [`<style>` tag](https://
|
10018
|
+
"The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) currently only supports static content." + htmlStyleTagAlternateMsg
|
10011
10019
|
);
|
10012
10020
|
}
|
10013
10021
|
}
|
10014
10022
|
if (node.body.body.length > 1) {
|
10015
10023
|
throw tag.hub.buildError(
|
10016
10024
|
node.name,
|
10017
|
-
"The [`<style>` tag](https://
|
10025
|
+
"The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) currently only supports static content." + htmlStyleTagAlternateMsg
|
10018
10026
|
);
|
10019
10027
|
}
|
10020
10028
|
},
|
@@ -10110,7 +10118,7 @@ var try_default = {
|
|
10110
10118
|
tagExtra[kDOMBinding2] = createBinding("#text", 0 /* dom */, section);
|
10111
10119
|
if (!tag.node.body.body.length) {
|
10112
10120
|
throw tag.get("name").buildCodeFrameError(
|
10113
|
-
"The [`<try>` tag](https://
|
10121
|
+
"The [`<try>` tag](https://markojs.com/docs/reference/core-tag#try) requires [body content](https://markojs.com/docs/reference/language#tag-content)."
|
10114
10122
|
);
|
10115
10123
|
}
|
10116
10124
|
startSection(tag.get("body"));
|
@@ -10217,7 +10225,7 @@ var try_default = {
|
|
10217
10225
|
autocomplete: [
|
10218
10226
|
{
|
10219
10227
|
description: "Used to capture errors and display placeholders for nested content.",
|
10220
|
-
descriptionMoreURL: "https://
|
10228
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#try"
|
10221
10229
|
}
|
10222
10230
|
],
|
10223
10231
|
types: runtime_info_default.name + "/tags/try.d.marko"
|
@@ -10672,7 +10680,7 @@ var attribute_tag_default = {
|
|
10672
10680
|
trackParamsReferences(body, 3 /* param */);
|
10673
10681
|
if (!(0, import_babel_utils48.findParentTag)(tag)) {
|
10674
10682
|
throw tag.get("name").buildCodeFrameError(
|
10675
|
-
"[Attribute tags](https://
|
10683
|
+
"[Attribute tags](https://markojs.com/docs/reference/language#attribute-tags) must be nested within another tag."
|
10676
10684
|
);
|
10677
10685
|
}
|
10678
10686
|
}
|
@@ -10711,11 +10719,11 @@ var custom_tag_default = {
|
|
10711
10719
|
const tagName = getTagName(tag);
|
10712
10720
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
10713
10721
|
throw tag.get("name").buildCodeFrameError(
|
10714
|
-
`Local variables must be in a [dynamic tag](https://
|
10722
|
+
`Local variables must be in a [dynamic tag](https://markojs.com/docs/reference/language#dynamic-tags) unless they are PascalCase. Use \`<\${${tagName}}/>\` or rename to \`${tagName.charAt(0).toUpperCase() + tagName.slice(1)}\`.`
|
10715
10723
|
);
|
10716
10724
|
}
|
10717
10725
|
throw tag.get("name").buildCodeFrameError(
|
10718
|
-
`Unable to find entry point for [custom tag](https://
|
10726
|
+
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
10719
10727
|
);
|
10720
10728
|
}
|
10721
10729
|
const section = getOrCreateSection(tag);
|
@@ -10734,6 +10742,7 @@ var custom_tag_default = {
|
|
10734
10742
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
10735
10743
|
}
|
10736
10744
|
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
10745
|
+
const mutatesTagVar = !!(tag.node.var?.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
10737
10746
|
if (varBinding) {
|
10738
10747
|
varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding("#scopeOffset", 0 /* dom */, section);
|
10739
10748
|
}
|
@@ -10745,7 +10754,7 @@ var custom_tag_default = {
|
|
10745
10754
|
addBindingSerializeReasonExpr(
|
10746
10755
|
section,
|
10747
10756
|
childScopeBinding,
|
10748
|
-
varSerializeReason
|
10757
|
+
mutatesTagVar || varSerializeReason
|
10749
10758
|
);
|
10750
10759
|
}
|
10751
10760
|
} else {
|
@@ -10771,7 +10780,7 @@ var custom_tag_default = {
|
|
10771
10780
|
addBindingSerializeReasonExpr(
|
10772
10781
|
section,
|
10773
10782
|
childScopeBinding,
|
10774
|
-
varSerializeReason
|
10783
|
+
mutatesTagVar || varSerializeReason
|
10775
10784
|
);
|
10776
10785
|
}
|
10777
10786
|
if (childExtra.inputSerializeReasons) {
|
@@ -10987,16 +10996,21 @@ function translateDOM(tag) {
|
|
10987
10996
|
);
|
10988
10997
|
const inputExport = childExports.input;
|
10989
10998
|
if (node.var) {
|
10999
|
+
const varBinding = node.var.extra.binding;
|
10990
11000
|
const source = initValue(
|
10991
11001
|
// TODO: support destructuring
|
10992
|
-
|
11002
|
+
varBinding
|
10993
11003
|
);
|
10994
11004
|
source.register = true;
|
10995
11005
|
source.buildAssignment = (valueSection, value) => {
|
10996
|
-
|
11006
|
+
const changeArgs = [
|
10997
11007
|
createScopeReadExpression(valueSection, childScopeBinding),
|
10998
11008
|
value
|
10999
|
-
]
|
11009
|
+
];
|
11010
|
+
if (!isOptimize()) {
|
11011
|
+
changeArgs.push(import_compiler56.types.stringLiteral(varBinding.name));
|
11012
|
+
}
|
11013
|
+
return import_compiler56.types.callExpression(importRuntime("_var_change"), changeArgs);
|
11000
11014
|
};
|
11001
11015
|
addStatement(
|
11002
11016
|
"render",
|
@@ -11054,11 +11068,11 @@ function getTagRelativePath(tag) {
|
|
11054
11068
|
const tagName = getTagName(tag);
|
11055
11069
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
11056
11070
|
throw tag.get("name").buildCodeFrameError(
|
11057
|
-
`Local variables must be in a [dynamic tag](https://
|
11071
|
+
`Local variables must be in a [dynamic tag](https://markojs.com/docs/reference/language#dynamic-tags) unless they are PascalCase. Use \`<\${${tagName}}/>\` or rename to \`${tagName.charAt(0).toUpperCase() + tagName.slice(1)}\`.`
|
11058
11072
|
);
|
11059
11073
|
}
|
11060
11074
|
throw tag.get("name").buildCodeFrameError(
|
11061
|
-
`Unable to find entry point for [custom tag](https://
|
11075
|
+
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
11062
11076
|
);
|
11063
11077
|
}
|
11064
11078
|
return relativePath;
|
@@ -11741,13 +11755,14 @@ var dynamic_tag_default = {
|
|
11741
11755
|
const signal = getSignal(section, nodeBinding, "dynamicTag");
|
11742
11756
|
let tagVarSignal;
|
11743
11757
|
if (tag.node.var) {
|
11758
|
+
const varBinding = tag.node.var.extra.binding;
|
11744
11759
|
tagVarSignal = initValue(
|
11745
11760
|
// TODO: support destructuring
|
11746
|
-
|
11761
|
+
varBinding
|
11747
11762
|
);
|
11748
11763
|
tagVarSignal.register = true;
|
11749
11764
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
11750
|
-
|
11765
|
+
const changeArgs = [
|
11751
11766
|
import_compiler57.types.memberExpression(
|
11752
11767
|
getScopeExpression(tagVarSignal.section, valueSection),
|
11753
11768
|
import_compiler57.types.stringLiteral(
|
@@ -11756,7 +11771,11 @@ var dynamic_tag_default = {
|
|
11756
11771
|
true
|
11757
11772
|
),
|
11758
11773
|
value
|
11759
|
-
]
|
11774
|
+
];
|
11775
|
+
if (!isOptimize()) {
|
11776
|
+
changeArgs.push(import_compiler57.types.stringLiteral(varBinding.name));
|
11777
|
+
}
|
11778
|
+
return import_compiler57.types.callExpression(importRuntime("_var_change"), changeArgs);
|
11760
11779
|
};
|
11761
11780
|
}
|
11762
11781
|
signal.build = () => {
|
package/package.json
CHANGED
package/tags/id.d.marko
CHANGED
package/tags/let.d.marko
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
/** File for types only, not actual implementation **/
|
2
2
|
|
3
|
-
export interface Input<T> {
|
3
|
+
export interface Input<T, K = T> {
|
4
4
|
value: T;
|
5
|
-
valueChange?: (newValue:
|
5
|
+
valueChange?: ((newValue: K) => void) | false | null;
|
6
6
|
}
|
7
7
|
|
8
|
-
return=input.value valueChange=input.valueChange
|
8
|
+
return=input.value valueChange=(input.valueChange as (newValue: K) => void)
|