marko 5.37.49 → 5.37.51

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.
@@ -50,7 +50,7 @@ exports.p = function (domCompat) {
50
50
  const TagsCompat = createRenderer(
51
51
  function (_, out, componentDef, component) {
52
52
  const input = Array.isArray(_.i) ? _.i : [_.i];
53
- const tagsRenderer = domCompat.resolveRegistered(_.r, global);
53
+ const tagsRenderer = domCompat.resolveRegistered(_.r, out.global);
54
54
  const newNode = domCompat.render(out, component, tagsRenderer, input);
55
55
 
56
56
  out.bf("1", component, !newNode);
@@ -34,6 +34,11 @@ exports.p = function (htmlCompat) {
34
34
 
35
35
  if (componentDefs) {
36
36
  scripts = _g_($global, componentDefs);
37
+ htmlCompat.ensureState($global).walkOnNextFlush = true;
38
+
39
+ if (!tagsAPI.length) {
40
+ scripts = concatScripts(htmlCompat.flushScript($global), scripts);
41
+ }
37
42
  }
38
43
 
39
44
  if (tagsAPI.length) {
@@ -70,17 +75,19 @@ exports.p = function (htmlCompat) {
70
75
  return tagsRenderer;
71
76
  }
72
77
 
73
- if (!tagsRenderer && renderBody) {
74
- renderBody.toJSON = htmlCompat.toJSON;
75
- }
76
-
77
- return (input, out) =>
78
- TagsCompat(
79
- args ?
80
- { i: args, r: (args) => (tagsRenderer || renderBody)(...args) } :
81
- { i: input, r: tagsRenderer || renderBody },
82
- out
83
- );
78
+ return (input, out) => {
79
+ if (!tagsRenderer && renderBody) {
80
+ renderBody.toJSON = htmlCompat.toJSON(
81
+ htmlCompat.ensureState(out.global)
82
+ );
83
+ }
84
+ TagsCompat(
85
+ args ?
86
+ { i: args, r: (args) => (tagsRenderer || renderBody)(...args) } :
87
+ { i: input, r: tagsRenderer || renderBody },
88
+ out
89
+ );
90
+ };
84
91
  };
85
92
 
86
93
  const TagsCompatId = "tags-compat";
@@ -147,7 +154,7 @@ exports.p = function (htmlCompat) {
147
154
  return (input, ...args) => {
148
155
  // tags to class
149
156
  const $global = htmlCompat.$global();
150
- htmlCompat.ensureState($global);
157
+ const state = htmlCompat.ensureState($global);
151
158
  let writers = writersByGlobal.get($global);
152
159
  if (!writers) {
153
160
  writersByGlobal.set($global, writers = { classAPI: [], tagsAPI: [] });
@@ -169,7 +176,7 @@ exports.p = function (htmlCompat) {
169
176
  key[2] === "-" ? key.slice(3) : key.slice(2).toLowerCase(),
170
177
  value]
171
178
  );
172
- value.toJSON = htmlCompat.toJSON;
179
+ value.toJSON = htmlCompat.toJSON(state);
173
180
  }
174
181
  } else {
175
182
  input[key === "content" ? "renderBody" : key] = value;
@@ -428,32 +428,44 @@ const translate = exports.translate = {
428
428
  );
429
429
  }
430
430
 
431
- path.pushContainer(
432
- "body",
433
- _compiler.types.expressionStatement(
434
- _compiler.types.assignmentExpression(
435
- "=",
436
- templateRendererMember,
437
- _compiler.types.callExpression(rendererIdentifier, [
438
- _compiler.types.functionExpression(
439
- null,
440
- [
441
- _compiler.types.identifier("input"),
442
- _compiler.types.identifier("out"),
443
- file._componentDefIdentifier,
444
- file._componentInstanceIdentifier,
445
- _compiler.types.identifier("state"),
446
- _compiler.types.identifier("$global")],
447
-
448
- renderBlock.node
449
- ),
450
- _compiler.types.objectExpression(templateRenderOptionsProps),
451
- componentIdentifier]
452
- )
453
- )
431
+ let rendererAssignment = _compiler.types.assignmentExpression(
432
+ "=",
433
+ templateRendererMember,
434
+ _compiler.types.callExpression(rendererIdentifier, [
435
+ _compiler.types.functionExpression(
436
+ null,
437
+ [
438
+ _compiler.types.identifier("input"),
439
+ _compiler.types.identifier("out"),
440
+ file._componentDefIdentifier,
441
+ file._componentInstanceIdentifier,
442
+ _compiler.types.identifier("state"),
443
+ _compiler.types.identifier("$global")],
444
+
445
+ renderBlock.node
446
+ ),
447
+ _compiler.types.objectExpression(templateRenderOptionsProps),
448
+ componentIdentifier]
454
449
  )
455
450
  );
456
451
 
452
+ if (!isHTML && componentBrowserFile && !meta.implicitSplitComponent) {
453
+ rendererAssignment = _compiler.types.assignmentExpression(
454
+ "=",
455
+ _compiler.types.memberExpression(
456
+ (0, _babelUtils.importDefault)(
457
+ file,
458
+ (0, _babelUtils.resolveRelativePath)(file, componentBrowserFile),
459
+ "marko_split_component"
460
+ ),
461
+ _compiler.types.identifier("renderer")
462
+ ),
463
+ rendererAssignment
464
+ );
465
+ }
466
+
467
+ path.pushContainer("body", _compiler.types.expressionStatement(rendererAssignment));
468
+
457
469
  if (meta.implicitSplitComponent && isHTML) {
458
470
  renderBlock.unshiftContainer(
459
471
  "body",
@@ -43,7 +43,7 @@ const lassoDepPrefix = "package: ";var _default =
43
43
  };exports.default = _default;
44
44
 
45
45
  const entryBuilder = exports.entryBuilder = {
46
- build(entryFile) {
46
+ build(entryFile, exportInit) {
47
47
  const state = entryFile[kEntryState];
48
48
  if (!state) {
49
49
  throw entryFile.path.buildCodeFrameError(
@@ -53,6 +53,7 @@ const entryBuilder = exports.entryBuilder = {
53
53
  const { markoOpts } = entryFile;
54
54
  const entryMarkoMeta = entryFile.metadata.marko;
55
55
  const { body } = state;
56
+ let didExportInit = false;
56
57
  entryMarkoMeta.watchFiles = [...state.watchFiles];
57
58
  entryMarkoMeta.deps = [...state.lassoDeps];
58
59
 
@@ -69,19 +70,29 @@ const entryBuilder = exports.entryBuilder = {
69
70
 
70
71
  body.unshift(markoComponentsImport);
71
72
 
72
- if (markoOpts.hydrateInit) {
73
+ if (markoOpts.hydrateInit || exportInit) {
74
+ const initExpression = _compiler.types.callExpression(
75
+ initId,
76
+ markoOpts.runtimeId ? [_compiler.types.stringLiteral(markoOpts.runtimeId)] : []
77
+ );
73
78
  markoComponentsImport.specifiers.push(
74
79
  _compiler.types.importSpecifier(initId, initId)
75
80
  );
81
+
76
82
  body.push(
77
- _compiler.types.expressionStatement(
78
- _compiler.types.callExpression(
79
- initId,
80
- markoOpts.runtimeId ? [_compiler.types.stringLiteral(markoOpts.runtimeId)] : []
81
- )
82
- )
83
+ exportInit ?
84
+ _compiler.types.exportDefaultDeclaration(
85
+ _compiler.types.arrowFunctionExpression([], initExpression)
86
+ ) :
87
+ _compiler.types.expressionStatement(initExpression)
83
88
  );
84
89
  }
90
+ } else if (exportInit) {
91
+ body.push(
92
+ _compiler.types.exportDefaultDeclaration(
93
+ _compiler.types.arrowFunctionExpression([], _compiler.types.blockStatement([]))
94
+ )
95
+ );
85
96
  }
86
97
 
87
98
  return body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.37.49",
3
+ "version": "5.37.51",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -50,7 +50,7 @@ exports.p = function (domCompat) {
50
50
  const TagsCompat = createRenderer(
51
51
  function (_, out, componentDef, component) {
52
52
  const input = Array.isArray(_.i) ? _.i : [_.i];
53
- const tagsRenderer = domCompat.resolveRegistered(_.r, global);
53
+ const tagsRenderer = domCompat.resolveRegistered(_.r, out.global);
54
54
  const newNode = domCompat.render(out, component, tagsRenderer, input);
55
55
 
56
56
  out.bf("1", component, !newNode);
@@ -34,6 +34,11 @@ exports.p = function (htmlCompat) {
34
34
 
35
35
  if (componentDefs) {
36
36
  scripts = ___getInitComponentsCodeForDefs($global, componentDefs);
37
+ htmlCompat.ensureState($global).walkOnNextFlush = true;
38
+
39
+ if (!tagsAPI.length) {
40
+ scripts = concatScripts(htmlCompat.flushScript($global), scripts);
41
+ }
37
42
  }
38
43
 
39
44
  if (tagsAPI.length) {
@@ -70,17 +75,19 @@ exports.p = function (htmlCompat) {
70
75
  return tagsRenderer;
71
76
  }
72
77
 
73
- if (!tagsRenderer && renderBody) {
74
- renderBody.toJSON = htmlCompat.toJSON;
75
- }
76
-
77
- return (input, out) =>
78
+ return (input, out) => {
79
+ if (!tagsRenderer && renderBody) {
80
+ renderBody.toJSON = htmlCompat.toJSON(
81
+ htmlCompat.ensureState(out.global),
82
+ );
83
+ }
78
84
  TagsCompat(
79
85
  args
80
86
  ? { i: args, r: (args) => (tagsRenderer || renderBody)(...args) }
81
87
  : { i: input, r: tagsRenderer || renderBody },
82
88
  out,
83
89
  );
90
+ };
84
91
  };
85
92
 
86
93
  const TagsCompatId = "tags-compat";
@@ -147,7 +154,7 @@ exports.p = function (htmlCompat) {
147
154
  return (input, ...args) => {
148
155
  // tags to class
149
156
  const $global = htmlCompat.$global();
150
- htmlCompat.ensureState($global);
157
+ const state = htmlCompat.ensureState($global);
151
158
  let writers = writersByGlobal.get($global);
152
159
  if (!writers) {
153
160
  writersByGlobal.set($global, (writers = { classAPI: [], tagsAPI: [] }));
@@ -169,7 +176,7 @@ exports.p = function (htmlCompat) {
169
176
  key[2] === "-" ? key.slice(3) : key.slice(2).toLowerCase(),
170
177
  value,
171
178
  ]);
172
- value.toJSON = htmlCompat.toJSON;
179
+ value.toJSON = htmlCompat.toJSON(state);
173
180
  }
174
181
  } else {
175
182
  input[key === "content" ? "renderBody" : key] = value;
@@ -428,32 +428,44 @@ export const translate = {
428
428
  );
429
429
  }
430
430
 
431
- path.pushContainer(
432
- "body",
433
- t.expressionStatement(
434
- t.assignmentExpression(
435
- "=",
436
- templateRendererMember,
437
- t.callExpression(rendererIdentifier, [
438
- t.functionExpression(
439
- null,
440
- [
441
- t.identifier("input"),
442
- t.identifier("out"),
443
- file._componentDefIdentifier,
444
- file._componentInstanceIdentifier,
445
- t.identifier("state"),
446
- t.identifier("$global"),
447
- ],
448
- renderBlock.node,
449
- ),
450
- t.objectExpression(templateRenderOptionsProps),
451
- componentIdentifier,
452
- ]),
431
+ let rendererAssignment = t.assignmentExpression(
432
+ "=",
433
+ templateRendererMember,
434
+ t.callExpression(rendererIdentifier, [
435
+ t.functionExpression(
436
+ null,
437
+ [
438
+ t.identifier("input"),
439
+ t.identifier("out"),
440
+ file._componentDefIdentifier,
441
+ file._componentInstanceIdentifier,
442
+ t.identifier("state"),
443
+ t.identifier("$global"),
444
+ ],
445
+ renderBlock.node,
453
446
  ),
454
- ),
447
+ t.objectExpression(templateRenderOptionsProps),
448
+ componentIdentifier,
449
+ ]),
455
450
  );
456
451
 
452
+ if (!isHTML && componentBrowserFile && !meta.implicitSplitComponent) {
453
+ rendererAssignment = t.assignmentExpression(
454
+ "=",
455
+ t.memberExpression(
456
+ importDefault(
457
+ file,
458
+ resolveRelativePath(file, componentBrowserFile),
459
+ "marko_split_component",
460
+ ),
461
+ t.identifier("renderer"),
462
+ ),
463
+ rendererAssignment,
464
+ );
465
+ }
466
+
467
+ path.pushContainer("body", t.expressionStatement(rendererAssignment));
468
+
457
469
  if (meta.implicitSplitComponent && isHTML) {
458
470
  renderBlock.unshiftContainer(
459
471
  "body",
@@ -43,7 +43,7 @@ export default (entryFile, isHydrate) => {
43
43
  };
44
44
 
45
45
  export const entryBuilder = {
46
- build(entryFile) {
46
+ build(entryFile, exportInit) {
47
47
  const state = entryFile[kEntryState];
48
48
  if (!state) {
49
49
  throw entryFile.path.buildCodeFrameError(
@@ -53,6 +53,7 @@ export const entryBuilder = {
53
53
  const { markoOpts } = entryFile;
54
54
  const entryMarkoMeta = entryFile.metadata.marko;
55
55
  const { body } = state;
56
+ let didExportInit = false;
56
57
  entryMarkoMeta.watchFiles = [...state.watchFiles];
57
58
  entryMarkoMeta.deps = [...state.lassoDeps];
58
59
 
@@ -69,19 +70,29 @@ export const entryBuilder = {
69
70
 
70
71
  body.unshift(markoComponentsImport);
71
72
 
72
- if (markoOpts.hydrateInit) {
73
+ if (markoOpts.hydrateInit || exportInit) {
74
+ const initExpression = t.callExpression(
75
+ initId,
76
+ markoOpts.runtimeId ? [t.stringLiteral(markoOpts.runtimeId)] : [],
77
+ );
73
78
  markoComponentsImport.specifiers.push(
74
79
  t.importSpecifier(initId, initId),
75
80
  );
81
+
76
82
  body.push(
77
- t.expressionStatement(
78
- t.callExpression(
79
- initId,
80
- markoOpts.runtimeId ? [t.stringLiteral(markoOpts.runtimeId)] : [],
81
- ),
82
- ),
83
+ exportInit
84
+ ? t.exportDefaultDeclaration(
85
+ t.arrowFunctionExpression([], initExpression),
86
+ )
87
+ : t.expressionStatement(initExpression),
83
88
  );
84
89
  }
90
+ } else if (exportInit) {
91
+ body.push(
92
+ t.exportDefaultDeclaration(
93
+ t.arrowFunctionExpression([], t.blockStatement([])),
94
+ ),
95
+ );
85
96
  }
86
97
 
87
98
  return body;