marko 5.36.4 → 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,164 @@
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.analyzeStaticVDOM = analyzeStaticVDOM;exports.optimizeStaticVDOM = optimizeStaticVDOM;var _compiler = require("@marko/compiler");
2
+ var _babelUtils = require("@marko/compiler/babel-utils");
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _he = require("he");
10
+
11
+ var _attributes = _interopRequireDefault(require("../tag/native-tag[vdom]/attributes"));
12
+ var _keyManager = require("./key-manager");
13
+ var _vdomOutWrite = _interopRequireDefault(require("./vdom-out-write"));
14
+
15
+ const skipDirectives = new Set([
16
+ "key",
17
+ "w-bind",
18
+ "no-update",
19
+ "no-update-if",
20
+ "no-update-body",
21
+ "no-update-body-if"]
22
+ );
23
+ const staticNodes = new WeakSet();
24
+
25
+ const mergeStaticCreateVisitor = {
26
+ MarkoText(path, state) {
27
+ const { node } = path;
28
+ state.currentRoot = _compiler.types.callExpression(
29
+ _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("t")),
30
+ [_compiler.types.stringLiteral((0, _he.decode)(node.value))]
31
+ );
32
+ },
33
+ MarkoPlaceholder(path, state) {
34
+ const computed = (0, _babelUtils.computeNode)(path.node.value);
35
+ state.currentRoot = _compiler.types.callExpression(
36
+ _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("t")),
37
+ [
38
+ _compiler.types.stringLiteral(
39
+ computed && computed.value != null ? `${computed.value}` : ""
40
+ )]
41
+
42
+ );
43
+ },
44
+ MarkoTag(path, state) {
45
+ (0, _keyManager.getKeyManager)(path).resolveKey(path);
46
+ state.currentRoot = _compiler.types.callExpression(
47
+ _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("e")),
48
+ getConstElementArgs(path)
49
+ );
50
+ }
51
+ };
52
+
53
+ const analyzeStaticVisitor = {
54
+ MarkoText(path) {
55
+ staticNodes.add(path.node);
56
+ },
57
+ MarkoPlaceholder(path) {
58
+ if (path.node.escape) {
59
+ const computed = (0, _babelUtils.computeNode)(path.node.value);
60
+ if (computed) {
61
+ staticNodes.add(path.node);
62
+ }
63
+ }
64
+ },
65
+ MarkoTag: {
66
+ enter(path) {
67
+ // needed to handle global keys on elements that don't have specific key attributes
68
+ if ((0, _babelUtils.isLoopTag)(path)) path.skip();
69
+ },
70
+ exit(path) {
71
+ // check name
72
+ let isStatic =
73
+ (0, _babelUtils.isNativeTag)(path) &&
74
+ !path.node.attributeTags.length &&
75
+ !path.node.body.attributeTags &&
76
+ !path.node.body.params.length &&
77
+ !path.node.arguments &&
78
+ !(0, _keyManager.hasUserKey)(path);
79
+
80
+ const tagDef = (0, _babelUtils.getTagDef)(path);
81
+ isStatic = isStatic && !tagDef.translator;
82
+
83
+ // check attributes
84
+ isStatic =
85
+ isStatic &&
86
+ path.
87
+ get("attributes").
88
+ every(
89
+ (attr) =>
90
+ _compiler.types.isMarkoAttribute(attr) &&
91
+ !(
92
+ attr.node.arguments ||
93
+ attr.node.modifier ||
94
+ skipDirectives.has(attr.node.name) ||
95
+ !(0, _babelUtils.computeNode)(attr.node.value))
96
+
97
+ );
98
+
99
+ // check children
100
+ isStatic =
101
+ isStatic &&
102
+ path.
103
+ get("body").
104
+ get("body").
105
+ every((t) => staticNodes.has(t.node));
106
+
107
+ if (isStatic) staticNodes.add(path.node);
108
+ }
109
+ }
110
+ };
111
+
112
+ function optimizeStaticVDOM(path) {
113
+ const {
114
+ hub: { file }
115
+ } = path;
116
+
117
+ if (
118
+ !shouldRun(file.markoOpts) ||
119
+ !staticNodes.has(path.node) ||
120
+ staticNodes.has(path.parentPath.parentPath.node))
121
+ {
122
+ return;
123
+ }
124
+
125
+ const identifier = path.scope.generateUidIdentifier("marko_node");
126
+ const state = {
127
+ currentRoot: _compiler.types.callExpression(
128
+ (0, _babelUtils.importDefault)(
129
+ file,
130
+ "marko/src/runtime/vdom/helpers/const-element.js",
131
+ "marko_constElement"
132
+ ),
133
+ getConstElementArgs(path)
134
+ )
135
+ };
136
+
137
+ path.traverse(mergeStaticCreateVisitor, state);
138
+
139
+ const d = _compiler.types.variableDeclaration("const", [
140
+ _compiler.types.variableDeclarator(identifier, state.currentRoot)]
141
+ );
142
+ file.path.node.body.push(d);
143
+ path.replaceWith((0, _vdomOutWrite.default)("n", identifier, file._componentInstanceIdentifier));
144
+ path.skip();
145
+ }
146
+
147
+ function analyzeStaticVDOM(path) {
148
+ if (shouldRun(path.hub.file.markoOpts)) {
149
+ path.traverse(analyzeStaticVisitor);
150
+ }
151
+ }
152
+
153
+ function shouldRun(markoOpts) {
154
+ return markoOpts.optimize && markoOpts.output !== "html";
155
+ }
156
+
157
+ function getConstElementArgs(path) {
158
+ const { node } = path;
159
+ return [
160
+ node.name,
161
+ (0, _attributes.default)(path, path.get("attributes")),
162
+ _compiler.types.numericLiteral(node.body.body.length)];
163
+
164
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";exports.__esModule = true;exports.enter = enter;exports.exit = exit; // Utilities for executing multi step compiler hooks (code generators in this package).
2
+
3
+ function enter(plugin, ...args) {
4
+ const fn =
5
+ plugin && (
6
+ plugin.enter ||
7
+ plugin.default && plugin.default.enter ||
8
+ plugin.default) ||
9
+ plugin;
10
+ if (typeof fn === "function") {
11
+ fn(...args);
12
+ }
13
+ }
14
+
15
+ function exit(plugin, ...args) {
16
+ const fn =
17
+ plugin && (
18
+ plugin.exit || (plugin.default ? plugin.default.exit : undefined));
19
+ if (typeof fn === "function") {
20
+ fn(...args);
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";exports.__esModule = true;exports.SPREAD_ATTRS = exports.IS_CUSTOM_ELEMENT = exports.HAS_SIMPLE_ATTRS = void 0;const HAS_SIMPLE_ATTRS = exports.HAS_SIMPLE_ATTRS = 1;
2
+ const IS_CUSTOM_ELEMENT = exports.IS_CUSTOM_ELEMENT = 2; // TODO: impl custom elements.
3
+ const SPREAD_ATTRS = exports.SPREAD_ATTRS = 4; // TODO: impl custom elements.
@@ -0,0 +1,10 @@
1
+ "use strict";exports.__esModule = true;exports.default = write;var _compiler = require("@marko/compiler");
2
+
3
+ function write(method, ...args) {
4
+ return _compiler.types.expressionStatement(
5
+ _compiler.types.callExpression(
6
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier(method)),
7
+ args
8
+ )
9
+ );
10
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";exports.__esModule = true;exports.default = withPreviousLocation;function withPreviousLocation(newNode, originalNode) {
2
+ newNode.start = originalNode.start;
3
+ newNode.loc = originalNode.loc;
4
+ newNode.end = originalNode.end;
5
+ return newNode;
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.36.4",
3
+ "version": "5.37.0",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -60,14 +60,16 @@
60
60
  "index-browser.marko",
61
61
  "index.js",
62
62
  "node-require.js",
63
- "tags-html.d.ts"
63
+ "tags-html.d.ts",
64
+ "translator/package.json",
65
+ "translator/index.d.ts"
64
66
  ],
65
67
  "scripts": {
66
68
  "build": "babel ./src --out-dir ./dist --extensions .js --copy-files --config-file ../../babel.config.js --env-name=production"
67
69
  },
68
70
  "dependencies": {
69
- "@marko/compiler": "^5.38.3",
70
- "@marko/translator-default": "^6.1.2",
71
+ "@babel/runtime": "^7.26.0",
72
+ "@marko/compiler": "^5.39.0",
71
73
  "app-module-path": "^2.2.0",
72
74
  "argly": "^1.2.0",
73
75
  "browser-refresh-client": "1.1.4",
@@ -75,6 +77,7 @@
75
77
  "csstype": "^3.1.3",
76
78
  "events-light": "^1.0.5",
77
79
  "listener-tracker": "^2.0.0",
80
+ "magic-string": "^0.30.15",
78
81
  "minimatch": "^9.0.5",
79
82
  "raptor-util": "^3.2.0",
80
83
  "resolve-from": "^5.0.0",
@@ -30,11 +30,11 @@ exports.finder = compiler.taglib._finder;
30
30
  exports.lookup = {
31
31
  buildLookup: function (dir, translator) {
32
32
  if (!translator || !Array.isArray(translator.taglibs)) {
33
- translator = require("@marko/translator-default");
33
+ translator = require("../translator");
34
34
  // eslint-disable-next-line no-constant-condition
35
35
  if ("MARKO_DEBUG") {
36
36
  complain(
37
- "buildTaglibLookup now requires passing in a transltor as the second argument, eg `buildTaglibLookup(dir, require('@marko/translator-default'))`.",
37
+ "buildTaglibLookup now requires passing in a transltor as the second argument, eg `buildTaglibLookup(dir, require('marko/translator'))`.",
38
38
  );
39
39
  }
40
40
  }
@@ -0,0 +1,15 @@
1
+ import translateHTML from "./index[html]";
2
+ import translateVDOM from "./index[vdom]";
3
+
4
+ export default function (path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts },
8
+ },
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ translateHTML(path);
12
+ } else {
13
+ translateVDOM(path);
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import { types as t } from "@marko/compiler";
2
+
3
+ import write from "../util/html-out-write";
4
+ import withPreviousLocation from "../util/with-previous-location";
5
+
6
+ export default function (path) {
7
+ const { node } = path;
8
+
9
+ path.replaceWith(
10
+ withPreviousLocation(
11
+ write`<![CDATA[${t.stringLiteral(node.value)}]]>`,
12
+ node,
13
+ ),
14
+ );
15
+ }
@@ -0,0 +1,12 @@
1
+ import { types as t } from "@marko/compiler";
2
+
3
+ import write from "../util/vdom-out-write";
4
+ import withPreviousLocation from "../util/with-previous-location";
5
+
6
+ export default function (path) {
7
+ const { node } = path;
8
+
9
+ path.replaceWith(
10
+ withPreviousLocation(write("t", t.stringLiteral(node.value)), node),
11
+ );
12
+ }
@@ -0,0 +1,65 @@
1
+ import { types as t } from "@marko/compiler";
2
+
3
+ export default function (path) {
4
+ const {
5
+ hub: { file },
6
+ node: {
7
+ body: { body },
8
+ },
9
+ } = path;
10
+
11
+ const classProperties = [];
12
+ let onCreateMethod = body.find(
13
+ (prop) =>
14
+ prop.computed === false &&
15
+ t.isIdentifier(prop.key) &&
16
+ prop.key.name === "onCreate",
17
+ );
18
+
19
+ const objectProperties = body
20
+ .map((prop) => {
21
+ if (t.isClassMethod(prop)) {
22
+ prop.type = "ObjectMethod";
23
+ delete prop.start;
24
+ delete prop.end;
25
+ delete prop.loc;
26
+ return prop;
27
+ } else if (t.isClassProperty(prop) && !prop.static) {
28
+ if (!prop.declare) {
29
+ classProperties.push(
30
+ t.assignmentExpression(
31
+ "=",
32
+ t.memberExpression(t.thisExpression(), prop.key, prop.computed),
33
+ prop.value || t.unaryExpression("void", t.numericLiteral(0)),
34
+ ),
35
+ );
36
+ }
37
+
38
+ return undefined;
39
+ }
40
+
41
+ throw file.buildCodeFrameError(
42
+ prop,
43
+ "Unsupported class property on component.",
44
+ );
45
+ })
46
+ .filter(Boolean);
47
+
48
+ if (classProperties.length) {
49
+ if (!onCreateMethod) {
50
+ objectProperties.push(
51
+ (onCreateMethod = t.objectMethod(
52
+ "method",
53
+ t.identifier("onCreate"),
54
+ [],
55
+ t.blockStatement([]),
56
+ )),
57
+ );
58
+ }
59
+
60
+ onCreateMethod.body.body.unshift(...classProperties);
61
+ }
62
+
63
+ file._inlineComponentClass = t.objectExpression(objectProperties);
64
+ path.remove();
65
+ }
@@ -0,0 +1,15 @@
1
+ import translateHTML from "./index[html]";
2
+ import translateVDOM from "./index[vdom]";
3
+
4
+ export default function (path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts },
8
+ },
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ translateHTML(path);
12
+ } else {
13
+ translateVDOM(path);
14
+ }
15
+ }
@@ -0,0 +1,17 @@
1
+ import { types as t } from "@marko/compiler";
2
+
3
+ import write from "../util/html-out-write";
4
+ import withPreviousLocation from "../util/with-previous-location";
5
+ const ieConditionalCommentRegExp = /^\[if |<!\[endif\]$/;
6
+
7
+ export default function (path) {
8
+ const { node } = path;
9
+
10
+ if (ieConditionalCommentRegExp.test(node.value)) {
11
+ path.replaceWith(
12
+ withPreviousLocation(write`<!--${t.stringLiteral(node.value)}-->`, node),
13
+ );
14
+ } else {
15
+ path.remove();
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ export default function (path) {
2
+ path.remove();
3
+ }
@@ -0,0 +1,15 @@
1
+ import translateHTML from "./index[html]";
2
+ import translateVDOM from "./index[vdom]";
3
+
4
+ export default function (path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts },
8
+ },
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ translateHTML(path);
12
+ } else {
13
+ translateVDOM(path);
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ import { types as t } from "@marko/compiler";
2
+
3
+ import write from "../util/html-out-write";
4
+ import withPreviousLocation from "../util/with-previous-location";
5
+
6
+ export default function (path) {
7
+ const { node } = path;
8
+
9
+ path.replaceWith(
10
+ withPreviousLocation(write`<?${t.stringLiteral(node.value)}?>`, node),
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ export default function (path) {
2
+ path.remove();
3
+ }
@@ -0,0 +1,15 @@
1
+ import translateHTML from "./index[html]";
2
+ import translateVDOM from "./index[vdom]";
3
+
4
+ export default function (path) {
5
+ const {
6
+ hub: {
7
+ file: { markoOpts },
8
+ },
9
+ } = path;
10
+ if (markoOpts.output === "html") {
11
+ translateHTML(path);
12
+ } else {
13
+ translateVDOM(path);
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ import { types as t } from "@marko/compiler";
2
+
3
+ import write from "../util/html-out-write";
4
+ import withPreviousLocation from "../util/with-previous-location";
5
+
6
+ export default function (path) {
7
+ const { node } = path;
8
+
9
+ path.replaceWith(
10
+ withPreviousLocation(write`<!${t.stringLiteral(node.value)}>`, node),
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ export default function (path) {
2
+ path.remove();
3
+ }