marko 5.37.9 → 5.37.11

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.
@@ -66,8 +66,76 @@ class ServerComponent {
66
66
  onCreate() {}
67
67
  onInput() {}
68
68
  onRender() {}
69
+
70
+ isDestroyed() {
71
+ return false;
72
+ }
73
+
74
+ setState(name, value) {
75
+ if (typeof name == "object") {
76
+ if (this.A_) {
77
+ Object.assign(this.A_, name);
78
+ } else {
79
+ this.A_ = name;
80
+ }
81
+ } else {
82
+ this.A_[name] = value;
83
+ }
84
+ }
85
+
86
+ setStateDirty(name, value) {
87
+ if (typeof name == "object") {
88
+ if (this.A_) {
89
+ Object.assign(this.A_, name);
90
+ } else {
91
+ this.A_ = name;
92
+ }
93
+ } else {
94
+ this.A_[name] = value;
95
+ }
96
+ }
97
+
98
+ replaceState(newState) {
99
+ this.A_ = newState;
100
+ }
101
+
102
+ subscribeTo() {
103
+ notImplemented("subscribeTo");
104
+ }
105
+
106
+ emit() {
107
+ notImplemented("emit");
108
+ }
109
+
110
+ getEl() {
111
+ notImplemented("getEl");
112
+ }
113
+
114
+ getEls() {
115
+ notImplemented("getEls");
116
+ }
117
+
118
+ getComponent() {
119
+ notImplemented("getComponent");
120
+ }
121
+
122
+ getComponents() {
123
+ notImplemented("getComponents");
124
+ }
125
+
126
+ forceUpdate() {
127
+ notImplemented("forceUpdate");
128
+ }
129
+
130
+ update() {
131
+ notImplemented("update");
132
+ }
69
133
  }
70
134
 
71
135
  ServerComponent.prototype.getElId = ServerComponent.prototype.elId;
72
136
 
73
- module.exports = ServerComponent;
137
+ module.exports = ServerComponent;
138
+
139
+ function notImplemented(name) {
140
+ throw new Error(name + " method not supported during SSR.");
141
+ }
@@ -73,6 +73,7 @@ const analyze = exports.analyze = {
73
73
  {
74
74
  meta.component = file.opts.filename;
75
75
  } else if (meta.hasStringEventHandlers) {
76
+ meta.implicitSplitComponent = true;
76
77
  meta.component = componentFiles.componentBrowserFile =
77
78
  "marko/src/runtime/helpers/empty-component.js";
78
79
  meta.hasComponentBrowser = true;
@@ -388,7 +389,7 @@ const translate = exports.translate = {
388
389
  componentTypeIdentifier,
389
390
  _compiler.types.arrowFunctionExpression(
390
391
  [],
391
- componentBrowserFile ?
392
+ componentBrowserFile && !meta.implicitSplitComponent ?
392
393
  (0, _babelUtils.importDefault)(
393
394
  file,
394
395
  (0, _babelUtils.resolveRelativePath)(file, componentBrowserFile),
@@ -14,7 +14,8 @@ function _default(path) {
14
14
  } = path;
15
15
  const {
16
16
  rawValue: code,
17
- name: { start, end }
17
+ name: { start },
18
+ end
18
19
  } = node;
19
20
  const meta = file.metadata.marko;
20
21
 
@@ -40,7 +41,9 @@ function _default(path) {
40
41
 
41
42
  const parsed = (0, _babelUtils.parseExpression)(file, code.replace(/;\s*$/, ""), start, end);
42
43
  if (parsed.type === "MarkoParseError") {
43
- path.replaceWith(_compiler.types.markoClass([_compiler.types.expressionStatement(parsed)]));
44
+ const replacement = _compiler.types.markoClass(_compiler.types.classBody([]));
45
+ replacement.body.body.push(parsed);
46
+ path.replaceWith(replacement);
44
47
  return;
45
48
  }
46
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.37.9",
3
+ "version": "5.37.11",
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,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@babel/runtime": "^7.26.0",
73
- "@marko/compiler": "^5.39.8",
73
+ "@marko/compiler": "^5.39.9",
74
74
  "app-module-path": "^2.2.0",
75
75
  "argly": "^1.2.0",
76
76
  "browser-refresh-client": "1.1.4",
@@ -66,8 +66,76 @@ class ServerComponent {
66
66
  onCreate() {}
67
67
  onInput() {}
68
68
  onRender() {}
69
+
70
+ isDestroyed() {
71
+ return false;
72
+ }
73
+
74
+ setState(name, value) {
75
+ if (typeof name == "object") {
76
+ if (this.___state) {
77
+ Object.assign(this.___state, name);
78
+ } else {
79
+ this.___state = name;
80
+ }
81
+ } else {
82
+ this.___state[name] = value;
83
+ }
84
+ }
85
+
86
+ setStateDirty(name, value) {
87
+ if (typeof name == "object") {
88
+ if (this.___state) {
89
+ Object.assign(this.___state, name);
90
+ } else {
91
+ this.___state = name;
92
+ }
93
+ } else {
94
+ this.___state[name] = value;
95
+ }
96
+ }
97
+
98
+ replaceState(newState) {
99
+ this.___state = newState;
100
+ }
101
+
102
+ subscribeTo() {
103
+ notImplemented("subscribeTo");
104
+ }
105
+
106
+ emit() {
107
+ notImplemented("emit");
108
+ }
109
+
110
+ getEl() {
111
+ notImplemented("getEl");
112
+ }
113
+
114
+ getEls() {
115
+ notImplemented("getEls");
116
+ }
117
+
118
+ getComponent() {
119
+ notImplemented("getComponent");
120
+ }
121
+
122
+ getComponents() {
123
+ notImplemented("getComponents");
124
+ }
125
+
126
+ forceUpdate() {
127
+ notImplemented("forceUpdate");
128
+ }
129
+
130
+ update() {
131
+ notImplemented("update");
132
+ }
69
133
  }
70
134
 
71
135
  ServerComponent.prototype.getElId = ServerComponent.prototype.elId;
72
136
 
73
137
  module.exports = ServerComponent;
138
+
139
+ function notImplemented(name) {
140
+ throw new Error(name + " method not supported during SSR.");
141
+ }
@@ -73,6 +73,7 @@ export const analyze = {
73
73
  ) {
74
74
  meta.component = file.opts.filename;
75
75
  } else if (meta.hasStringEventHandlers) {
76
+ meta.implicitSplitComponent = true;
76
77
  meta.component = componentFiles.componentBrowserFile =
77
78
  "marko/src/runtime/helpers/empty-component.js";
78
79
  meta.hasComponentBrowser = true;
@@ -388,7 +389,7 @@ export const translate = {
388
389
  componentTypeIdentifier,
389
390
  t.arrowFunctionExpression(
390
391
  [],
391
- componentBrowserFile
392
+ componentBrowserFile && !meta.implicitSplitComponent
392
393
  ? importDefault(
393
394
  file,
394
395
  resolveRelativePath(file, componentBrowserFile),
@@ -14,7 +14,8 @@ export default function (path) {
14
14
  } = path;
15
15
  const {
16
16
  rawValue: code,
17
- name: { start, end },
17
+ name: { start },
18
+ end,
18
19
  } = node;
19
20
  const meta = file.metadata.marko;
20
21
 
@@ -40,7 +41,9 @@ export default function (path) {
40
41
 
41
42
  const parsed = parseExpression(file, code.replace(/;\s*$/, ""), start, end);
42
43
  if (parsed.type === "MarkoParseError") {
43
- path.replaceWith(t.markoClass([t.expressionStatement(parsed)]));
44
+ const replacement = t.markoClass(t.classBody([]));
45
+ replacement.body.body.push(parsed);
46
+ path.replaceWith(replacement);
44
47
  return;
45
48
  }
46
49