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,17 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+
3
+ var _htmlOutWrite = _interopRequireDefault(require("../util/html-out-write"));
4
+ var _withPreviousLocation = _interopRequireDefault(require("../util/with-previous-location"));
5
+ const ieConditionalCommentRegExp = /^\[if |<!\[endif\]$/;
6
+
7
+ function _default(path) {
8
+ const { node } = path;
9
+
10
+ if (ieConditionalCommentRegExp.test(node.value)) {
11
+ path.replaceWith(
12
+ (0, _withPreviousLocation.default)((0, _htmlOutWrite.default)`<!--${_compiler.types.stringLiteral(node.value)}-->`, node)
13
+ );
14
+ } else {
15
+ path.remove();
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;function _default(path) {
2
+ path.remove();
3
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _indexHtml = _interopRequireDefault(require("./index[html]"));
2
+ var _indexVdom = _interopRequireDefault(require("./index[vdom]"));
3
+
4
+ function _default(path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts }
8
+ }
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ (0, _indexHtml.default)(path);
12
+ } else {
13
+ (0, _indexVdom.default)(path);
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+
3
+ var _htmlOutWrite = _interopRequireDefault(require("../util/html-out-write"));
4
+ var _withPreviousLocation = _interopRequireDefault(require("../util/with-previous-location"));
5
+
6
+ function _default(path) {
7
+ const { node } = path;
8
+
9
+ path.replaceWith(
10
+ (0, _withPreviousLocation.default)((0, _htmlOutWrite.default)`<?${_compiler.types.stringLiteral(node.value)}?>`, node)
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;function _default(path) {
2
+ path.remove();
3
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _indexHtml = _interopRequireDefault(require("./index[html]"));
2
+ var _indexVdom = _interopRequireDefault(require("./index[vdom]"));
3
+
4
+ function _default(path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts }
8
+ }
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ (0, _indexHtml.default)(path);
12
+ } else {
13
+ (0, _indexVdom.default)(path);
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+
3
+ var _htmlOutWrite = _interopRequireDefault(require("../util/html-out-write"));
4
+ var _withPreviousLocation = _interopRequireDefault(require("../util/with-previous-location"));
5
+
6
+ function _default(path) {
7
+ const { node } = path;
8
+
9
+ path.replaceWith(
10
+ (0, _withPreviousLocation.default)((0, _htmlOutWrite.default)`<!${_compiler.types.stringLiteral(node.value)}>`, node)
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;function _default(path) {
2
+ path.remove();
3
+ }
@@ -0,0 +1,551 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.analyze = void 0;exports.getRuntimeEntryFiles = getRuntimeEntryFiles;exports.translate = exports.taglibs = exports.optionalTaglibs = exports.internalEntryBuilder = void 0;var _compiler = require("@marko/compiler");
2
+ var _babelUtils = require("@marko/compiler/babel-utils");
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _package = require("marko/package.json");
18
+ var _path = require("path");
19
+
20
+ var _cdata = _interopRequireDefault(require("./cdata"));
21
+ var _class = _interopRequireDefault(require("./class"));
22
+ var _comment = _interopRequireDefault(require("./comment"));
23
+ var _declaration = _interopRequireDefault(require("./declaration"));
24
+ var _documentType = _interopRequireDefault(require("./document-type"));
25
+ var _placeholder = _interopRequireDefault(require("./placeholder"));
26
+ var _scriptlet = _interopRequireDefault(require("./scriptlet"));
27
+ var _tag = _interopRequireDefault(require("./tag"));
28
+ var _text = _interopRequireDefault(require("./text"));
29
+ var _addDependencies = _interopRequireWildcard(require("./util/add-dependencies"));exports.internalEntryBuilder = _addDependencies.entryBuilder;
30
+ var _getComponentFiles = _interopRequireDefault(require("./util/get-component-files"));
31
+ var _optimizeHtmlWrites = require("./util/optimize-html-writes");
32
+ var _optimizeVdomCreate = require("./util/optimize-vdom-create");
33
+
34
+ var _taglib = _interopRequireWildcard(require("./taglib"));exports.optionalTaglibs = _taglib.optionalTaglibs;exports.taglibs = _taglib.default;function _getRequireWildcardCache(e) {if ("function" != typeof WeakMap) return null;var r = new WeakMap(),t = new WeakMap();return (_getRequireWildcardCache = function (e) {return e ? t : r;})(e);}function _interopRequireWildcard(e, r) {if (!r && e && e.__esModule) return e;if (null === e || "object" != typeof e && "function" != typeof e) return { default: e };var t = _getRequireWildcardCache(r);if (t && t.has(e)) return t.get(e);var n = { __proto__: null },a = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];}return n.default = e, t && t.set(e, n), n;}
35
+
36
+
37
+ const analyze = exports.analyze = {
38
+ Program: {
39
+ enter(program) {
40
+ // Pre populate metadata for component files.
41
+ const meta = program.hub.file.metadata.marko;
42
+ (0, _getComponentFiles.default)(program);
43
+
44
+ if (!meta.hasComponent && !meta.hasComponentBrowser) {
45
+ meta.hasComponent = program.
46
+ get("body").
47
+ some((child) => child.isMarkoClass());
48
+ }
49
+ },
50
+ exit(program) {
51
+ const { file } = program.hub;
52
+ const meta = file.metadata.marko;
53
+ const componentFiles = (0, _getComponentFiles.default)(program);
54
+ const { styleFile, packageFile, componentBrowserFile } = componentFiles;
55
+
56
+ if (packageFile) {
57
+ meta.deps.unshift(`package: ${packageFile}`);
58
+ }
59
+
60
+ if (styleFile) {
61
+ meta.deps.unshift(styleFile);
62
+ }
63
+
64
+ if (!meta.widgetBind) {
65
+ if (meta.hasComponentBrowser) {
66
+ meta.component = componentBrowserFile;
67
+ } else if (
68
+ meta.hasComponent ||
69
+ meta.hasStatefulTagParams ||
70
+ meta.hasFunctionEventHandlers)
71
+ {
72
+ meta.component = file.opts.filename;
73
+ } else if (meta.hasStringEventHandlers) {
74
+ meta.component = componentFiles.componentBrowserFile =
75
+ "marko/src/runtime/helpers/empty-component.js";
76
+ meta.hasComponentBrowser = true;
77
+ }
78
+ }
79
+
80
+ meta.component =
81
+ meta.component && (0, _babelUtils.resolveRelativePath)(file, meta.component);
82
+ meta.deps = meta.deps.map((filename) =>
83
+ typeof filename === "string" ?
84
+ (0, _babelUtils.resolveRelativePath)(file, filename) :
85
+ filename
86
+ );
87
+ }
88
+ },
89
+ MarkoTag(tag) {
90
+ const { file } = tag.hub;
91
+ const tagDef = (0, _babelUtils.getTagDef)(tag);
92
+ // Check if tag uses stateful tag params.
93
+ const meta = tag.hub.file.metadata.marko;
94
+
95
+ if (tagDef) {
96
+ if (tagDef.html && !tagDef.template && !tagDef.renderer) {
97
+ if (tagDef.htmlType === "custom-element") {
98
+ if (tagDef.parseOptions && tagDef.parseOptions.import) {
99
+ // TODO: the taglib should be updated to support this as a top level option.
100
+ meta.deps.push(
101
+ (0, _path.resolve)(
102
+ tagDef.dir,
103
+ (0, _path.resolve)(tagDef.dir, tagDef.parseOptions.import)
104
+ )
105
+ );
106
+ }
107
+ }
108
+ } else if (tag.get("name").isStringLiteral()) {
109
+ const relativePath = resolveRelativeTagEntry(file, tagDef);
110
+
111
+ if (relativePath) {
112
+ tag.node.extra = tag.node.extra || {};
113
+ tag.node.extra.relativePath = relativePath;
114
+
115
+ if (!meta.tags.includes(relativePath)) {
116
+ meta.tags.push(relativePath);
117
+ }
118
+ }
119
+ }
120
+
121
+ if (tagDef.translator && tagDef.translator.path) {
122
+ if (!meta.watchFiles.includes(tagDef.translator.path)) {
123
+ meta.watchFiles.push(tagDef.translator.path);
124
+ }
125
+ }
126
+ }
127
+
128
+ if (!(meta.hasFunctionEventHandlers || meta.hasStringEventHandlers)) {
129
+ for (const attr of tag.node.attributes) {
130
+ if (
131
+ _compiler.types.isMarkoAttribute(attr) &&
132
+ attr.arguments &&
133
+ /^on[-A-Z]/.test(attr.name))
134
+ {
135
+ if (
136
+ attr.arguments.length >= 1 &&
137
+ attr.arguments[0].type === "StringLiteral")
138
+ {
139
+ meta.hasStringEventHandlers = true;
140
+ } else {
141
+ meta.hasFunctionEventHandlers = true;
142
+ }
143
+ break;
144
+ }
145
+ }
146
+ }
147
+
148
+ if (
149
+ meta.hasStatefulTagParams ||
150
+ (0, _babelUtils.isNativeTag)(tag) ||
151
+ (0, _babelUtils.isMacroTag)(tag) ||
152
+ !tag.get("body").get("params").length)
153
+ {
154
+ return;
155
+ }
156
+
157
+ if ((0, _babelUtils.isDynamicTag)(tag)) {
158
+ meta.hasStatefulTagParams = true;
159
+ return;
160
+ }
161
+
162
+ let curTag = tag;
163
+ while ((0, _babelUtils.isAttributeTag)(curTag)) {
164
+ curTag = (0, _babelUtils.findParentTag)(curTag);
165
+ }
166
+
167
+ const tagFile = (0, _babelUtils.loadFileForTag)(curTag);
168
+ const childMeta = tagFile && tagFile.metadata.marko;
169
+ meta.hasStatefulTagParams =
170
+ childMeta && (
171
+ childMeta.hasStatefulTagParams ||
172
+ childMeta.hasFunctionEventHandlers ||
173
+ childMeta.hasComponent && !childMeta.hasComponentBrowser);
174
+ },
175
+ ImportDeclaration: {
176
+ exit(path) {
177
+ const source = path.get("source");
178
+ const tagEntry = (0, _babelUtils.resolveTagImport)(source, source.node.value);
179
+
180
+ if (tagEntry) {
181
+ const meta = path.hub.file.metadata.marko;
182
+ source.node.value = tagEntry;
183
+
184
+ if (!meta.tags.includes(tagEntry)) {
185
+ meta.tags.push(tagEntry);
186
+ }
187
+ }
188
+ }
189
+ }
190
+ };
191
+
192
+ const translate = exports.translate = {
193
+ MarkoDocumentType: _documentType.default,
194
+ MarkoDeclaration: _declaration.default,
195
+ MarkoCDATA: _cdata.default,
196
+ MarkoTag: _tag.default,
197
+ MarkoText: _text.default,
198
+ MarkoPlaceholder: _placeholder.default,
199
+ MarkoScriptlet: _scriptlet.default,
200
+ MarkoClass: _class.default,
201
+ MarkoComment: _comment.default,
202
+ ReferencedIdentifier(path) {
203
+ if (path.node.name === "component" && !path.scope.hasBinding("component")) {
204
+ path.replaceWith(path.hub.file._componentInstanceIdentifier);
205
+ }
206
+ },
207
+ Program: {
208
+ enter(path) {
209
+ const {
210
+ hub: { file }
211
+ } = path;
212
+
213
+ if (file.markoOpts.output === "hydrate") {
214
+ (0, _addDependencies.default)(file, true);
215
+ return;
216
+ } else if (
217
+ file.markoOpts.resolveVirtualDependency &&
218
+ file.markoOpts.output !== "html")
219
+ {
220
+ (0, _addDependencies.default)(file, false);
221
+ }
222
+
223
+ if (file.metadata.marko.moduleCode) {
224
+ path.
225
+ replaceWith(
226
+ _compiler.types.program(
227
+ (0, _babelUtils.parseStatements)(file, file.metadata.marko.moduleCode),
228
+ undefined,
229
+ file.markoOpts.modules === "cjs" ? "script" : "module"
230
+ )
231
+ )[0].
232
+ skip();
233
+ return;
234
+ }
235
+
236
+ file._componentDefIdentifier =
237
+ path.scope.generateUidIdentifier("componentDef");
238
+
239
+ file._componentInstanceIdentifier =
240
+ path.scope.generateUidIdentifier("component");
241
+
242
+ // Pre-Analyze tree
243
+ (0, _optimizeVdomCreate.analyzeStaticVDOM)(path);
244
+
245
+ // Move non static content into the renderBody.
246
+ const [renderBlock] = path.pushContainer("body", _compiler.types.blockStatement([]));
247
+ path.
248
+ get("body").
249
+ filter(isRenderContent).
250
+ forEach((childPath) => {
251
+ renderBlock.pushContainer("body", childPath.node);
252
+ childPath.remove();
253
+ });
254
+
255
+ file._renderBlock = renderBlock;
256
+ path.scope.crawl();
257
+ },
258
+ exit(path) {
259
+ const {
260
+ hub: { file }
261
+ } = path;
262
+ const { markoOpts, _inlineComponentClass } = file;
263
+ const includeMetaInSource = markoOpts.meta !== false;
264
+ const meta = file.metadata.marko;
265
+ const { componentFile, componentBrowserFile } = (0, _getComponentFiles.default)(path);
266
+ const isHTML = markoOpts.output === "html";
267
+
268
+ const renderBlock = file._renderBlock;
269
+ const componentClass =
270
+ componentFile &&
271
+ (0, _babelUtils.importDefault)(
272
+ file,
273
+ (0, _babelUtils.resolveRelativePath)(file, componentFile),
274
+ "marko_component"
275
+ ) ||
276
+ _inlineComponentClass ||
277
+ _compiler.types.objectExpression([]);
278
+
279
+ const componentIdentifier =
280
+ path.scope.generateUidIdentifier("marko_component");
281
+ const componentTypeIdentifier = path.scope.generateUidIdentifier(
282
+ "marko_componentType"
283
+ );
284
+ const templateIdentifier =
285
+ path.scope.generateUidIdentifier("marko_template");
286
+ const rendererIdentifier = (0, _babelUtils.importDefault)(
287
+ file,
288
+ "marko/src/runtime/components/renderer.js",
289
+ "marko_renderer"
290
+ );
291
+ const templateRendererMember = _compiler.types.memberExpression(
292
+ templateIdentifier,
293
+ _compiler.types.identifier("_")
294
+ );
295
+ const templateMetaMember = _compiler.types.memberExpression(
296
+ templateIdentifier,
297
+ _compiler.types.identifier("meta")
298
+ );
299
+
300
+ if (markoOpts.writeVersionComment) {
301
+ path.addComment(
302
+ "leading",
303
+ ` Compiled using marko@${_package.version} - DO NOT EDIT`,
304
+ true
305
+ );
306
+ }
307
+
308
+ const runtimeTemplateIdentifier = path.scope.generateUidIdentifier("t");
309
+
310
+ path.unshiftContainer(
311
+ "body",
312
+ [
313
+ _compiler.types.importDeclaration(
314
+ [_compiler.types.importSpecifier(runtimeTemplateIdentifier, _compiler.types.identifier("t"))],
315
+ _compiler.types.stringLiteral(
316
+ `marko/${markoOpts.optimize ? "dist" : "src"}/runtime/${
317
+ isHTML ? "html" : "vdom"}/${
318
+ markoOpts.hot ? "hot-reload.js" : "index.js"}`
319
+ )
320
+ ),
321
+ _compiler.types.variableDeclaration("const", [
322
+ _compiler.types.variableDeclarator(
323
+ componentTypeIdentifier,
324
+ _compiler.types.stringLiteral(meta.id)
325
+ ),
326
+ _compiler.types.variableDeclarator(
327
+ templateIdentifier,
328
+ _compiler.types.callExpression(runtimeTemplateIdentifier, [
329
+ componentTypeIdentifier]
330
+ )
331
+ )]
332
+ ),
333
+ includeMetaInSource &&
334
+ _compiler.types.expressionStatement(
335
+ _compiler.types.assignmentExpression(
336
+ "=",
337
+ _compiler.types.memberExpression(templateIdentifier, _compiler.types.identifier("path")),
338
+ _compiler.types.identifier("__filename")
339
+ )
340
+ ),
341
+ _compiler.types.exportDefaultDeclaration(templateIdentifier)].
342
+ filter(Boolean)
343
+ );
344
+
345
+ path.pushContainer(
346
+ "body",
347
+ [
348
+ !isHTML &&
349
+ _compiler.types.expressionStatement(
350
+ _compiler.types.callExpression(
351
+ (0, _babelUtils.importNamed)(
352
+ file,
353
+ "marko/src/runtime/components/registry.js",
354
+ "r",
355
+ "marko_registerComponent"
356
+ ),
357
+ [
358
+ componentTypeIdentifier,
359
+ _compiler.types.arrowFunctionExpression(
360
+ [],
361
+ componentBrowserFile ?
362
+ (0, _babelUtils.importDefault)(
363
+ file,
364
+ (0, _babelUtils.resolveRelativePath)(file, componentBrowserFile),
365
+ "marko_split_component"
366
+ ) :
367
+ templateIdentifier
368
+ )]
369
+
370
+ )
371
+ ),
372
+ _compiler.types.variableDeclaration("const", [
373
+ _compiler.types.variableDeclarator(componentIdentifier, componentClass)]
374
+ )].
375
+ filter(Boolean)
376
+ );
377
+
378
+ const templateRenderOptionsProps = [
379
+ _compiler.types.objectProperty(_compiler.types.identifier("t"), componentTypeIdentifier)];
380
+
381
+
382
+ if (!meta.component) {
383
+ templateRenderOptionsProps.push(
384
+ _compiler.types.objectProperty(_compiler.types.identifier("i"), _compiler.types.booleanLiteral(true))
385
+ );
386
+ }
387
+
388
+ if (componentBrowserFile) {
389
+ templateRenderOptionsProps.push(
390
+ _compiler.types.objectProperty(_compiler.types.identifier("s"), _compiler.types.booleanLiteral(true))
391
+ );
392
+ }
393
+
394
+ if (!markoOpts.optimize) {
395
+ templateRenderOptionsProps.push(
396
+ _compiler.types.objectProperty(_compiler.types.identifier("d"), _compiler.types.booleanLiteral(true))
397
+ );
398
+ }
399
+
400
+ path.pushContainer(
401
+ "body",
402
+ _compiler.types.expressionStatement(
403
+ _compiler.types.assignmentExpression(
404
+ "=",
405
+ templateRendererMember,
406
+ _compiler.types.callExpression(rendererIdentifier, [
407
+ _compiler.types.functionExpression(
408
+ null,
409
+ [
410
+ _compiler.types.identifier("input"),
411
+ _compiler.types.identifier("out"),
412
+ file._componentDefIdentifier,
413
+ file._componentInstanceIdentifier,
414
+ _compiler.types.identifier("state"),
415
+ _compiler.types.identifier("$global")],
416
+
417
+ renderBlock.node
418
+ ),
419
+ _compiler.types.objectExpression(templateRenderOptionsProps),
420
+ componentIdentifier]
421
+ )
422
+ )
423
+ )
424
+ );
425
+ renderBlock.remove();
426
+
427
+ if (!isHTML) {
428
+ path.pushContainer(
429
+ "body",
430
+ _compiler.types.expressionStatement(
431
+ _compiler.types.assignmentExpression(
432
+ "=",
433
+ _compiler.types.memberExpression(templateIdentifier, _compiler.types.identifier("Component")),
434
+ _compiler.types.callExpression(
435
+ (0, _babelUtils.importDefault)(
436
+ file,
437
+ "marko/src/runtime/components/defineComponent.js",
438
+ "marko_defineComponent"
439
+ ),
440
+ [componentIdentifier, templateRendererMember]
441
+ )
442
+ )
443
+ )
444
+ );
445
+ }
446
+
447
+ if (includeMetaInSource) {
448
+ const metaObject = _compiler.types.objectExpression([
449
+ _compiler.types.objectProperty(_compiler.types.identifier("id"), componentTypeIdentifier)]
450
+ );
451
+
452
+ if (meta.component) {
453
+ metaObject.properties.push(
454
+ _compiler.types.objectProperty(
455
+ _compiler.types.identifier("component"),
456
+ _compiler.types.stringLiteral(meta.component)
457
+ )
458
+ );
459
+ }
460
+
461
+ if (meta.deps.length) {
462
+ metaObject.properties.push(
463
+ _compiler.types.objectProperty(
464
+ _compiler.types.identifier("deps"),
465
+ (0, _babelUtils.parseExpression)(file, JSON.stringify(meta.deps))
466
+ )
467
+ );
468
+ }
469
+
470
+ if (meta.tags.length) {
471
+ metaObject.properties.push(
472
+ _compiler.types.objectProperty(
473
+ _compiler.types.identifier("tags"),
474
+ _compiler.types.arrayExpression(meta.tags.map((tag) => _compiler.types.stringLiteral(tag)))
475
+ )
476
+ );
477
+ }
478
+
479
+ path.pushContainer(
480
+ "body",
481
+ _compiler.types.expressionStatement(
482
+ _compiler.types.assignmentExpression("=", templateMetaMember, metaObject)
483
+ )
484
+ );
485
+ }
486
+
487
+ (0, _optimizeHtmlWrites.optimizeHTMLWrites)(path);
488
+ }
489
+ }
490
+ };
491
+
492
+ function getRuntimeEntryFiles(output, optimize) {
493
+ const base = `marko/${optimize ? "dist" : "src"}/`;
494
+
495
+ return [
496
+ `${base}runtime/components/index.js`,
497
+ `${base}runtime/components/defineComponent.js`,
498
+ `${base}runtime/components/renderer.js`,
499
+ `${base}runtime/components/registry.js`,
500
+ `${base}runtime/components/attach-detach.js`,
501
+ `${base}runtime/helpers/assign.js`,
502
+ `${base}runtime/helpers/class-value.js`,
503
+ `${base}runtime/helpers/of-fallback.js`,
504
+ `${base}runtime/helpers/dynamic-tag.js`,
505
+ `${base}runtime/helpers/attr-tag.js`,
506
+ `${base}runtime/helpers/merge.js`,
507
+ `${base}runtime/helpers/render-tag.js`,
508
+ `${base}runtime/helpers/style-value.js`,
509
+ `${base}runtime/helpers/to-string.js`,
510
+ `${base}runtime/helpers/empty-component.js`,
511
+ `${base}core-tags/components/preserve-tag.js`,
512
+ ...(output === "html" ?
513
+ [
514
+ `${base}runtime/html/index.js`,
515
+ `${base}runtime/html/hot-reload.js`,
516
+ `${base}runtime/html/helpers/attr.js`,
517
+ `${base}runtime/html/helpers/attrs.js`,
518
+ `${base}runtime/html/helpers/class-attr.js`,
519
+ `${base}runtime/html/helpers/data-marko.js`,
520
+ `${base}runtime/html/helpers/escape-quotes.js`,
521
+ `${base}runtime/html/helpers/escape-script-placeholder.js`,
522
+ `${base}runtime/html/helpers/escape-style-placeholder.js`,
523
+ `${base}runtime/html/helpers/escape-xml.js`,
524
+ `${base}runtime/html/helpers/merge-attrs.js`,
525
+ `${base}runtime/html/helpers/props-script.js`,
526
+ `${base}runtime/html/helpers/style-attr.js`,
527
+ `${base}core-tags/components/init-components-tag.js`,
528
+ `${base}core-tags/components/preferred-script-location-tag.js`,
529
+ `${base}core-tags/core/__flush_here_and_after__.js`,
530
+ `${base}core-tags/core/await/renderer.js`,
531
+ `${base}core-tags/core/await/reorderer-renderer.js`] :
532
+
533
+ [
534
+ `${base}runtime/vdom/index.js`,
535
+ `${base}runtime/vdom/hot-reload.js`,
536
+ `${base}runtime/vdom/helpers/attrs.js`,
537
+ `${base}runtime/vdom/helpers/const-element.js`])];
538
+
539
+
540
+ }
541
+
542
+ function isRenderContent(path) {
543
+ const { node } = path;
544
+ return _compiler.types.MARKO_TYPES.includes(node.type) && !node.static;
545
+ }
546
+
547
+ function resolveRelativeTagEntry(file, tagDef) {
548
+ // TODO: support transform and other entries.
549
+ const entry = tagDef.template || tagDef.renderer;
550
+ return entry && (0, _babelUtils.resolveRelativePath)(file, entry);
551
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _indexHtml = _interopRequireDefault(require("./index[html]"));
2
+ var _indexVdom = _interopRequireDefault(require("./index[vdom]"));
3
+
4
+ function _default(path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts }
8
+ }
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ (0, _indexHtml.default)(path);
12
+ } else {
13
+ (0, _indexVdom.default)(path);
14
+ }
15
+ }