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.
- package/dist/compiler/index.js +11 -11
- package/dist/core-tags/components/init-components-tag.js +4 -4
- package/dist/core-tags/components/preferred-script-location-tag.js +2 -2
- package/dist/core-tags/core/__flush_here_and_after__.js +1 -1
- package/dist/core-tags/core/await/AsyncValue.js +21 -21
- package/dist/core-tags/core/await/renderer.js +24 -24
- package/dist/core-tags/core/await/reorderer-renderer.js +6 -6
- package/dist/node-require/browser-refresh.js +18 -1
- package/dist/node-require/index.js +7 -7
- package/dist/node_modules/@internal/components-beginComponent/index-browser.js +5 -5
- package/dist/node_modules/@internal/components-beginComponent/index.js +12 -12
- package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +99 -99
- package/dist/node_modules/@internal/components-define-widget-legacy/index.js +3 -3
- package/dist/node_modules/@internal/components-endComponent/index.js +3 -3
- package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
- package/dist/node_modules/@internal/components-entry/index.js +29 -29
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +13 -13
- package/dist/node_modules/@internal/components-entry-legacy/index.js +1 -1
- package/dist/node_modules/@internal/components-registry/index-browser.js +102 -102
- package/dist/node_modules/@internal/components-registry/index.js +2 -2
- package/dist/node_modules/@internal/components-util/index-browser.js +20 -20
- package/dist/node_modules/@internal/components-util/index.js +24 -20
- package/dist/node_modules/@internal/create-readable/index-browser.js +1 -1
- package/dist/node_modules/@internal/create-readable/index.js +9 -9
- package/dist/node_modules/@internal/preserve-tag/index-browser.js +8 -8
- package/dist/node_modules/@internal/preserve-tag/index.js +6 -6
- package/dist/node_modules/@internal/set-immediate/index-browser.js +2 -2
- package/dist/node_modules/@internal/set-immediate/index-worker.js +3 -3
- package/dist/node_modules/@internal/set-immediate/index.js +3 -3
- package/dist/runtime/RenderResult.js +24 -24
- package/dist/runtime/components/Component.js +163 -163
- package/dist/runtime/components/ComponentDef.js +34 -34
- package/dist/runtime/components/ComponentsContext.js +20 -20
- package/dist/runtime/components/GlobalComponentsContext.js +4 -4
- package/dist/runtime/components/KeySequence.js +3 -3
- package/dist/runtime/components/ServerComponent.js +17 -17
- package/dist/runtime/components/State.js +28 -28
- package/dist/runtime/components/attach-detach.js +8 -8
- package/dist/runtime/components/defineComponent.js +5 -5
- package/dist/runtime/components/dom-data.js +6 -6
- package/dist/runtime/components/event-delegation.js +10 -10
- package/dist/runtime/components/legacy/defineComponent-legacy.js +1 -1
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +25 -25
- package/dist/runtime/components/legacy/dependencies/index.js +10 -10
- package/dist/runtime/components/legacy/renderer-legacy.js +56 -56
- package/dist/runtime/components/renderer.js +45 -45
- package/dist/runtime/components/update-manager.js +4 -4
- package/dist/runtime/createOut.js +1 -1
- package/dist/runtime/dom-insert.js +5 -5
- package/dist/runtime/helpers/_change-case.js +2 -2
- package/dist/runtime/helpers/dynamic-tag.js +33 -33
- package/dist/runtime/helpers/render-tag.js +1 -1
- package/dist/runtime/helpers/serialize-noop.js +2 -2
- package/dist/runtime/helpers/style-value.js +1 -1
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +35 -35
- package/dist/runtime/helpers/tags-compat/runtime-html.js +16 -16
- package/dist/runtime/html/AsyncStream.js +28 -28
- package/dist/runtime/html/BufferedWriter.js +2 -2
- package/dist/runtime/html/StringWriter.js +2 -2
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +11 -11
- package/dist/runtime/html/helpers/attrs.js +6 -6
- package/dist/runtime/html/helpers/data-marko.js +6 -6
- package/dist/runtime/html/helpers/escape-quotes.js +2 -2
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/html/helpers/merge-attrs.js +11 -11
- package/dist/runtime/html/helpers/props-script.js +1 -1
- package/dist/runtime/html/index.js +2 -2
- package/dist/runtime/renderable.js +5 -5
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +100 -100
- package/dist/runtime/vdom/VComment.js +7 -7
- package/dist/runtime/vdom/VComponent.js +5 -5
- package/dist/runtime/vdom/VDocumentFragment.js +8 -8
- package/dist/runtime/vdom/VElement.js +52 -52
- package/dist/runtime/vdom/VFragment.js +9 -9
- package/dist/runtime/vdom/VNode.js +34 -34
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/attrs.js +6 -6
- package/dist/runtime/vdom/helpers/const-element.js +3 -3
- package/dist/runtime/vdom/hot-reload.js +20 -20
- package/dist/runtime/vdom/index.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +10 -10
- package/dist/runtime/vdom/morphdom/helpers.js +5 -5
- package/dist/runtime/vdom/morphdom/index.js +81 -81
- package/dist/runtime/vdom/vdom.js +15 -15
- package/dist/taglib/index.js +7 -7
- package/dist/translator/cdata/index.js +15 -0
- package/dist/translator/cdata/index[html].js +15 -0
- package/dist/translator/cdata/index[vdom].js +12 -0
- package/dist/translator/class.js +65 -0
- package/dist/translator/comment/index.js +15 -0
- package/dist/translator/comment/index[html].js +17 -0
- package/dist/translator/comment/index[vdom].js +3 -0
- package/dist/translator/declaration/index.js +15 -0
- package/dist/translator/declaration/index[html].js +12 -0
- package/dist/translator/declaration/index[vdom].js +3 -0
- package/dist/translator/document-type/index.js +15 -0
- package/dist/translator/document-type/index[html].js +12 -0
- package/dist/translator/document-type/index[vdom].js +3 -0
- package/dist/translator/index.js +551 -0
- package/dist/translator/placeholder/index.js +15 -0
- package/dist/translator/placeholder/index[html].js +93 -0
- package/dist/translator/placeholder/index[vdom].js +22 -0
- package/dist/translator/scriptlet.js +4 -0
- package/dist/translator/tag/attribute/directives/class.js +42 -0
- package/dist/translator/tag/attribute/directives/index.js +15 -0
- package/dist/translator/tag/attribute/directives/no-update-body-if.js +15 -0
- package/dist/translator/tag/attribute/directives/no-update-body.js +10 -0
- package/dist/translator/tag/attribute/directives/no-update-if.js +12 -0
- package/dist/translator/tag/attribute/directives/no-update.js +48 -0
- package/dist/translator/tag/attribute/directives/style.js +42 -0
- package/dist/translator/tag/attribute/index.js +150 -0
- package/dist/translator/tag/attribute/modifiers/index.js +7 -0
- package/dist/translator/tag/attribute/modifiers/no-update.js +14 -0
- package/dist/translator/tag/attribute/modifiers/scoped.js +23 -0
- package/dist/translator/tag/attribute-tag.js +149 -0
- package/dist/translator/tag/custom-tag.js +146 -0
- package/dist/translator/tag/dynamic-tag.js +74 -0
- package/dist/translator/tag/index.js +287 -0
- package/dist/translator/tag/macro-tag.js +7 -0
- package/dist/translator/tag/native-tag.js +27 -0
- package/dist/translator/tag/native-tag[html]/attributes.js +151 -0
- package/dist/translator/tag/native-tag[html]/index.js +221 -0
- package/dist/translator/tag/native-tag[vdom]/attributes.js +105 -0
- package/dist/translator/tag/native-tag[vdom]/index.js +189 -0
- package/dist/translator/tag/util.js +246 -0
- package/dist/translator/taglib/core/conditional/translate-else-if.js +20 -0
- package/dist/translator/taglib/core/conditional/translate-else.js +20 -0
- package/dist/translator/taglib/core/conditional/translate-if.js +8 -0
- package/dist/translator/taglib/core/conditional/util.js +41 -0
- package/dist/translator/taglib/core/index.js +474 -0
- package/dist/translator/taglib/core/macro/parse.js +17 -0
- package/dist/translator/taglib/core/macro/translate.js +48 -0
- package/dist/translator/taglib/core/parse-class.js +79 -0
- package/dist/translator/taglib/core/parse-export.js +14 -0
- package/dist/translator/taglib/core/parse-import.js +14 -0
- package/dist/translator/taglib/core/parse-module-code.js +18 -0
- package/dist/translator/taglib/core/parse-static.js +18 -0
- package/dist/translator/taglib/core/transform-style.js +66 -0
- package/dist/translator/taglib/core/translate-await.js +41 -0
- package/dist/translator/taglib/core/translate-body.js +17 -0
- package/dist/translator/taglib/core/translate-for.js +156 -0
- package/dist/translator/taglib/core/translate-html-comment.js +52 -0
- package/dist/translator/taglib/core/translate-include-content.js +53 -0
- package/dist/translator/taglib/core/translate-server-only.js +5 -0
- package/dist/translator/taglib/core/translate-while.js +32 -0
- package/dist/translator/taglib/index.js +6 -0
- package/dist/translator/taglib/migrate/all-templates.js +46 -0
- package/dist/translator/taglib/migrate/index.js +5 -0
- package/dist/translator/text/index.js +10 -0
- package/dist/translator/text/index[html].js +12 -0
- package/dist/translator/text/index[vdom].js +20 -0
- package/dist/translator/util/add-dependencies.js +329 -0
- package/dist/translator/util/escape-regexp.js +4 -0
- package/dist/translator/util/get-component-files.js +86 -0
- package/dist/translator/util/html-out-write.js +15 -0
- package/dist/translator/util/key-manager.js +176 -0
- package/dist/translator/util/optimize-html-writes.js +52 -0
- package/dist/translator/util/optimize-vdom-create.js +164 -0
- package/dist/translator/util/plugin-hooks.js +22 -0
- package/dist/translator/util/runtime-flags.js +3 -0
- package/dist/translator/util/vdom-out-write.js +10 -0
- package/dist/translator/util/with-previous-location.js +6 -0
- package/package.json +7 -4
- package/src/taglib/index.js +2 -2
- package/src/translator/cdata/index.js +15 -0
- package/src/translator/cdata/index[html].js +15 -0
- package/src/translator/cdata/index[vdom].js +12 -0
- package/src/translator/class.js +65 -0
- package/src/translator/comment/index.js +15 -0
- package/src/translator/comment/index[html].js +17 -0
- package/src/translator/comment/index[vdom].js +3 -0
- package/src/translator/declaration/index.js +15 -0
- package/src/translator/declaration/index[html].js +12 -0
- package/src/translator/declaration/index[vdom].js +3 -0
- package/src/translator/document-type/index.js +15 -0
- package/src/translator/document-type/index[html].js +12 -0
- package/src/translator/document-type/index[vdom].js +3 -0
- package/src/translator/index.js +551 -0
- package/src/translator/placeholder/index.js +15 -0
- package/src/translator/placeholder/index[html].js +93 -0
- package/src/translator/placeholder/index[vdom].js +22 -0
- package/src/translator/scriptlet.js +4 -0
- package/src/translator/tag/attribute/directives/class.js +42 -0
- package/src/translator/tag/attribute/directives/index.js +15 -0
- package/src/translator/tag/attribute/directives/no-update-body-if.js +15 -0
- package/src/translator/tag/attribute/directives/no-update-body.js +10 -0
- package/src/translator/tag/attribute/directives/no-update-if.js +12 -0
- package/src/translator/tag/attribute/directives/no-update.js +48 -0
- package/src/translator/tag/attribute/directives/style.js +42 -0
- package/src/translator/tag/attribute/index.js +150 -0
- package/src/translator/tag/attribute/modifiers/index.js +7 -0
- package/src/translator/tag/attribute/modifiers/no-update.js +14 -0
- package/src/translator/tag/attribute/modifiers/scoped.js +23 -0
- package/src/translator/tag/attribute-tag.js +149 -0
- package/src/translator/tag/custom-tag.js +146 -0
- package/src/translator/tag/dynamic-tag.js +74 -0
- package/src/translator/tag/index.js +287 -0
- package/src/translator/tag/macro-tag.js +7 -0
- package/src/translator/tag/native-tag.js +27 -0
- package/src/translator/tag/native-tag[html]/attributes.js +151 -0
- package/src/translator/tag/native-tag[html]/index.js +221 -0
- package/src/translator/tag/native-tag[vdom]/attributes.js +105 -0
- package/src/translator/tag/native-tag[vdom]/index.js +189 -0
- package/src/translator/tag/util.js +246 -0
- package/src/translator/taglib/core/conditional/translate-else-if.js +20 -0
- package/src/translator/taglib/core/conditional/translate-else.js +20 -0
- package/src/translator/taglib/core/conditional/translate-if.js +8 -0
- package/src/translator/taglib/core/conditional/util.js +41 -0
- package/src/translator/taglib/core/index.js +474 -0
- package/src/translator/taglib/core/macro/parse.js +17 -0
- package/src/translator/taglib/core/macro/translate.js +48 -0
- package/src/translator/taglib/core/parse-class.js +79 -0
- package/src/translator/taglib/core/parse-export.js +14 -0
- package/src/translator/taglib/core/parse-import.js +14 -0
- package/src/translator/taglib/core/parse-module-code.js +18 -0
- package/src/translator/taglib/core/parse-static.js +18 -0
- package/src/translator/taglib/core/transform-style.js +66 -0
- package/src/translator/taglib/core/translate-await.js +41 -0
- package/src/translator/taglib/core/translate-body.js +17 -0
- package/src/translator/taglib/core/translate-for.js +156 -0
- package/src/translator/taglib/core/translate-html-comment.js +52 -0
- package/src/translator/taglib/core/translate-include-content.js +53 -0
- package/src/translator/taglib/core/translate-server-only.js +5 -0
- package/src/translator/taglib/core/translate-while.js +32 -0
- package/src/translator/taglib/index.js +7 -0
- package/src/translator/taglib/migrate/all-templates.js +46 -0
- package/src/translator/taglib/migrate/index.js +5 -0
- package/src/translator/text/index.js +10 -0
- package/src/translator/text/index[html].js +12 -0
- package/src/translator/text/index[vdom].js +20 -0
- package/src/translator/util/add-dependencies.js +329 -0
- package/src/translator/util/escape-regexp.js +4 -0
- package/src/translator/util/get-component-files.js +86 -0
- package/src/translator/util/html-out-write.js +15 -0
- package/src/translator/util/key-manager.js +176 -0
- package/src/translator/util/optimize-html-writes.js +52 -0
- package/src/translator/util/optimize-vdom-create.js +164 -0
- package/src/translator/util/plugin-hooks.js +22 -0
- package/src/translator/util/runtime-flags.js +3 -0
- package/src/translator/util/vdom-out-write.js +10 -0
- package/src/translator/util/with-previous-location.js +6 -0
- package/translator/index.d.ts +7 -0
- package/translator/package.json +5 -0
|
@@ -9,7 +9,7 @@ var registry = require("@internal/components-registry");
|
|
|
9
9
|
var jQuery = require("../../../runtime/components/legacy/jquery");
|
|
10
10
|
var ready = require("../../../runtime/components/legacy/ready");
|
|
11
11
|
// eslint-disable-next-line no-constant-binary-expression
|
|
12
|
-
|
|
12
|
+
var complain = "MARKO_DEBUG" && require("complain");
|
|
13
13
|
var hasHowOwnProperty = {}.hasOwnProperty;
|
|
14
14
|
var stateToJSONDef = {
|
|
15
15
|
enumerable: false,
|
|
@@ -22,7 +22,7 @@ function noop() {}
|
|
|
22
22
|
module.exports = function defineWidget(def, renderer) {
|
|
23
23
|
def = def.Widget || def;
|
|
24
24
|
|
|
25
|
-
if (def.
|
|
25
|
+
if (def.___isComponent) {
|
|
26
26
|
return def;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -52,7 +52,7 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
52
52
|
BaseComponent.call(this, id, doc);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (!proto.
|
|
55
|
+
if (!proto.___isComponent) {
|
|
56
56
|
// Inherit from Component if they didn't already
|
|
57
57
|
ComponentClass.prototype = Object.create(BaseComponent.prototype);
|
|
58
58
|
for (var propName in proto) {
|
|
@@ -65,16 +65,16 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
65
65
|
// The same prototype will be used by our constructor after
|
|
66
66
|
// we he have set up the prototype chain using the inherit function
|
|
67
67
|
proto = Component.prototype = ComponentClass.prototype;
|
|
68
|
-
proto.
|
|
68
|
+
proto.___isLegacy = true;
|
|
69
69
|
|
|
70
70
|
proto.constructor = def.constructor = Component;
|
|
71
71
|
|
|
72
72
|
Object.defineProperty(proto, "state", {
|
|
73
73
|
get: function () {
|
|
74
|
-
var raw = this.
|
|
74
|
+
var raw = this.___state && this.___state.___raw;
|
|
75
75
|
|
|
76
76
|
if (raw && !raw.toJSON) {
|
|
77
|
-
Object.defineProperty(this.
|
|
77
|
+
Object.defineProperty(this.___state.___raw, "toJSON", stateToJSONDef);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
return raw;
|
|
@@ -82,17 +82,17 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
82
82
|
set: function (newState) {
|
|
83
83
|
newState = newState || {};
|
|
84
84
|
// eslint-disable-next-line no-constant-condition
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
if ("MARKO_DEBUG") {
|
|
86
|
+
if (
|
|
87
|
+
Object.keys(newState).sort().join("") !==
|
|
88
|
+
Object.keys(this.___state && this.___state.___raw || {}).
|
|
89
|
+
sort().
|
|
90
|
+
join(""))
|
|
91
|
+
|
|
92
|
+
complain(
|
|
93
|
+
"'widget.state = newState' has changed from merging the newState to replacing the old state."
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
this.setState(newState);
|
|
98
98
|
}
|
|
@@ -101,58 +101,58 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
101
101
|
Object.defineProperty(proto, "__document", {
|
|
102
102
|
get: function () {
|
|
103
103
|
// eslint-disable-next-line no-constant-condition
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return this.
|
|
104
|
+
if ("MARKO_DEBUG") {
|
|
105
|
+
complain("__document is deprecated");
|
|
106
|
+
}
|
|
107
|
+
return this.___host;
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
Object.defineProperty(proto, "el", {
|
|
112
112
|
get: function () {
|
|
113
113
|
// eslint-disable-next-line no-constant-condition
|
|
114
|
+
if ("MARKO_DEBUG") {
|
|
115
|
+
if (
|
|
116
|
+
this.___currentLegacyBindEl !== (
|
|
117
|
+
this.___rootNode && this.___rootNode.firstChild))
|
|
118
|
+
{
|
|
119
|
+
complain(
|
|
120
|
+
"this.el no longer returns the `w-bind` element and instead returns the first node in the template. Assign a key to the w-bind element and use getEl(key) instead."
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
114
124
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return this.D_;
|
|
125
|
+
return this.___currentLegacyBindEl;
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
// get legacy methods
|
|
130
130
|
|
|
131
|
-
proto.
|
|
131
|
+
proto.___legacyOnRender = proto.onRender;
|
|
132
132
|
Object.defineProperty(proto, "onRender", {
|
|
133
133
|
get: noop,
|
|
134
134
|
set: function (v) {
|
|
135
|
-
proto.
|
|
135
|
+
proto.___legacyOnRender = v;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
proto.
|
|
139
|
+
proto.___legacyOnUpdate = proto.onUpdate;
|
|
140
140
|
Object.defineProperty(proto, "onUpdate", {
|
|
141
141
|
get: function () {
|
|
142
142
|
return modernMountOrUpdate;
|
|
143
143
|
},
|
|
144
144
|
set: function (v) {
|
|
145
|
-
proto.
|
|
145
|
+
proto.___legacyOnUpdate = v;
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
proto.
|
|
149
|
+
proto.___legacyOnDestroy = proto.onDestroy;
|
|
150
150
|
Object.defineProperty(proto, "onDestroy", {
|
|
151
151
|
get: function () {
|
|
152
152
|
return modernOnDestory;
|
|
153
153
|
},
|
|
154
154
|
set: function (v) {
|
|
155
|
-
proto.
|
|
155
|
+
proto.___legacyOnDestroy = v;
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
|
|
@@ -161,110 +161,110 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
161
161
|
proto.onMount = modernMountOrUpdate;
|
|
162
162
|
|
|
163
163
|
if (legacyInit) {
|
|
164
|
-
proto.
|
|
164
|
+
proto.___legacyInit = legacyInit;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// convert legacy to modern
|
|
168
|
-
proto.
|
|
168
|
+
proto.___modernUpdate = proto.update;
|
|
169
169
|
proto.update = function () {
|
|
170
|
-
if (this.
|
|
170
|
+
if (this.___destroyed) {
|
|
171
171
|
// eslint-disable-next-line no-constant-condition
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
172
|
+
if ("MARKO_DEBUG") {
|
|
173
|
+
complain(
|
|
174
|
+
"widget was updated after it was destroyed, if this widget is migrated to a modern component this will become a noop.",
|
|
175
|
+
{
|
|
176
|
+
location: this.___type
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
180
|
|
|
181
181
|
this.destroy = modernOnDestory;
|
|
182
|
-
this.
|
|
182
|
+
this.___destroyed = false;
|
|
183
183
|
}
|
|
184
|
-
this.
|
|
185
|
-
if (this.
|
|
184
|
+
this.___legacyExplicitUpdate = true;
|
|
185
|
+
if (this.___currentLegacyBindEl) {
|
|
186
186
|
this.onBeforeUpdate && this.onBeforeUpdate();
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
this.
|
|
190
|
-
this.
|
|
189
|
+
this.___modernUpdate();
|
|
190
|
+
this.___legacyExplicitUpdate = false;
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
function modernMountOrUpdate() {
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
195
195
|
var self = this;
|
|
196
|
-
var el = this.
|
|
197
|
-
var prevEl = this.
|
|
196
|
+
var el = this.___keyedElements["@_wbind"];
|
|
197
|
+
var prevEl = this.___currentLegacyBindEl;
|
|
198
198
|
|
|
199
199
|
if (prevEl !== el) {
|
|
200
|
-
this.
|
|
200
|
+
this.___currentLegacyBindEl = el;
|
|
201
201
|
|
|
202
202
|
if (prevEl) {
|
|
203
203
|
this.onBeforeDestroy && this.onBeforeDestroy();
|
|
204
|
-
this.
|
|
205
|
-
this.
|
|
204
|
+
this.___legacyOnDestroy && this.___legacyOnDestroy();
|
|
205
|
+
this.___legacyRender = undefined;
|
|
206
206
|
this.removeAllListeners();
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
if (el) {
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
210
|
+
this.___legacyInit && this.___legacyInit(this.widgetConfig || {});
|
|
211
|
+
this.___legacyOnRender && this.___legacyOnRender({ firstRender: true });
|
|
212
|
+
this.___legacyRender = legacyRender;
|
|
213
213
|
|
|
214
214
|
// eslint-disable-next-line no-constant-condition
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
215
|
+
if ("MARKO_DEBUG") {
|
|
216
|
+
Object.defineProperty(el, "__widget", {
|
|
217
|
+
configurable: true,
|
|
218
|
+
get: function () {
|
|
219
|
+
complain("__widget is deprecated");
|
|
220
|
+
return self;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
el.__widget = this;
|
|
225
|
+
}
|
|
226
226
|
}
|
|
227
227
|
} else if (el) {
|
|
228
228
|
if (prevEl) {
|
|
229
|
-
this.
|
|
229
|
+
this.___legacyOnUpdate && this.___legacyOnUpdate();
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
if (this.
|
|
233
|
-
this.
|
|
234
|
-
this.
|
|
232
|
+
if (this.___didUpdate) {
|
|
233
|
+
this.___legacyOnRender &&
|
|
234
|
+
this.___legacyOnRender({ firstRender: false });
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
this.
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
238
|
+
this.___widgetProps = this.___input;
|
|
239
|
+
this.___input = null;
|
|
240
|
+
this.___didUpdate = false;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
function legacyRender() {
|
|
244
|
-
if (!this.
|
|
244
|
+
if (!this.___legacyExplicitUpdate) {
|
|
245
245
|
this.onBeforeUpdate && this.onBeforeUpdate();
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
this.
|
|
248
|
+
this.___didUpdate = true;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
function modernOnDestory() {
|
|
252
|
-
if (this.
|
|
252
|
+
if (this.___currentLegacyBindEl) {
|
|
253
253
|
this.onBeforeDestroy && this.onBeforeDestroy();
|
|
254
|
-
this.
|
|
255
|
-
this.
|
|
254
|
+
this.___legacyOnDestroy && this.___legacyOnDestroy();
|
|
255
|
+
this.___currentLegacyBindEl = null;
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
// Set a flag on the constructor function to make it clear this is
|
|
260
260
|
// a component so that we can short-circuit this work later
|
|
261
|
-
Component.
|
|
261
|
+
Component.___isComponent = true;
|
|
262
262
|
|
|
263
263
|
function State() {
|
|
264
264
|
BaseState.apply(this, arguments);
|
|
265
265
|
}
|
|
266
266
|
inherit(State, BaseState);
|
|
267
|
-
proto.
|
|
267
|
+
proto.___State = State;
|
|
268
268
|
|
|
269
269
|
jQuery.patchComponent(
|
|
270
270
|
window.$,
|
|
@@ -299,22 +299,22 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
299
299
|
if (renderer) {
|
|
300
300
|
// Add the rendering related methods as statics on the
|
|
301
301
|
// new component constructor function
|
|
302
|
-
Component.renderer = proto.
|
|
302
|
+
Component.renderer = proto.___renderer = renderer;
|
|
303
303
|
Component.render = renderer.render;
|
|
304
304
|
Component.renderSync = renderer.renderSync;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
// eslint-disable-next-line no-constant-condition
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
308
|
+
if ("MARKO_DEBUG") {
|
|
309
|
+
Object.defineProperty(Component, "_isWidget", {
|
|
310
|
+
get: function () {
|
|
311
|
+
complain("_isWidget is deprecated");
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
} else {
|
|
316
|
+
Component._isWidget = true;
|
|
317
|
+
}
|
|
318
318
|
|
|
319
319
|
var template = def.template;
|
|
320
320
|
if (template) {
|
|
@@ -322,7 +322,7 @@ module.exports = function defineWidget(def, renderer) {
|
|
|
322
322
|
template = req(template);
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
registry.r((template.default || template).
|
|
325
|
+
registry.r((template.default || template).___typeName, function () {
|
|
326
326
|
return Component;
|
|
327
327
|
});
|
|
328
328
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";module.exports = function defineWidget(def, renderer) {
|
|
2
|
-
if (def.
|
|
2
|
+
if (def.___isComponent) {
|
|
3
3
|
return def;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
if (renderer) {
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
___isComponent: true,
|
|
9
9
|
_isWidget: true,
|
|
10
10
|
renderer: renderer,
|
|
11
11
|
render: renderer.render,
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
template: renderer.template
|
|
14
14
|
};
|
|
15
15
|
} else {
|
|
16
|
-
return {
|
|
16
|
+
return { ___isComponent: true, _isWidget: true };
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var ComponentsContext = require("../../../runtime/components/ComponentsContext");
|
|
4
|
-
var getComponentsContext = ComponentsContext.
|
|
4
|
+
var getComponentsContext = ComponentsContext.___getComponentsContext;
|
|
5
5
|
|
|
6
6
|
module.exports = function endComponent(out, componentDef) {
|
|
7
|
-
if (componentDef.
|
|
7
|
+
if (componentDef.___renderBoundary) {
|
|
8
8
|
out.w("<!--" + out.global.runtimeId + "/-->");
|
|
9
|
-
getComponentsContext(out).
|
|
9
|
+
getComponentsContext(out).___isPreserved = componentDef.___parentPreserved;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
var registry = require("@internal/components-registry");
|
|
3
3
|
|
|
4
4
|
exports.getComponentForEl =
|
|
5
|
-
require("@internal/components-util").
|
|
6
|
-
exports.init = registry.
|
|
5
|
+
require("@internal/components-util").___getComponentForEl;
|
|
6
|
+
exports.init = registry.___initServerRendered;
|
|
7
7
|
exports.register = function (id, component) {
|
|
8
8
|
registry.r(id, function () {
|
|
9
9
|
return component;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require("../../../runtime/html/marko-namespace");
|
|
3
3
|
|
|
4
4
|
var warp10 = require("warp10");
|
|
5
|
-
var w10ToJSON = require("../../../runtime/helpers/serialize-noop").
|
|
5
|
+
var w10ToJSON = require("../../../runtime/helpers/serialize-noop").___toJSON;
|
|
6
6
|
var safeJSONRegExp = /<\/|\u2028|\u2029/g;
|
|
7
7
|
var IGNORE_GLOBAL_TYPES = new Set(["undefined", "function", "symbol"]);
|
|
8
8
|
var DEFAULT_RUNTIME_ID = "M";
|
|
@@ -60,23 +60,23 @@ function getSerializedGlobals($global) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
63
|
-
var components = componentsContext.
|
|
63
|
+
var components = componentsContext.___components;
|
|
64
64
|
|
|
65
65
|
var len = components.length;
|
|
66
66
|
|
|
67
67
|
for (var i = 0; i < len; i++) {
|
|
68
68
|
var componentDef = components[i];
|
|
69
69
|
var id = componentDef.id;
|
|
70
|
-
var component = componentDef.
|
|
71
|
-
var flags = componentDef.
|
|
72
|
-
var isLegacy = componentDef.
|
|
70
|
+
var component = componentDef.___component;
|
|
71
|
+
var flags = componentDef.___flags;
|
|
72
|
+
var isLegacy = componentDef.___isLegacy;
|
|
73
73
|
|
|
74
74
|
var state = component.state;
|
|
75
75
|
var input = component.input || 0;
|
|
76
76
|
var typeName = component.typeName;
|
|
77
|
-
var customEvents = component.
|
|
78
|
-
var scope = component.
|
|
79
|
-
var bubblingDomEvents = component.
|
|
77
|
+
var customEvents = component.___customEvents;
|
|
78
|
+
var scope = component.___scope;
|
|
79
|
+
var bubblingDomEvents = component.___bubblingDomEvents;
|
|
80
80
|
|
|
81
81
|
var needsState;
|
|
82
82
|
var serializedProps;
|
|
@@ -84,7 +84,7 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
|
84
84
|
|
|
85
85
|
if (isLegacy) {
|
|
86
86
|
flags |= FLAG_IS_LEGACY;
|
|
87
|
-
renderBody = component.
|
|
87
|
+
renderBody = component.___widgetBody;
|
|
88
88
|
|
|
89
89
|
if (component.widgetConfig && isNotEmpty(component.widgetConfig)) {
|
|
90
90
|
serializedProps = component.widgetConfig;
|
|
@@ -96,16 +96,16 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
|
96
96
|
!(flags & FLAG_WILL_RERENDER_IN_BROWSER) ||
|
|
97
97
|
flags & FLAG_OLD_HYDRATE_NO_CREATE)
|
|
98
98
|
{
|
|
99
|
-
component.
|
|
100
|
-
component.
|
|
99
|
+
component.___state = undefined; // We don't use `delete` to avoid V8 deoptimization
|
|
100
|
+
component.___input = undefined; // We don't use `delete` to avoid V8 deoptimization
|
|
101
101
|
component.typeName = undefined;
|
|
102
102
|
component.id = undefined;
|
|
103
|
-
component.
|
|
104
|
-
component.
|
|
105
|
-
component.
|
|
106
|
-
component.
|
|
107
|
-
component.
|
|
108
|
-
component.
|
|
103
|
+
component.___customEvents = undefined;
|
|
104
|
+
component.___scope = undefined;
|
|
105
|
+
component.___bubblingDomEvents = undefined;
|
|
106
|
+
component.___bubblingDomEventsExtraArgsCount = undefined;
|
|
107
|
+
component.___updatedInput = undefined;
|
|
108
|
+
component.___updateQueued = undefined;
|
|
109
109
|
|
|
110
110
|
needsState = true;
|
|
111
111
|
|
|
@@ -145,7 +145,7 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
|
145
145
|
|
|
146
146
|
var extra = {
|
|
147
147
|
b: bubblingDomEvents,
|
|
148
|
-
d: componentDef.
|
|
148
|
+
d: componentDef.___domEvents,
|
|
149
149
|
e: customEvents,
|
|
150
150
|
f: flags || undefined,
|
|
151
151
|
p: customEvents && scope, // Only serialize scope if we need to attach custom events
|
|
@@ -174,7 +174,7 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
|
174
174
|
components.length = 0;
|
|
175
175
|
|
|
176
176
|
// Also add any components from nested contexts
|
|
177
|
-
var nestedContexts = componentsContext.
|
|
177
|
+
var nestedContexts = componentsContext.___nestedContexts;
|
|
178
178
|
if (nestedContexts !== undefined) {
|
|
179
179
|
nestedContexts.forEach(function (nestedContext) {
|
|
180
180
|
addComponentsFromContext(nestedContext, componentsToHydrate);
|
|
@@ -185,8 +185,8 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
|
185
185
|
function getInitComponentsData(out, componentDefs) {
|
|
186
186
|
const len = componentDefs.length;
|
|
187
187
|
const $global = out.global;
|
|
188
|
-
const isLast = $global.
|
|
189
|
-
const didSerializeComponents = $global.
|
|
188
|
+
const isLast = $global.___isLastFlush;
|
|
189
|
+
const didSerializeComponents = $global.___didSerializeComponents;
|
|
190
190
|
const prefix = $global.componentIdPrefix || $global.widgetIdPrefix;
|
|
191
191
|
|
|
192
192
|
if (len === 0) {
|
|
@@ -199,7 +199,7 @@ function getInitComponentsData(out, componentDefs) {
|
|
|
199
199
|
|
|
200
200
|
const TYPE_INDEX = 1;
|
|
201
201
|
const typesLookup =
|
|
202
|
-
$global.
|
|
202
|
+
$global.___typesLookup || ($global.___typesLookup = new Map());
|
|
203
203
|
let newTypes;
|
|
204
204
|
|
|
205
205
|
for (let i = 0; i < len; i++) {
|
|
@@ -224,7 +224,7 @@ function getInitComponentsData(out, componentDefs) {
|
|
|
224
224
|
let serializedGlobals;
|
|
225
225
|
|
|
226
226
|
if (!didSerializeComponents) {
|
|
227
|
-
$global.
|
|
227
|
+
$global.___didSerializeComponents = true;
|
|
228
228
|
serializedGlobals = getSerializedGlobals($global);
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -238,7 +238,7 @@ function getInitComponentsData(out, componentDefs) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
function getInitComponentsDataFromOut(out) {
|
|
241
|
-
const componentsContext = out.
|
|
241
|
+
const componentsContext = out.___components;
|
|
242
242
|
|
|
243
243
|
if (componentsContext === null) {
|
|
244
244
|
return;
|
|
@@ -249,9 +249,9 @@ function getInitComponentsDataFromOut(out) {
|
|
|
249
249
|
const componentsToHydrate = [];
|
|
250
250
|
addComponentsFromContext(componentsContext, componentsToHydrate);
|
|
251
251
|
|
|
252
|
-
$global.
|
|
252
|
+
$global.___isLastFlush = true;
|
|
253
253
|
const data = getInitComponentsData(out, componentsToHydrate);
|
|
254
|
-
$global.
|
|
254
|
+
$global.___isLastFlush = undefined;
|
|
255
255
|
|
|
256
256
|
if (runtimeId !== DEFAULT_RUNTIME_ID && data) {
|
|
257
257
|
data.r = runtimeId;
|
|
@@ -261,10 +261,10 @@ function getInitComponentsDataFromOut(out) {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
function writeInitComponentsCode(out) {
|
|
264
|
-
out.script(exports.
|
|
264
|
+
out.script(exports.___getInitComponentsCode(out));
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
exports.
|
|
267
|
+
exports.___getInitComponentsCode = function getInitComponentsCode(
|
|
268
268
|
out,
|
|
269
269
|
componentDefs)
|
|
270
270
|
{
|
|
@@ -286,7 +286,7 @@ componentDefs)
|
|
|
286
286
|
)})`;
|
|
287
287
|
};
|
|
288
288
|
|
|
289
|
-
exports.
|
|
289
|
+
exports.___addComponentsFromContext = addComponentsFromContext;
|
|
290
290
|
exports.writeInitComponentsCode = writeInitComponentsCode;
|
|
291
291
|
|
|
292
292
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";var Component = require("../../../runtime/components/Component");
|
|
2
2
|
var req = require("@internal/require");
|
|
3
3
|
var getComponentForEl =
|
|
4
|
-
require("@internal/components-util").
|
|
4
|
+
require("@internal/components-util").___getComponentForEl;
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line no-constant-binary-expression
|
|
7
|
-
|
|
7
|
+
var complain = "MARKO_DEBUG" && require("complain");
|
|
8
8
|
|
|
9
9
|
// expose legacy
|
|
10
|
-
require("@internal/components-registry").
|
|
10
|
+
require("@internal/components-registry").___legacy = exports;
|
|
11
11
|
exports.load = function (typeName) {
|
|
12
12
|
return exports.defineWidget(req(typeName));
|
|
13
13
|
};
|
|
@@ -35,14 +35,14 @@ exports.getWidgetForEl = exports.get = function (elOrId) {
|
|
|
35
35
|
return getComponentForEl(el);
|
|
36
36
|
};
|
|
37
37
|
exports.initWidgets =
|
|
38
|
-
require("@internal/components-registry").
|
|
38
|
+
require("@internal/components-registry").___initServerRendered;
|
|
39
39
|
|
|
40
40
|
// monkey patch Widget
|
|
41
41
|
if (Widget) {
|
|
42
42
|
var WidgetProto = Widget.prototype;
|
|
43
43
|
WidgetProto.setProps = function (newInput) {
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
44
|
+
this.___isReceivingNewInput = true;
|
|
45
|
+
this.___setInput(newInput);
|
|
46
46
|
};
|
|
47
47
|
WidgetProto.rerender = function (newInput) {
|
|
48
48
|
if (newInput) {
|
|
@@ -58,19 +58,19 @@ var RenderResult = require("../../../runtime/RenderResult");
|
|
|
58
58
|
|
|
59
59
|
RenderResult.prototype.getWidget = function () {
|
|
60
60
|
// eslint-disable-next-line no-constant-condition
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if ("MARKO_DEBUG") {
|
|
62
|
+
complain("getWidget is deprecated. use getComponent instead.");
|
|
63
|
+
}
|
|
64
64
|
return this.getWidgets()[0];
|
|
65
65
|
};
|
|
66
66
|
RenderResult.prototype.getWidgets = function () {
|
|
67
67
|
// eslint-disable-next-line no-constant-condition
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
if ("MARKO_DEBUG") {
|
|
69
|
+
complain("getWidgets is deprecated. use getComponents instead.");
|
|
70
|
+
}
|
|
71
71
|
return RenderResult.prototype.getComponents.
|
|
72
72
|
apply(this, arguments).
|
|
73
73
|
filter(function (component) {
|
|
74
|
-
return component.
|
|
74
|
+
return component.___isLegacy;
|
|
75
75
|
});
|
|
76
76
|
};
|
|
@@ -12,5 +12,5 @@ exports.writeInitWidgetsCode = modernMarko.writeInitComponentsCode;
|
|
|
12
12
|
exports.getRenderedWidgets = exports.getRenderedWidgetIds =
|
|
13
13
|
modernMarko.getRenderedComponents;
|
|
14
14
|
exports.getInitWidgetsCode = function (out) {
|
|
15
|
-
return modernMarko.
|
|
15
|
+
return modernMarko.___getInitComponentsCode(out);
|
|
16
16
|
};
|