marko 5.36.5 → 5.37.0

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.
Files changed (244) hide show
  1. package/dist/compiler/index.js +11 -11
  2. package/dist/core-tags/components/init-components-tag.js +4 -4
  3. package/dist/core-tags/components/preferred-script-location-tag.js +2 -2
  4. package/dist/core-tags/core/__flush_here_and_after__.js +1 -1
  5. package/dist/core-tags/core/await/AsyncValue.js +21 -21
  6. package/dist/core-tags/core/await/renderer.js +24 -24
  7. package/dist/core-tags/core/await/reorderer-renderer.js +6 -6
  8. package/dist/node-require/browser-refresh.js +18 -1
  9. package/dist/node-require/index.js +7 -7
  10. package/dist/node_modules/@internal/components-beginComponent/index-browser.js +5 -5
  11. package/dist/node_modules/@internal/components-beginComponent/index.js +12 -12
  12. package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +99 -99
  13. package/dist/node_modules/@internal/components-define-widget-legacy/index.js +3 -3
  14. package/dist/node_modules/@internal/components-endComponent/index.js +3 -3
  15. package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
  16. package/dist/node_modules/@internal/components-entry/index.js +29 -29
  17. package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +13 -13
  18. package/dist/node_modules/@internal/components-entry-legacy/index.js +1 -1
  19. package/dist/node_modules/@internal/components-registry/index-browser.js +102 -102
  20. package/dist/node_modules/@internal/components-registry/index.js +2 -2
  21. package/dist/node_modules/@internal/components-util/index-browser.js +20 -20
  22. package/dist/node_modules/@internal/components-util/index.js +24 -20
  23. package/dist/node_modules/@internal/create-readable/index-browser.js +1 -1
  24. package/dist/node_modules/@internal/create-readable/index.js +9 -9
  25. package/dist/node_modules/@internal/preserve-tag/index-browser.js +8 -8
  26. package/dist/node_modules/@internal/preserve-tag/index.js +6 -6
  27. package/dist/node_modules/@internal/set-immediate/index-browser.js +2 -2
  28. package/dist/node_modules/@internal/set-immediate/index-worker.js +3 -3
  29. package/dist/node_modules/@internal/set-immediate/index.js +3 -3
  30. package/dist/runtime/RenderResult.js +24 -24
  31. package/dist/runtime/components/Component.js +163 -163
  32. package/dist/runtime/components/ComponentDef.js +34 -34
  33. package/dist/runtime/components/ComponentsContext.js +20 -20
  34. package/dist/runtime/components/GlobalComponentsContext.js +4 -4
  35. package/dist/runtime/components/KeySequence.js +3 -3
  36. package/dist/runtime/components/ServerComponent.js +17 -17
  37. package/dist/runtime/components/State.js +28 -28
  38. package/dist/runtime/components/attach-detach.js +8 -8
  39. package/dist/runtime/components/defineComponent.js +5 -5
  40. package/dist/runtime/components/dom-data.js +6 -6
  41. package/dist/runtime/components/event-delegation.js +10 -10
  42. package/dist/runtime/components/legacy/defineComponent-legacy.js +1 -1
  43. package/dist/runtime/components/legacy/defineRenderer-legacy.js +25 -25
  44. package/dist/runtime/components/legacy/dependencies/index.js +10 -10
  45. package/dist/runtime/components/legacy/renderer-legacy.js +56 -56
  46. package/dist/runtime/components/renderer.js +45 -45
  47. package/dist/runtime/components/update-manager.js +4 -4
  48. package/dist/runtime/createOut.js +1 -1
  49. package/dist/runtime/dom-insert.js +5 -5
  50. package/dist/runtime/helpers/_change-case.js +2 -2
  51. package/dist/runtime/helpers/dynamic-tag.js +33 -33
  52. package/dist/runtime/helpers/render-tag.js +1 -1
  53. package/dist/runtime/helpers/serialize-noop.js +2 -2
  54. package/dist/runtime/helpers/style-value.js +1 -1
  55. package/dist/runtime/helpers/tags-compat/runtime-dom.js +35 -35
  56. package/dist/runtime/helpers/tags-compat/runtime-html.js +16 -16
  57. package/dist/runtime/html/AsyncStream.js +28 -28
  58. package/dist/runtime/html/BufferedWriter.js +2 -2
  59. package/dist/runtime/html/StringWriter.js +2 -2
  60. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  61. package/dist/runtime/html/helpers/attr.js +11 -11
  62. package/dist/runtime/html/helpers/attrs.js +6 -6
  63. package/dist/runtime/html/helpers/data-marko.js +6 -6
  64. package/dist/runtime/html/helpers/escape-quotes.js +2 -2
  65. package/dist/runtime/html/helpers/escape-xml.js +1 -1
  66. package/dist/runtime/html/helpers/merge-attrs.js +11 -11
  67. package/dist/runtime/html/helpers/props-script.js +1 -1
  68. package/dist/runtime/html/index.js +2 -2
  69. package/dist/runtime/renderable.js +5 -5
  70. package/dist/runtime/vdom/AsyncVDOMBuilder.js +100 -100
  71. package/dist/runtime/vdom/VComment.js +7 -7
  72. package/dist/runtime/vdom/VComponent.js +5 -5
  73. package/dist/runtime/vdom/VDocumentFragment.js +8 -8
  74. package/dist/runtime/vdom/VElement.js +52 -52
  75. package/dist/runtime/vdom/VFragment.js +9 -9
  76. package/dist/runtime/vdom/VNode.js +34 -34
  77. package/dist/runtime/vdom/VText.js +8 -8
  78. package/dist/runtime/vdom/helpers/attrs.js +6 -6
  79. package/dist/runtime/vdom/helpers/const-element.js +3 -3
  80. package/dist/runtime/vdom/hot-reload.js +20 -20
  81. package/dist/runtime/vdom/index.js +2 -2
  82. package/dist/runtime/vdom/morphdom/fragment.js +10 -10
  83. package/dist/runtime/vdom/morphdom/helpers.js +5 -5
  84. package/dist/runtime/vdom/morphdom/index.js +81 -81
  85. package/dist/runtime/vdom/vdom.js +15 -15
  86. package/dist/taglib/index.js +7 -7
  87. package/dist/translator/cdata/index.js +15 -0
  88. package/dist/translator/cdata/index[html].js +15 -0
  89. package/dist/translator/cdata/index[vdom].js +12 -0
  90. package/dist/translator/class.js +65 -0
  91. package/dist/translator/comment/index.js +15 -0
  92. package/dist/translator/comment/index[html].js +17 -0
  93. package/dist/translator/comment/index[vdom].js +3 -0
  94. package/dist/translator/declaration/index.js +15 -0
  95. package/dist/translator/declaration/index[html].js +12 -0
  96. package/dist/translator/declaration/index[vdom].js +3 -0
  97. package/dist/translator/document-type/index.js +15 -0
  98. package/dist/translator/document-type/index[html].js +12 -0
  99. package/dist/translator/document-type/index[vdom].js +3 -0
  100. package/dist/translator/index.js +551 -0
  101. package/dist/translator/placeholder/index.js +15 -0
  102. package/dist/translator/placeholder/index[html].js +93 -0
  103. package/dist/translator/placeholder/index[vdom].js +22 -0
  104. package/dist/translator/scriptlet.js +4 -0
  105. package/dist/translator/tag/attribute/directives/class.js +42 -0
  106. package/dist/translator/tag/attribute/directives/index.js +15 -0
  107. package/dist/translator/tag/attribute/directives/no-update-body-if.js +15 -0
  108. package/dist/translator/tag/attribute/directives/no-update-body.js +10 -0
  109. package/dist/translator/tag/attribute/directives/no-update-if.js +12 -0
  110. package/dist/translator/tag/attribute/directives/no-update.js +48 -0
  111. package/dist/translator/tag/attribute/directives/style.js +42 -0
  112. package/dist/translator/tag/attribute/index.js +150 -0
  113. package/dist/translator/tag/attribute/modifiers/index.js +7 -0
  114. package/dist/translator/tag/attribute/modifiers/no-update.js +14 -0
  115. package/dist/translator/tag/attribute/modifiers/scoped.js +23 -0
  116. package/dist/translator/tag/attribute-tag.js +149 -0
  117. package/dist/translator/tag/custom-tag.js +146 -0
  118. package/dist/translator/tag/dynamic-tag.js +74 -0
  119. package/dist/translator/tag/index.js +287 -0
  120. package/dist/translator/tag/macro-tag.js +7 -0
  121. package/dist/translator/tag/native-tag.js +27 -0
  122. package/dist/translator/tag/native-tag[html]/attributes.js +151 -0
  123. package/dist/translator/tag/native-tag[html]/index.js +221 -0
  124. package/dist/translator/tag/native-tag[vdom]/attributes.js +105 -0
  125. package/dist/translator/tag/native-tag[vdom]/index.js +189 -0
  126. package/dist/translator/tag/util.js +246 -0
  127. package/dist/translator/taglib/core/conditional/translate-else-if.js +20 -0
  128. package/dist/translator/taglib/core/conditional/translate-else.js +20 -0
  129. package/dist/translator/taglib/core/conditional/translate-if.js +8 -0
  130. package/dist/translator/taglib/core/conditional/util.js +41 -0
  131. package/dist/translator/taglib/core/index.js +474 -0
  132. package/dist/translator/taglib/core/macro/parse.js +17 -0
  133. package/dist/translator/taglib/core/macro/translate.js +48 -0
  134. package/dist/translator/taglib/core/parse-class.js +79 -0
  135. package/dist/translator/taglib/core/parse-export.js +14 -0
  136. package/dist/translator/taglib/core/parse-import.js +14 -0
  137. package/dist/translator/taglib/core/parse-module-code.js +18 -0
  138. package/dist/translator/taglib/core/parse-static.js +18 -0
  139. package/dist/translator/taglib/core/transform-style.js +66 -0
  140. package/dist/translator/taglib/core/translate-await.js +41 -0
  141. package/dist/translator/taglib/core/translate-body.js +17 -0
  142. package/dist/translator/taglib/core/translate-for.js +156 -0
  143. package/dist/translator/taglib/core/translate-html-comment.js +52 -0
  144. package/dist/translator/taglib/core/translate-include-content.js +53 -0
  145. package/dist/translator/taglib/core/translate-server-only.js +5 -0
  146. package/dist/translator/taglib/core/translate-while.js +32 -0
  147. package/dist/translator/taglib/index.js +6 -0
  148. package/dist/translator/taglib/migrate/all-templates.js +46 -0
  149. package/dist/translator/taglib/migrate/index.js +5 -0
  150. package/dist/translator/text/index.js +10 -0
  151. package/dist/translator/text/index[html].js +12 -0
  152. package/dist/translator/text/index[vdom].js +20 -0
  153. package/dist/translator/util/add-dependencies.js +329 -0
  154. package/dist/translator/util/escape-regexp.js +4 -0
  155. package/dist/translator/util/get-component-files.js +86 -0
  156. package/dist/translator/util/html-out-write.js +15 -0
  157. package/dist/translator/util/key-manager.js +176 -0
  158. package/dist/translator/util/optimize-html-writes.js +52 -0
  159. package/dist/translator/util/optimize-vdom-create.js +164 -0
  160. package/dist/translator/util/plugin-hooks.js +22 -0
  161. package/dist/translator/util/runtime-flags.js +3 -0
  162. package/dist/translator/util/vdom-out-write.js +10 -0
  163. package/dist/translator/util/with-previous-location.js +6 -0
  164. package/package.json +7 -4
  165. package/src/taglib/index.js +2 -2
  166. package/src/translator/cdata/index.js +15 -0
  167. package/src/translator/cdata/index[html].js +15 -0
  168. package/src/translator/cdata/index[vdom].js +12 -0
  169. package/src/translator/class.js +65 -0
  170. package/src/translator/comment/index.js +15 -0
  171. package/src/translator/comment/index[html].js +17 -0
  172. package/src/translator/comment/index[vdom].js +3 -0
  173. package/src/translator/declaration/index.js +15 -0
  174. package/src/translator/declaration/index[html].js +12 -0
  175. package/src/translator/declaration/index[vdom].js +3 -0
  176. package/src/translator/document-type/index.js +15 -0
  177. package/src/translator/document-type/index[html].js +12 -0
  178. package/src/translator/document-type/index[vdom].js +3 -0
  179. package/src/translator/index.js +551 -0
  180. package/src/translator/placeholder/index.js +15 -0
  181. package/src/translator/placeholder/index[html].js +93 -0
  182. package/src/translator/placeholder/index[vdom].js +22 -0
  183. package/src/translator/scriptlet.js +4 -0
  184. package/src/translator/tag/attribute/directives/class.js +42 -0
  185. package/src/translator/tag/attribute/directives/index.js +15 -0
  186. package/src/translator/tag/attribute/directives/no-update-body-if.js +15 -0
  187. package/src/translator/tag/attribute/directives/no-update-body.js +10 -0
  188. package/src/translator/tag/attribute/directives/no-update-if.js +12 -0
  189. package/src/translator/tag/attribute/directives/no-update.js +48 -0
  190. package/src/translator/tag/attribute/directives/style.js +42 -0
  191. package/src/translator/tag/attribute/index.js +150 -0
  192. package/src/translator/tag/attribute/modifiers/index.js +7 -0
  193. package/src/translator/tag/attribute/modifiers/no-update.js +14 -0
  194. package/src/translator/tag/attribute/modifiers/scoped.js +23 -0
  195. package/src/translator/tag/attribute-tag.js +149 -0
  196. package/src/translator/tag/custom-tag.js +146 -0
  197. package/src/translator/tag/dynamic-tag.js +74 -0
  198. package/src/translator/tag/index.js +287 -0
  199. package/src/translator/tag/macro-tag.js +7 -0
  200. package/src/translator/tag/native-tag.js +27 -0
  201. package/src/translator/tag/native-tag[html]/attributes.js +151 -0
  202. package/src/translator/tag/native-tag[html]/index.js +221 -0
  203. package/src/translator/tag/native-tag[vdom]/attributes.js +105 -0
  204. package/src/translator/tag/native-tag[vdom]/index.js +189 -0
  205. package/src/translator/tag/util.js +246 -0
  206. package/src/translator/taglib/core/conditional/translate-else-if.js +20 -0
  207. package/src/translator/taglib/core/conditional/translate-else.js +20 -0
  208. package/src/translator/taglib/core/conditional/translate-if.js +8 -0
  209. package/src/translator/taglib/core/conditional/util.js +41 -0
  210. package/src/translator/taglib/core/index.js +474 -0
  211. package/src/translator/taglib/core/macro/parse.js +17 -0
  212. package/src/translator/taglib/core/macro/translate.js +48 -0
  213. package/src/translator/taglib/core/parse-class.js +79 -0
  214. package/src/translator/taglib/core/parse-export.js +14 -0
  215. package/src/translator/taglib/core/parse-import.js +14 -0
  216. package/src/translator/taglib/core/parse-module-code.js +18 -0
  217. package/src/translator/taglib/core/parse-static.js +18 -0
  218. package/src/translator/taglib/core/transform-style.js +66 -0
  219. package/src/translator/taglib/core/translate-await.js +41 -0
  220. package/src/translator/taglib/core/translate-body.js +17 -0
  221. package/src/translator/taglib/core/translate-for.js +156 -0
  222. package/src/translator/taglib/core/translate-html-comment.js +52 -0
  223. package/src/translator/taglib/core/translate-include-content.js +53 -0
  224. package/src/translator/taglib/core/translate-server-only.js +5 -0
  225. package/src/translator/taglib/core/translate-while.js +32 -0
  226. package/src/translator/taglib/index.js +7 -0
  227. package/src/translator/taglib/migrate/all-templates.js +46 -0
  228. package/src/translator/taglib/migrate/index.js +5 -0
  229. package/src/translator/text/index.js +10 -0
  230. package/src/translator/text/index[html].js +12 -0
  231. package/src/translator/text/index[vdom].js +20 -0
  232. package/src/translator/util/add-dependencies.js +329 -0
  233. package/src/translator/util/escape-regexp.js +4 -0
  234. package/src/translator/util/get-component-files.js +86 -0
  235. package/src/translator/util/html-out-write.js +15 -0
  236. package/src/translator/util/key-manager.js +176 -0
  237. package/src/translator/util/optimize-html-writes.js +52 -0
  238. package/src/translator/util/optimize-vdom-create.js +164 -0
  239. package/src/translator/util/plugin-hooks.js +22 -0
  240. package/src/translator/util/runtime-flags.js +3 -0
  241. package/src/translator/util/vdom-out-write.js +10 -0
  242. package/src/translator/util/with-previous-location.js +6 -0
  243. package/translator/index.d.ts +7 -0
  244. package/translator/package.json +5 -0
@@ -0,0 +1,474 @@
1
+ import * as translateElse from "./conditional/translate-else";
2
+ import * as translateElseIf from "./conditional/translate-else-if";
3
+ import * as translateIf from "./conditional/translate-if";
4
+ import * as parseMacro from "./macro/parse";
5
+ import * as translateMacro from "./macro/translate";
6
+ import * as parseClass from "./parse-class";
7
+ import * as parseExport from "./parse-export";
8
+ import * as parseImport from "./parse-import";
9
+ import * as parseModuleCode from "./parse-module-code";
10
+ import * as parseStatic from "./parse-static";
11
+ import * as transformStyle from "./transform-style";
12
+ import * as translateAwait from "./translate-await";
13
+ import * as translateBody from "./translate-body";
14
+ import * as translateFor from "./translate-for";
15
+ import * as translateHTMLComment from "./translate-html-comment";
16
+ import * as translateIncludeContent from "./translate-include-content";
17
+ import * as translateServerOnly from "./translate-server-only";
18
+ import * as translateWhile from "./translate-while";
19
+
20
+ export default {
21
+ "taglib-id": "marko-default-core",
22
+ "<import>": {
23
+ "node-factory": parseImport,
24
+ "parse-options": {
25
+ statement: true,
26
+ rawOpenTag: true,
27
+ },
28
+ autocomplete: [
29
+ {
30
+ displayText: 'import <scope> from "<path>"',
31
+ description:
32
+ "Use to import external modules, follows the same syntax as JavaScript imports.",
33
+ snippet: 'import ${2} from "${1:path}"',
34
+ descriptionMoreURL:
35
+ "https://markojs.com/docs/syntax/#importing-external-files",
36
+ },
37
+ ],
38
+ },
39
+ "<export>": {
40
+ "node-factory": parseExport,
41
+ "parse-options": {
42
+ statement: true,
43
+ rawOpenTag: true,
44
+ },
45
+ autocomplete: [
46
+ {
47
+ displayText: "export <scope>",
48
+ description:
49
+ "Use export additional data with the template, follows the same syntax as JavaScript exports.",
50
+ snippet: "export ${1}",
51
+ descriptionMoreURL:
52
+ "https://markojs.com/docs/syntax/#importing-external-files",
53
+ },
54
+ ],
55
+ },
56
+ "<class>": {
57
+ "node-factory": parseClass,
58
+ "parse-options": {
59
+ statement: true,
60
+ rawOpenTag: true,
61
+ },
62
+ autocomplete: [
63
+ {
64
+ displayText: "class { /** lifecycle methods **/ }",
65
+ snippet: "class {\n\t$0\n}",
66
+ description:
67
+ "A class containing the lifecycle methods, event handlers, and other properties for this component.",
68
+ descriptionMoreURL:
69
+ "https://markojs.com/docs/class-components/#single-file-components",
70
+ },
71
+ ],
72
+ },
73
+ "<static>": {
74
+ "node-factory": parseStatic,
75
+ "parse-options": {
76
+ statement: true,
77
+ rawOpenTag: true,
78
+ },
79
+ autocomplete: [
80
+ {
81
+ displayText: "static <statement>",
82
+ description:
83
+ "A JavaScript statement which is only evaluated once your template is loaded.",
84
+ descriptionMoreURL:
85
+ "https://markojs.com/docs/syntax/#static-javascript",
86
+ },
87
+ ],
88
+ },
89
+ "<style>": {
90
+ transformer: transformStyle,
91
+ "parse-options": {
92
+ rawOpenTag: true,
93
+ },
94
+ },
95
+ "<macro>": {
96
+ "node-factory": parseMacro,
97
+ "code-generator": translateMacro,
98
+ "@name": {
99
+ type: "string",
100
+ autocomplete: [
101
+ {
102
+ description: "The name which can be used as a tag within a template.",
103
+ },
104
+ ],
105
+ },
106
+ autocomplete: [
107
+ {
108
+ displayText: 'macro|<params>| name="<name>"',
109
+ description: "Creates a reusable fragment within the template.",
110
+ snippet: 'macro|${2:param1, param2}| name="${1:name}"',
111
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#macro",
112
+ },
113
+ ],
114
+ },
115
+ "<include-text>": {
116
+ "code-generator": translateIncludeContent,
117
+ attributes: {},
118
+ autocomplete: [
119
+ {
120
+ displayText: 'include-text("<path>")',
121
+ description: "Allows you to inline the contents of a text file.",
122
+ snippet: 'include-text(${1:"./foo.txt"})',
123
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#include-text",
124
+ },
125
+ ],
126
+ },
127
+ "<include-html>": {
128
+ "code-generator": translateIncludeContent,
129
+ attributes: {},
130
+ autocomplete: [
131
+ {
132
+ displayText: 'include-html("<path>")',
133
+ snippet: 'include-html(${1:"./foo.html"})',
134
+ description: "Allows you to inline the contents of an html file.",
135
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#include-html",
136
+ },
137
+ ],
138
+ },
139
+ "<if>": {
140
+ "parse-options": { controlFlow: true },
141
+ "code-generator": translateIf,
142
+ attributes: {},
143
+ autocomplete: [
144
+ {
145
+ snippet: "if(${1:condition})",
146
+ description: "Use to display content only if the condition is meant.",
147
+ descriptionMoreURL:
148
+ "https://markojs.com/docs/core-tags/#if-else-if-else",
149
+ },
150
+ ],
151
+ },
152
+ "<else-if>": {
153
+ "parse-options": { controlFlow: true },
154
+ "code-generator": translateElseIf,
155
+ attributes: {},
156
+ autocomplete: [
157
+ {
158
+ snippet: "else-if(${1:condition})",
159
+ description:
160
+ "Use after an <if> or <else-if> tag to display content if those conditions do not match and this one does.",
161
+ descriptionMoreURL:
162
+ "https://markojs.com/docs/core-tags/#if-else-if-else",
163
+ },
164
+ ],
165
+ },
166
+ "<else>": {
167
+ "parse-options": { controlFlow: true },
168
+ "code-generator": translateElse,
169
+ attributes: {},
170
+ autocomplete: [
171
+ {
172
+ description:
173
+ "Use after an <if> or <else-if> tag to display content if those conditions do not match.",
174
+ descriptionMoreURL:
175
+ "https://markojs.com/docs/core-tags/#if-else-if-else",
176
+ },
177
+ ],
178
+ },
179
+ "<for>": {
180
+ "parse-options": { controlFlow: true },
181
+ "code-generator": translateFor,
182
+ "@of": {
183
+ type: "expression",
184
+ autocomplete: [
185
+ {
186
+ description: "Iterates over a list of items.",
187
+ },
188
+ ],
189
+ },
190
+ "@in": {
191
+ type: "expression",
192
+ autocomplete: [
193
+ {
194
+ description: "Iterates over the keys and values of an object.",
195
+ },
196
+ ],
197
+ },
198
+ "@to": {
199
+ type: "number",
200
+ autocomplete: [
201
+ {
202
+ description: "Iterates up to the provided number (inclusive)",
203
+ },
204
+ ],
205
+ },
206
+ "@from": {
207
+ type: "number",
208
+ autocomplete: [
209
+ {
210
+ description: "Iterates starting from the provided number (inclusive)",
211
+ },
212
+ ],
213
+ },
214
+ "@step": {
215
+ type: "number",
216
+ autocomplete: [
217
+ {
218
+ description:
219
+ "The amount to increment during each interation (with from/to)",
220
+ },
221
+ ],
222
+ },
223
+ autocomplete: [
224
+ {
225
+ snippet: "for|${1:value, index}| of=${3:array}",
226
+ description:
227
+ "Use to iterate over lists, object properties, or between ranges.",
228
+ descriptionMoreURL:
229
+ "https://markojs.com/docs/core-tags/#iterating-over-a-list",
230
+ },
231
+ {
232
+ snippet: "for|${1:name, value}| in=${3:object}",
233
+ descriptionMoreURL:
234
+ "https://markojs.com/docs/core-tags/#iterating-over-an-objects-properties",
235
+ },
236
+ {
237
+ snippet:
238
+ "for|${1:index}| from=${2:number} to=${3:number} step=${4:number}",
239
+ descriptionMoreURL:
240
+ "https://markojs.com/docs/core-tags/#iterating-between-a-range-of-numbers",
241
+ },
242
+ ],
243
+ },
244
+ "<while>": {
245
+ "parse-options": { controlFlow: true },
246
+ "code-generator": translateWhile,
247
+ autocomplete: [
248
+ {
249
+ snippet: "while(${1:condition})",
250
+ description:
251
+ "Renders the content multiple times until the condition is no longer met.",
252
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#while",
253
+ },
254
+ ],
255
+ },
256
+ "<html-comment>": {
257
+ "code-generator": translateHTMLComment,
258
+ "parse-options": {
259
+ text: true,
260
+ },
261
+ attributes: {},
262
+ autocomplete: [
263
+ {
264
+ description:
265
+ "Use to create an html comment that is not stripped from the output.",
266
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#html-comment",
267
+ },
268
+ ],
269
+ },
270
+ "<_preserve>": {
271
+ renderer: "marko/src/core-tags/components/preserve-tag.js",
272
+ "@n": "boolean",
273
+ "@i": "boolean",
274
+ "@b": "boolean",
275
+ autocomplete: [],
276
+ },
277
+ "<init-components>": {
278
+ "code-generator": translateServerOnly,
279
+ renderer: "marko/src/core-tags/components/init-components-tag.js",
280
+ "@immediate": "boolean",
281
+ },
282
+ "<_preferred-script-location>": {
283
+ "code-generator": translateServerOnly,
284
+ renderer: "marko/src/core-tags/components/preferred-script-location-tag.js",
285
+ },
286
+ "<body>": {
287
+ "code-generator": translateBody,
288
+ },
289
+ "<await>": {
290
+ renderer: "marko/src/core-tags/core/await/renderer.js",
291
+ types: "marko/src/core-tags/core/await/index.d.marko",
292
+ "code-generator": translateAwait,
293
+ "@_provider": "expression",
294
+ "@_name": "string",
295
+ "@name": {
296
+ type: "string",
297
+ autocomplete: [
298
+ {
299
+ description:
300
+ "Used to improve debugging and also to ensure promise ordering with the show-after attribute.",
301
+ snippet: 'name="${1:name}"',
302
+ },
303
+ ],
304
+ },
305
+ "@timeout": {
306
+ type: "number",
307
+ autocomplete: [
308
+ {
309
+ description:
310
+ "An optional timeout that when reached will cause the promise to reject with a TimeoutError.",
311
+ },
312
+ ],
313
+ },
314
+ "@client-reorder": {
315
+ type: "boolean",
316
+ autocomplete: [
317
+ {
318
+ description:
319
+ "If set anything after this promise will be sent out immediately, and reordered using JS in the browser.",
320
+ },
321
+ ],
322
+ },
323
+ "@show-after": {
324
+ type: "string",
325
+ autocomplete: [
326
+ {
327
+ description:
328
+ "This attribute will ensure that (with client-reorder) this await tag will always show after another await tag with the provided name.",
329
+ },
330
+ ],
331
+ },
332
+ "@then <then>": {
333
+ autocomplete: [
334
+ {
335
+ displayText: "then|<result>|",
336
+ description: "Executed with the result of the resolved promise.",
337
+ snippet: "then|${1:result}|",
338
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#await",
339
+ },
340
+ ],
341
+ },
342
+ "@catch <catch>": {
343
+ autocomplete: [
344
+ {
345
+ displayText: "catch|<err>|",
346
+ description: "Executed with the err of the rejected promise.",
347
+ snippet: "catch|${1:err}|",
348
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#await",
349
+ },
350
+ ],
351
+ },
352
+ "@placeholder <placeholder>": {
353
+ autocomplete: [
354
+ {
355
+ description: "A placeholder to display while the promise is pending.",
356
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#await",
357
+ },
358
+ ],
359
+ },
360
+ autocomplete: [
361
+ {
362
+ displayText: "await(<promise>)",
363
+ description:
364
+ "Used to render a template asynchronously with the results of a Promise",
365
+ snippet: "await(${1:promise})",
366
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#await",
367
+ },
368
+ ],
369
+ },
370
+ "<await-reorderer>": {
371
+ "code-generator": translateServerOnly,
372
+ renderer: "marko/src/core-tags/core/await/reorderer-renderer.js",
373
+ autocomplete: [
374
+ {
375
+ snippet: "await-reorderer",
376
+ descriptionMoreURL: "https://markojs.com/docs/core-tags/#await",
377
+ },
378
+ ],
379
+ },
380
+ "<__flush_here_and_after__>": {
381
+ "code-generator": translateServerOnly,
382
+ renderer: "marko/src/core-tags/core/__flush_here_and_after__.js",
383
+ },
384
+ "<module-code>": {
385
+ "node-factory": parseModuleCode,
386
+ "parse-options": {
387
+ rawOpenTag: true,
388
+ },
389
+ },
390
+ "<*>": {
391
+ "@key": {
392
+ type: "string",
393
+ "preserve-name": true,
394
+ autocomplete: [
395
+ {
396
+ displayText: 'key="<method>"',
397
+ snippet: 'key="${1:method}"',
398
+ descriptionMoreURL: "https://markojs.com/docs/class-components/#key",
399
+ },
400
+ {
401
+ descriptionMoreURL: "https://markojs.com/docs/class-components/#key",
402
+ },
403
+ ],
404
+ },
405
+ "@on*": {
406
+ pattern: true,
407
+ type: "statement",
408
+ "allow-expressions": true,
409
+ "preserve-name": true,
410
+ "set-flag": "hasComponentEvents",
411
+ autocomplete: [
412
+ {
413
+ displayText: 'on<event>("<method>")',
414
+ snippet: 'on${1:Click}("handle${2:Button}${1:Click}")',
415
+ descriptionMoreURL:
416
+ "https://markojs.com/docs/components/#attaching-dom-event-listeners",
417
+ },
418
+ ],
419
+ },
420
+ "@once*": {
421
+ pattern: true,
422
+ type: "statement",
423
+ "allow-expressions": true,
424
+ "preserve-name": true,
425
+ "set-flag": "hasComponentEvents",
426
+ autocomplete: {
427
+ displayText: 'once<event>("<method>")',
428
+ snippet: 'once${1:Click}("handle${2:Button}${1:Click}")',
429
+ descriptionMoreURL:
430
+ "https://markojs.com/docs/components/#attaching-dom-event-listeners",
431
+ },
432
+ },
433
+ "@no-update": {
434
+ type: "flag",
435
+ "preserve-name": true,
436
+ autocomplete: [
437
+ {
438
+ descriptionMoreURL:
439
+ "https://markojs.com/docs/class-components/#no-update",
440
+ },
441
+ ],
442
+ },
443
+ "@no-update-body": {
444
+ type: "flag",
445
+ "preserve-name": true,
446
+ autocomplete: [
447
+ {
448
+ descriptionMoreURL:
449
+ "https://markojs.com/docs/class-components/#no-update-body",
450
+ },
451
+ ],
452
+ },
453
+ "@no-update-if": {
454
+ "preserve-name": true,
455
+ autocomplete: [
456
+ {
457
+ snippet: "no-update-if(${1:condition})",
458
+ descriptionMoreURL:
459
+ "https://markojs.com/docs/class-components/#no-update-if",
460
+ },
461
+ ],
462
+ },
463
+ "@no-update-body-if": {
464
+ "preserve-name": true,
465
+ autocomplete: [
466
+ {
467
+ snippet: "no-update-body-if(${1:condition})",
468
+ descriptionMoreURL:
469
+ "https://markojs.com/docs/class-components/#no-update-body-if",
470
+ },
471
+ ],
472
+ },
473
+ },
474
+ };
@@ -0,0 +1,17 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { registerMacro } from "@marko/compiler/babel-utils";
3
+
4
+ export default function (path) {
5
+ const attrs = path.node.attributes;
6
+ if (attrs.length === 1) {
7
+ const [attr] = attrs;
8
+
9
+ if (
10
+ t.isMarkoAttribute(attr) &&
11
+ attr.name === "name" &&
12
+ t.isStringLiteral(attr.value)
13
+ ) {
14
+ registerMacro(path.get("attributes")[0], attr.value.value);
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,48 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import {
3
+ diagnosticError,
4
+ getMacroIdentifierForName,
5
+ } from "@marko/compiler/babel-utils";
6
+
7
+ import withPreviousLocation from "../../../util/with-previous-location";
8
+
9
+ export function exit(path) {
10
+ const { node } = path;
11
+ const { attributes, body } = node;
12
+ if (attributes.length === 0) {
13
+ diagnosticError(path, {
14
+ label: "The 'macro' tag must have a 'name' attribute.",
15
+ });
16
+ path.remove();
17
+ return;
18
+ }
19
+
20
+ if (attributes.length > 1) {
21
+ diagnosticError(path, {
22
+ label: "The 'macro' tag can only have a 'name' attribute.",
23
+ });
24
+ path.remove();
25
+ return;
26
+ }
27
+
28
+ const [nameAttr] = attributes;
29
+ if (!t.isStringLiteral(nameAttr.value)) {
30
+ diagnosticError(path, {
31
+ label: "The 'name' attribute for 'macro' tags must be a string literal.",
32
+ loc: nameAttr.loc || node.loc || undefined,
33
+ });
34
+ path.remove();
35
+ return;
36
+ }
37
+
38
+ path.replaceWith(
39
+ withPreviousLocation(
40
+ t.functionDeclaration(
41
+ getMacroIdentifierForName(path, nameAttr.value.value),
42
+ [t.identifier("out"), ...body.params],
43
+ t.blockStatement(body.body),
44
+ ),
45
+ node,
46
+ ),
47
+ );
48
+ }
@@ -0,0 +1,79 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import {
3
+ diagnosticDeprecate,
4
+ diagnosticError,
5
+ parseExpression,
6
+ } from "@marko/compiler/babel-utils";
7
+
8
+ import getComponentFiles from "../../util/get-component-files";
9
+
10
+ export default function (path) {
11
+ const {
12
+ node,
13
+ hub: { file },
14
+ } = path;
15
+ const {
16
+ rawValue: code,
17
+ name: { start, end },
18
+ } = node;
19
+ const meta = file.metadata.marko;
20
+
21
+ if (meta.hasComponent) {
22
+ diagnosticError(path.get("name"), {
23
+ label: "A Marko component can only have one top level class.",
24
+ });
25
+ path.remove();
26
+ return;
27
+ }
28
+
29
+ meta.hasComponent = true;
30
+
31
+ if (getComponentFiles(path).componentFile) {
32
+ diagnosticError(path.get("name"), {
33
+ label:
34
+ 'A Marko file can either have an inline class, or an external "component.js", but not both.',
35
+ });
36
+
37
+ path.remove();
38
+ return;
39
+ }
40
+
41
+ const parsed = parseExpression(file, code.replace(/;\s*$/, ""), start, end);
42
+ if (parsed.type === "MarkoParseError") {
43
+ path.replaceWith(t.markoClass([t.expressionStatement(parsed)]));
44
+ return;
45
+ }
46
+
47
+ if (parsed.superClass) {
48
+ diagnosticError(path, {
49
+ label: "Component class cannot have a super class.",
50
+ loc: parsed.superClass.loc,
51
+ });
52
+ }
53
+
54
+ const constructorPropIndex = parsed.body.body.findIndex(
55
+ (prop) => t.isClassMethod(prop) && prop.kind === "constructor",
56
+ );
57
+ if (constructorPropIndex !== -1) {
58
+ const constructorProp = parsed.body.body[constructorPropIndex];
59
+ diagnosticError(path, {
60
+ label:
61
+ "The constructor method should not be used for a component, use onCreate instead.",
62
+ loc: constructorProp.key.loc,
63
+ });
64
+
65
+ parsed.body.body.splice(constructorProp, 1);
66
+ }
67
+
68
+ if (parsed.id) {
69
+ diagnosticDeprecate(path, {
70
+ label: "Component class should not have a name.",
71
+ loc: parsed.id.loc,
72
+ fix() {
73
+ parsed.id = null;
74
+ },
75
+ });
76
+ }
77
+
78
+ path.replaceWith(t.markoClass(parsed.body));
79
+ }
@@ -0,0 +1,14 @@
1
+ import { parseStatements } from "@marko/compiler/babel-utils";
2
+
3
+ export default function (path) {
4
+ const {
5
+ node,
6
+ hub: { file },
7
+ } = path;
8
+ const {
9
+ rawValue,
10
+ name: { start, end },
11
+ } = node;
12
+ const [exportNode] = parseStatements(file, rawValue, start, end);
13
+ path.replaceWith(exportNode);
14
+ }
@@ -0,0 +1,14 @@
1
+ import { parseStatements } from "@marko/compiler/babel-utils";
2
+
3
+ export default function (path) {
4
+ const {
5
+ node,
6
+ hub: { file },
7
+ } = path;
8
+ const {
9
+ rawValue,
10
+ name: { start, end },
11
+ } = node;
12
+ const [importNode] = parseStatements(file, rawValue, start, end);
13
+ path.replaceWith(importNode);
14
+ }
@@ -0,0 +1,18 @@
1
+ import markoModules from "@marko/compiler/modules";
2
+ import path from "path";
3
+ import resolveFrom from "resolve-from";
4
+
5
+ const startOffset = "module-code".length;
6
+
7
+ export default function (tag) {
8
+ const {
9
+ hub: { file },
10
+ node: { rawValue },
11
+ } = tag;
12
+ const dirname = path.dirname(file.opts.filename);
13
+ const relativeRequire = (entry) =>
14
+ markoModules.require(resolveFrom(dirname, entry));
15
+ const fn = eval(rawValue.slice(startOffset));
16
+ const source = fn(relativeRequire, file.markoOpts);
17
+ file.metadata.marko.moduleCode = source;
18
+ }
@@ -0,0 +1,18 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { parseStatements } from "@marko/compiler/babel-utils";
3
+
4
+ export default function (path) {
5
+ const {
6
+ node,
7
+ hub: { file },
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^static\s*/, "").trim();
11
+ const start = node.name.start + (rawValue.length - code.length);
12
+ let body = parseStatements(file, code, start, end);
13
+ if (body.length === 1 && t.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(t.MarkoScriptlet(body, true));
18
+ }