marko 5.37.63 → 5.38.1

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.
@@ -148,7 +148,7 @@ exports.p = function (htmlCompat) {
148
148
  {}
149
149
  );
150
150
 
151
- htmlCompat.patchDynamicTag(function getRenderer(scopeId, accessor, tag) {
151
+ htmlCompat.patchDynamicTag(function getRenderer(tag, scopeId, accessor) {
152
152
  if (!tag || isMarko6(tag._ || tag.content || tag)) {
153
153
  return tag;
154
154
  }
@@ -588,20 +588,21 @@ function getRuntimeEntryFiles(output, optimize) {
588
588
  `${base}core-tags/core/__flush_here_and_after__.js`,
589
589
  `${base}core-tags/core/await/renderer.js`,
590
590
  `${base}core-tags/core/await/reorderer-renderer.js`,
591
- `${base}runtime/helpers/skip-serialize.js`] :
591
+ `${base}runtime/helpers/skip-serialize.js`,
592
+ `${base}runtime/helpers/tags-compat/html${optimize ? "" : "-debug"}.mjs`] :
592
593
 
593
594
  [
594
595
  `${base}runtime/vdom/index.js`,
595
596
  `${base}runtime/vdom/hot-reload.js`,
596
597
  `${base}runtime/vdom/helpers/attrs.js`,
597
- `${base}runtime/vdom/helpers/const-element.js`])];
598
+ `${base}runtime/vdom/helpers/const-element.js`,
599
+ `${base}runtime/helpers/tags-compat/dom${optimize ? "" : "-debug"}.mjs`])];
598
600
 
599
601
 
600
602
  }
601
603
 
602
- function isRenderContent(path) {
603
- const { node } = path;
604
- return _compiler.types.MARKO_TYPES.includes(node.type) && !node.static;
604
+ function isRenderContent({ node }) {
605
+ return /^Marko/.test(node.type) && !node.static;
605
606
  }
606
607
 
607
608
  function resolveRelativeTagEntry(file, tagDef) {
@@ -1,4 +1,35 @@
1
- "use strict";exports.__esModule = true;exports.default = _default;function _default(path) {
1
+ "use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+
3
+ function _default(path) {
2
4
  const { node } = path;
5
+ const isHTML = path.hub.file.markoOpts.output === "html";
6
+ switch (node.target) {
7
+ case "server":
8
+ if (!isHTML) {
9
+ replaceWithUndefinedIdentifiers(path);
10
+ return;
11
+ }
12
+ break;
13
+ case "client":
14
+ if (isHTML) {
15
+ replaceWithUndefinedIdentifiers(path);
16
+ return;
17
+ }
18
+ break;
19
+ }
3
20
  path.replaceWithMultiple(node.body);
21
+ }
22
+
23
+ function replaceWithUndefinedIdentifiers(path) {
24
+ const keys = Object.keys(path.getOuterBindingIdentifiers());
25
+ if (keys.length) {
26
+ path.replaceWith(
27
+ _compiler.types.variableDeclaration(
28
+ "var",
29
+ keys.map((key) => _compiler.types.variableDeclarator(_compiler.types.identifier(key)))
30
+ )
31
+ );
32
+ } else {
33
+ path.remove();
34
+ }
4
35
  }
@@ -5,9 +5,11 @@ var parseMacro = _interopRequireWildcard(require("./macro/parse"));
5
5
  var translateMacro = _interopRequireWildcard(require("./macro/translate"));
6
6
  var _migrate = _interopRequireDefault(require("./migrate"));
7
7
  var parseClass = _interopRequireWildcard(require("./parse-class"));
8
+ var parseClient = _interopRequireWildcard(require("./parse-client"));
8
9
  var parseExport = _interopRequireWildcard(require("./parse-export"));
9
10
  var parseImport = _interopRequireWildcard(require("./parse-import"));
10
11
  var parseModuleCode = _interopRequireWildcard(require("./parse-module-code"));
12
+ var parseServer = _interopRequireWildcard(require("./parse-server"));
11
13
  var parseStatic = _interopRequireWildcard(require("./parse-static"));
12
14
  var transformBody = _interopRequireWildcard(require("./transform-body"));
13
15
  var transformStyle = _interopRequireWildcard(require("./transform-style"));
@@ -55,6 +57,20 @@ var translateWhile = _interopRequireWildcard(require("./translate-while"));funct
55
57
  }]
56
58
 
57
59
  },
60
+ "<client>": {
61
+ "node-factory": parseClient,
62
+ "parse-options": {
63
+ statement: true,
64
+ rawOpenTag: true
65
+ }
66
+ },
67
+ "<server>": {
68
+ "node-factory": parseServer,
69
+ "parse-options": {
70
+ statement: true,
71
+ rawOpenTag: true
72
+ }
73
+ },
58
74
  "<class>": {
59
75
  "node-factory": parseClass,
60
76
  "parse-options": {
@@ -0,0 +1,18 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+ var _babelUtils = require("@marko/compiler/babel-utils");
3
+
4
+ function _default(path) {
5
+ const {
6
+ node,
7
+ hub: { file }
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^client\s*/, "");
11
+ const start = node.start + (rawValue.length - code.length);
12
+ let body = (0, _babelUtils.parseStatements)(file, code, start, end);
13
+ if (body.length === 1 && _compiler.types.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(_compiler.types.markoScriptlet(body, true, "client"));
18
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+ var _babelUtils = require("@marko/compiler/babel-utils");
3
+
4
+ function _default(path) {
5
+ const {
6
+ node,
7
+ hub: { file }
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^server\s*/, "");
11
+ const start = node.start + (rawValue.length - code.length);
12
+ let body = (0, _babelUtils.parseStatements)(file, code, start, end);
13
+ if (body.length === 1 && _compiler.types.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(_compiler.types.markoScriptlet(body, true, "server"));
18
+ }
@@ -140,6 +140,23 @@ const entryBuilder = exports.entryBuilder = {
140
140
  resolveRelativeToEntry(entryFile, file, value)
141
141
  );
142
142
  }
143
+ } else if (
144
+ _compiler.types.isMarkoScriptlet(child) &&
145
+ child.static &&
146
+ child.target !== "server")
147
+ {
148
+ for (const stmt of child.body) {
149
+ if (_compiler.types.isImportDeclaration(stmt)) {
150
+ const { value } = stmt.source;
151
+ if (child.target === "client" || state.shouldIncludeImport(value)) {
152
+ addImport(
153
+ imports,
154
+ body,
155
+ resolveRelativeToEntry(entryFile, file, value)
156
+ );
157
+ }
158
+ }
159
+ }
143
160
  }
144
161
  }
145
162
 
@@ -78,7 +78,11 @@ const analyzeStaticVisitor = {
78
78
  !(0, _keyManager.hasUserKey)(path);
79
79
 
80
80
  const tagDef = (0, _babelUtils.getTagDef)(path);
81
- isStatic = isStatic && !tagDef.translator;
81
+ isStatic =
82
+ isStatic && (
83
+ !tagDef.translator ||
84
+ tagDef.name === "script" ||
85
+ tagDef.name === "style");
82
86
 
83
87
  // check attributes
84
88
  isStatic =
@@ -0,0 +1,13 @@
1
+ "use strict";exports.__esModule = true;exports.translate = exports.transform = exports.taglibs = exports.tagDiscoveryDirs = exports.preferAPI = exports.getRuntimeEntryFiles = exports.analyze = void 0;var tagsAPI = _interopRequireWildcard(require("@marko/runtime-tags/translator"));
2
+
3
+ var classAPI = _interopRequireWildcard(require("./translator/index"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);}
4
+
5
+ const {
6
+ preferAPI,
7
+ tagDiscoveryDirs,
8
+ transform,
9
+ analyze,
10
+ translate,
11
+ taglibs,
12
+ getRuntimeEntryFiles
13
+ } = tagsAPI.createInteropTranslator(classAPI);exports.getRuntimeEntryFiles = getRuntimeEntryFiles;exports.taglibs = taglibs;exports.translate = translate;exports.analyze = analyze;exports.transform = transform;exports.tagDiscoveryDirs = tagDiscoveryDirs;exports.preferAPI = preferAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.37.63",
3
+ "version": "5.38.1",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -70,7 +70,8 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@babel/runtime": "^7.28.2",
73
- "@marko/compiler": "^5.39.43",
73
+ "@marko/compiler": "^5.39.45",
74
+ "@marko/runtime-tags": "^6.0.122",
74
75
  "app-module-path": "^2.2.0",
75
76
  "argly": "^1.2.0",
76
77
  "browser-refresh-client": "1.1.4",
@@ -148,7 +148,7 @@ exports.p = function (htmlCompat) {
148
148
  {},
149
149
  );
150
150
 
151
- htmlCompat.patchDynamicTag(function getRenderer(scopeId, accessor, tag) {
151
+ htmlCompat.patchDynamicTag(function getRenderer(tag, scopeId, accessor) {
152
152
  if (!tag || isMarko6(tag._ || tag.content || tag)) {
153
153
  return tag;
154
154
  }
@@ -589,19 +589,20 @@ export function getRuntimeEntryFiles(output, optimize) {
589
589
  `${base}core-tags/core/await/renderer.js`,
590
590
  `${base}core-tags/core/await/reorderer-renderer.js`,
591
591
  `${base}runtime/helpers/skip-serialize.js`,
592
+ `${base}runtime/helpers/tags-compat/html${optimize ? "" : "-debug"}.mjs`,
592
593
  ]
593
594
  : [
594
595
  `${base}runtime/vdom/index.js`,
595
596
  `${base}runtime/vdom/hot-reload.js`,
596
597
  `${base}runtime/vdom/helpers/attrs.js`,
597
598
  `${base}runtime/vdom/helpers/const-element.js`,
599
+ `${base}runtime/helpers/tags-compat/dom${optimize ? "" : "-debug"}.mjs`,
598
600
  ]),
599
601
  ];
600
602
  }
601
603
 
602
- function isRenderContent(path) {
603
- const { node } = path;
604
- return t.MARKO_TYPES.includes(node.type) && !node.static;
604
+ function isRenderContent({ node }) {
605
+ return /^Marko/.test(node.type) && !node.static;
605
606
  }
606
607
 
607
608
  function resolveRelativeTagEntry(file, tagDef) {
@@ -1,4 +1,35 @@
1
+ import { types as t } from "@marko/compiler";
2
+
1
3
  export default function (path) {
2
4
  const { node } = path;
5
+ const isHTML = path.hub.file.markoOpts.output === "html";
6
+ switch (node.target) {
7
+ case "server":
8
+ if (!isHTML) {
9
+ replaceWithUndefinedIdentifiers(path);
10
+ return;
11
+ }
12
+ break;
13
+ case "client":
14
+ if (isHTML) {
15
+ replaceWithUndefinedIdentifiers(path);
16
+ return;
17
+ }
18
+ break;
19
+ }
3
20
  path.replaceWithMultiple(node.body);
4
21
  }
22
+
23
+ function replaceWithUndefinedIdentifiers(path) {
24
+ const keys = Object.keys(path.getOuterBindingIdentifiers());
25
+ if (keys.length) {
26
+ path.replaceWith(
27
+ t.variableDeclaration(
28
+ "var",
29
+ keys.map((key) => t.variableDeclarator(t.identifier(key))),
30
+ ),
31
+ );
32
+ } else {
33
+ path.remove();
34
+ }
35
+ }
@@ -5,9 +5,11 @@ import * as parseMacro from "./macro/parse";
5
5
  import * as translateMacro from "./macro/translate";
6
6
  import migrate from "./migrate";
7
7
  import * as parseClass from "./parse-class";
8
+ import * as parseClient from "./parse-client";
8
9
  import * as parseExport from "./parse-export";
9
10
  import * as parseImport from "./parse-import";
10
11
  import * as parseModuleCode from "./parse-module-code";
12
+ import * as parseServer from "./parse-server";
11
13
  import * as parseStatic from "./parse-static";
12
14
  import * as transformBody from "./transform-body";
13
15
  import * as transformStyle from "./transform-style";
@@ -55,6 +57,20 @@ export default {
55
57
  },
56
58
  ],
57
59
  },
60
+ "<client>": {
61
+ "node-factory": parseClient,
62
+ "parse-options": {
63
+ statement: true,
64
+ rawOpenTag: true,
65
+ },
66
+ },
67
+ "<server>": {
68
+ "node-factory": parseServer,
69
+ "parse-options": {
70
+ statement: true,
71
+ rawOpenTag: true,
72
+ },
73
+ },
58
74
  "<class>": {
59
75
  "node-factory": parseClass,
60
76
  "parse-options": {
@@ -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(/^client\s*/, "");
11
+ const start = node.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, "client"));
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(/^server\s*/, "");
11
+ const start = node.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, "server"));
18
+ }
@@ -140,6 +140,23 @@ export const entryBuilder = {
140
140
  resolveRelativeToEntry(entryFile, file, value),
141
141
  );
142
142
  }
143
+ } else if (
144
+ t.isMarkoScriptlet(child) &&
145
+ child.static &&
146
+ child.target !== "server"
147
+ ) {
148
+ for (const stmt of child.body) {
149
+ if (t.isImportDeclaration(stmt)) {
150
+ const { value } = stmt.source;
151
+ if (child.target === "client" || state.shouldIncludeImport(value)) {
152
+ addImport(
153
+ imports,
154
+ body,
155
+ resolveRelativeToEntry(entryFile, file, value),
156
+ );
157
+ }
158
+ }
159
+ }
143
160
  }
144
161
  }
145
162
 
@@ -78,7 +78,11 @@ const analyzeStaticVisitor = {
78
78
  !hasUserKey(path);
79
79
 
80
80
  const tagDef = getTagDef(path);
81
- isStatic = isStatic && !tagDef.translator;
81
+ isStatic =
82
+ isStatic &&
83
+ (!tagDef.translator ||
84
+ tagDef.name === "script" ||
85
+ tagDef.name === "style");
82
86
 
83
87
  // check attributes
84
88
  isStatic =
@@ -0,0 +1,13 @@
1
+ import * as tagsAPI from "@marko/runtime-tags/translator";
2
+
3
+ import * as classAPI from "./translator/index";
4
+
5
+ export const {
6
+ preferAPI,
7
+ tagDiscoveryDirs,
8
+ transform,
9
+ analyze,
10
+ translate,
11
+ taglibs,
12
+ getRuntimeEntryFiles,
13
+ } = tagsAPI.createInteropTranslator(classAPI);
@@ -1,5 +1,5 @@
1
1
  {
2
- "main": "../dist/translator/index.js",
2
+ "main": "../dist/translator.js",
3
3
  "types": "index.d.ts",
4
- "main:override": "../src/translator/index.js"
4
+ "main:override": "../src/translator.js"
5
5
  }