marko 5.29.2 → 5.30.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/README.md +1 -1
- package/bin/markoc.js +18 -18
- package/dist/core-tags/core/await/renderer.js +5 -1
- package/dist/node_modules/@internal/components-beginComponent/index.js +13 -3
- package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +331 -0
- package/dist/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
- package/dist/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
- package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
- package/dist/node_modules/@internal/components-entry/index.js +73 -45
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
- package/dist/node_modules/@internal/components-entry-legacy/index.js +15 -0
- package/dist/node_modules/@internal/components-entry-legacy/package.json +11 -0
- package/dist/node_modules/@internal/components-registry/index-browser.js +70 -43
- package/dist/node_modules/@internal/components-registry/index.js +2 -2
- package/dist/node_modules/@internal/components-util/index-browser.js +17 -17
- package/dist/node_modules/@internal/components-util/index.js +18 -8
- 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/set-immediate/index-browser.js +1 -1
- package/dist/node_modules/@internal/set-immediate/index-worker.js +2 -2
- package/dist/node_modules/@internal/set-immediate/index.js +2 -2
- package/dist/runtime/RenderResult.js +3 -3
- package/dist/runtime/components/Component.js +146 -148
- package/dist/runtime/components/ComponentDef.js +41 -27
- package/dist/runtime/components/ComponentsContext.js +6 -6
- package/dist/runtime/components/GlobalComponentsContext.js +3 -3
- package/dist/runtime/components/KeySequence.js +3 -3
- package/dist/runtime/components/ServerComponent.js +13 -13
- package/dist/runtime/components/State.js +27 -27
- package/dist/runtime/components/attach-detach.js +7 -7
- 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/browser.json +9 -0
- package/dist/runtime/components/legacy/defineComponent-legacy.js +32 -0
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +171 -0
- package/dist/runtime/components/legacy/defineWidget-legacy.js +1 -0
- package/dist/runtime/components/legacy/dependencies/html.js +3 -0
- package/dist/runtime/components/legacy/dependencies/index.js +178 -0
- package/dist/runtime/components/legacy/dependencies/vdom.js +3 -0
- package/dist/runtime/components/legacy/index.js +1 -0
- package/dist/runtime/components/legacy/jquery.js +51 -0
- package/dist/runtime/components/legacy/ready.js +152 -0
- package/dist/runtime/components/legacy/renderer-legacy.js +230 -0
- package/dist/runtime/components/renderer.js +30 -26
- package/dist/runtime/components/update-manager.js +10 -10
- 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 +7 -9
- package/dist/runtime/helpers/style-value.js +7 -2
- package/dist/runtime/html/AsyncStream.js +20 -20
- package/dist/runtime/html/BufferedWriter.js +2 -2
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +19 -6
- package/dist/runtime/html/helpers/attrs.js +7 -0
- package/dist/runtime/html/helpers/data-marko.js +2 -2
- package/dist/runtime/html/helpers/escape-quotes.js +1 -1
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/html/helpers/merge-attrs.js +38 -7
- package/dist/runtime/html/index.js +2 -2
- package/dist/runtime/renderable.js +9 -6
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +86 -86
- package/dist/runtime/vdom/VComponent.js +3 -3
- package/dist/runtime/vdom/VDocumentFragment.js +7 -7
- package/dist/runtime/vdom/VElement.js +61 -50
- package/dist/runtime/vdom/VFragment.js +8 -8
- package/dist/runtime/vdom/VNode.js +36 -36
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/attrs.js +24 -4
- package/dist/runtime/vdom/helpers/merge-attrs.js +16 -0
- package/dist/runtime/vdom/helpers/v-element.js +1 -1
- package/dist/runtime/vdom/helpers/v-text.js +1 -1
- package/dist/runtime/vdom/hot-reload.js +19 -19
- package/dist/runtime/vdom/index.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +5 -5
- package/dist/runtime/vdom/morphdom/helpers.js +5 -5
- package/dist/runtime/vdom/morphdom/index.js +56 -56
- package/dist/runtime/vdom/morphdom/specialElHandlers.js +7 -7
- package/dist/runtime/vdom/preserve-attrs.js +1 -1
- package/dist/runtime/vdom/vdom.js +14 -14
- package/docs/10-awesome-marko-features.md +1 -1
- package/docs/body-content.md +3 -3
- package/docs/class-components.md +6 -6
- package/docs/cloudflare-workers.md +3 -3
- package/docs/compiler.md +5 -5
- package/docs/express.md +2 -2
- package/docs/http.md +1 -1
- package/docs/koa.md +1 -1
- package/docs/lasso.md +1 -1
- package/docs/marko-vs-react.md +2 -2
- package/docs/rendering.md +6 -6
- package/docs/rollup.md +30 -30
- package/docs/troubleshooting-streaming.md +1 -1
- package/docs/typescript.md +1 -1
- package/docs/vite.md +3 -3
- package/docs/webpack.md +25 -25
- package/docs/why-is-marko-fast.md +2 -2
- package/index.d.ts +1 -0
- package/legacy-components-browser.marko +15 -0
- package/legacy-components.js +7 -0
- package/package.json +51 -45
- package/src/compiler/config.js +1 -1
- package/src/compiler/index.js +5 -5
- package/src/core-tags/core/__flush_here_and_after__.js +1 -1
- package/src/core-tags/core/await/AsyncValue.js +1 -1
- package/src/core-tags/core/await/renderer.js +8 -4
- package/src/core-tags/core/await/reorderer-renderer.js +1 -1
- package/src/node-require/browser-refresh.js +2 -2
- package/src/node-require/index.js +2 -2
- package/src/node_modules/@internal/components-beginComponent/index.js +16 -6
- package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +331 -0
- package/src/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
- package/src/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
- package/src/node_modules/@internal/components-entry/index.js +65 -37
- package/src/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
- package/src/node_modules/@internal/components-entry-legacy/index.js +15 -0
- package/src/node_modules/@internal/components-entry-legacy/package.json +11 -0
- package/src/node_modules/@internal/components-registry/index-browser.js +33 -6
- package/src/node_modules/@internal/components-util/index.js +10 -0
- package/src/runtime/RenderResult.js +3 -3
- package/src/runtime/components/Component.js +16 -18
- package/src/runtime/components/ComponentDef.js +22 -8
- package/src/runtime/components/ComponentsContext.js +1 -1
- package/src/runtime/components/State.js +2 -2
- package/src/runtime/components/attach-detach.js +1 -1
- package/src/runtime/components/dom-data.js +1 -1
- package/src/runtime/components/legacy/browser.json +9 -0
- package/src/runtime/components/legacy/defineComponent-legacy.js +32 -0
- package/src/runtime/components/legacy/defineRenderer-legacy.js +171 -0
- package/src/runtime/components/legacy/defineWidget-legacy.js +1 -0
- package/src/runtime/components/legacy/dependencies/html.js +3 -0
- package/src/runtime/components/legacy/dependencies/index.js +178 -0
- package/src/runtime/components/legacy/dependencies/vdom.js +3 -0
- package/src/runtime/components/legacy/index.js +1 -0
- package/src/runtime/components/legacy/jquery.js +51 -0
- package/src/runtime/components/legacy/ready.js +152 -0
- package/src/runtime/components/legacy/renderer-legacy.js +230 -0
- package/src/runtime/components/renderer.js +4 -0
- package/src/runtime/components/update-manager.js +1 -1
- package/src/runtime/dom-insert.js +1 -1
- package/src/runtime/helpers/dynamic-tag.js +2 -4
- package/src/runtime/helpers/style-value.js +7 -2
- package/src/runtime/html/AsyncStream.js +5 -5
- package/src/runtime/html/BufferedWriter.js +1 -1
- package/src/runtime/html/StringWriter.js +1 -1
- package/src/runtime/html/helpers/attr.js +15 -2
- package/src/runtime/html/helpers/attrs.js +7 -0
- package/src/runtime/html/helpers/merge-attrs.js +38 -7
- package/src/runtime/html/hot-reload.js +1 -1
- package/src/runtime/html/index.js +2 -2
- package/src/runtime/renderable.js +5 -2
- package/src/runtime/vdom/AsyncVDOMBuilder.js +2 -2
- package/src/runtime/vdom/VComponent.js +1 -1
- package/src/runtime/vdom/VDocumentFragment.js +1 -1
- package/src/runtime/vdom/VElement.js +17 -6
- package/src/runtime/vdom/VFragment.js +1 -1
- package/src/runtime/vdom/VNode.js +1 -1
- package/src/runtime/vdom/VText.js +1 -1
- package/src/runtime/vdom/helpers/attrs.js +26 -6
- package/src/runtime/vdom/helpers/merge-attrs.js +16 -0
- package/src/runtime/vdom/hot-reload.js +1 -1
- package/src/runtime/vdom/index.js +2 -2
- package/src/runtime/vdom/morphdom/fragment.js +1 -1
- package/src/runtime/vdom/morphdom/specialElHandlers.js +1 -1
- package/src/taglib/index.js +1 -1
- package/tags-html.d.ts +9 -0
package/README.md
CHANGED
package/bin/markoc.js
CHANGED
|
@@ -25,7 +25,7 @@ var appModulePath = require("app-module-path");
|
|
|
25
25
|
var mmOptions = {
|
|
26
26
|
matchBase: true,
|
|
27
27
|
dot: true,
|
|
28
|
-
flipNegate: true
|
|
28
|
+
flipNegate: true,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
function relPath(path) {
|
|
@@ -38,55 +38,55 @@ var args = require("argly")
|
|
|
38
38
|
.createParser({
|
|
39
39
|
"--help": {
|
|
40
40
|
type: "boolean",
|
|
41
|
-
description: "Show this help message"
|
|
41
|
+
description: "Show this help message",
|
|
42
42
|
},
|
|
43
43
|
"--files --file -f *": {
|
|
44
44
|
type: "string[]",
|
|
45
|
-
description: "A set of directories or files to compile"
|
|
45
|
+
description: "A set of directories or files to compile",
|
|
46
46
|
},
|
|
47
47
|
"--ignore -i": {
|
|
48
48
|
type: "string[]",
|
|
49
|
-
description: 'An ignore rule (default: --ignore "/node_modules" ".*")'
|
|
49
|
+
description: 'An ignore rule (default: --ignore "/node_modules" ".*")',
|
|
50
50
|
},
|
|
51
51
|
"--clean -c": {
|
|
52
52
|
type: "boolean",
|
|
53
|
-
description: "Clean all of the *.marko.js files"
|
|
53
|
+
description: "Clean all of the *.marko.js files",
|
|
54
54
|
},
|
|
55
55
|
"--force": {
|
|
56
56
|
type: "boolean",
|
|
57
|
-
description: "Force template recompilation even if unchanged"
|
|
57
|
+
description: "Force template recompilation even if unchanged",
|
|
58
58
|
},
|
|
59
59
|
"--paths -p": {
|
|
60
60
|
type: "string[]",
|
|
61
61
|
description:
|
|
62
|
-
"Additional directories to add to the Node.js module search path"
|
|
62
|
+
"Additional directories to add to the Node.js module search path",
|
|
63
63
|
},
|
|
64
64
|
"--quiet -q": {
|
|
65
65
|
type: "boolean",
|
|
66
|
-
description: "Only print warnings and errors"
|
|
66
|
+
description: "Only print warnings and errors",
|
|
67
67
|
},
|
|
68
68
|
"--migrate -m": {
|
|
69
69
|
type: "boolean",
|
|
70
70
|
description:
|
|
71
|
-
"Run any migrations that exist for the provided template and write changes to disk"
|
|
71
|
+
"Run any migrations that exist for the provided template and write changes to disk",
|
|
72
72
|
},
|
|
73
73
|
"--strip-types -t": {
|
|
74
74
|
type: "boolean",
|
|
75
|
-
description: "Strip all type information from the compiled template"
|
|
75
|
+
description: "Strip all type information from the compiled template",
|
|
76
76
|
},
|
|
77
77
|
"--browser -b": {
|
|
78
78
|
type: "boolean",
|
|
79
|
-
description: "Browser output"
|
|
79
|
+
description: "Browser output",
|
|
80
80
|
},
|
|
81
81
|
"--source-maps -s": {
|
|
82
82
|
type: "string",
|
|
83
83
|
description:
|
|
84
|
-
"Output a sourcemap beside the compiled file. (use --source-maps inline for an inline source map)"
|
|
84
|
+
"Output a sourcemap beside the compiled file. (use --source-maps inline for an inline source map)",
|
|
85
85
|
},
|
|
86
86
|
"--version -v": {
|
|
87
87
|
type: "boolean",
|
|
88
|
-
description: "Print markoc and marko compiler versions to the console"
|
|
89
|
-
}
|
|
88
|
+
description: "Print markoc and marko compiler versions to the console",
|
|
89
|
+
},
|
|
90
90
|
})
|
|
91
91
|
.usage("Usage: $0 <pattern> [options]")
|
|
92
92
|
.example("Compile a single template", "$0 template.marko")
|
|
@@ -143,7 +143,7 @@ var compileOptions = {
|
|
|
143
143
|
stripTypes: args.stripTypes,
|
|
144
144
|
sourceMaps: args.sourceMaps || false,
|
|
145
145
|
compilerType: "markoc",
|
|
146
|
-
compilerVersion: markoPkgVersion || markocPkgVersion
|
|
146
|
+
compilerVersion: markoPkgVersion || markocPkgVersion,
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
var force = args.force;
|
|
@@ -242,7 +242,7 @@ function walk(files, options, done) {
|
|
|
242
242
|
done(null);
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
}
|
|
245
|
+
},
|
|
246
246
|
};
|
|
247
247
|
|
|
248
248
|
function doWalk(dir) {
|
|
@@ -316,7 +316,7 @@ if (args.clean) {
|
|
|
316
316
|
context.endAsync();
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
|
-
}
|
|
319
|
+
},
|
|
320
320
|
},
|
|
321
321
|
function () {
|
|
322
322
|
if (deleteCount === 0) {
|
|
@@ -420,7 +420,7 @@ if (args.clean) {
|
|
|
420
420
|
) {
|
|
421
421
|
compile(file, context);
|
|
422
422
|
}
|
|
423
|
-
}
|
|
423
|
+
},
|
|
424
424
|
},
|
|
425
425
|
function (err) {
|
|
426
426
|
if (err) {
|
|
@@ -220,7 +220,11 @@ function renderContents(err, data, input, out) {
|
|
|
220
220
|
if (err) {
|
|
221
221
|
if (input.catch) {
|
|
222
222
|
if (errorRenderer) {
|
|
223
|
-
|
|
223
|
+
try {
|
|
224
|
+
errorRenderer(out, err);
|
|
225
|
+
} catch (err2) {
|
|
226
|
+
out.error(err2);
|
|
227
|
+
}
|
|
224
228
|
}
|
|
225
229
|
} else {
|
|
226
230
|
out.error(err);
|
|
@@ -4,6 +4,7 @@ const ComponentDef = require("../../../runtime/components/ComponentDef");
|
|
|
4
4
|
|
|
5
5
|
var FLAG_WILL_RERENDER_IN_BROWSER = 1;
|
|
6
6
|
// var FLAG_HAS_RENDER_BODY = 2;
|
|
7
|
+
var FLAG_OLD_HYDRATE_NO_CREATE = 8;
|
|
7
8
|
|
|
8
9
|
module.exports = function beginComponent(
|
|
9
10
|
componentsContext,
|
|
@@ -11,14 +12,19 @@ component,
|
|
|
11
12
|
key,
|
|
12
13
|
ownerComponentDef,
|
|
13
14
|
isSplitComponent,
|
|
14
|
-
isImplicitComponent
|
|
15
|
+
isImplicitComponent,
|
|
16
|
+
existingComponentDef)
|
|
15
17
|
{
|
|
16
18
|
var componentId = component.id;
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
// existingComponentDef is only here to allow binding a conditional
|
|
21
|
+
// widget. It should be removed when the legacy compat layer is removed.
|
|
22
|
+
var componentDef =
|
|
23
|
+
existingComponentDef || (
|
|
24
|
+
componentsContext.k_ = new ComponentDef(
|
|
19
25
|
component,
|
|
20
26
|
componentId,
|
|
21
|
-
componentsContext);
|
|
27
|
+
componentsContext));
|
|
22
28
|
|
|
23
29
|
|
|
24
30
|
var ownerIsRenderBoundary =
|
|
@@ -54,6 +60,10 @@ isImplicitComponent)
|
|
|
54
60
|
componentsContext.p_ = false;
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
if (out.global.oldHydrateNoCreate === true) {
|
|
64
|
+
componentDef.C_ |= FLAG_OLD_HYDRATE_NO_CREATE;
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
if ((ownerIsRenderBoundary || ownerWillRerender) && key != null) {
|
|
58
68
|
out.w(
|
|
59
69
|
"<!--" +
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* jshint newcap:false */
|
|
3
|
+
|
|
4
|
+
var BaseState;
|
|
5
|
+
var BaseComponent;
|
|
6
|
+
var inherit;
|
|
7
|
+
var loader = require("@internal/loader");
|
|
8
|
+
var registry = require("@internal/components-registry");
|
|
9
|
+
var jQuery = require("../../../runtime/components/legacy/jquery");
|
|
10
|
+
var ready = require("../../../runtime/components/legacy/ready");
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var stateToJSONDef = {
|
|
14
|
+
enumerable: false,
|
|
15
|
+
value: function returnSelf() {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function noop() {}
|
|
20
|
+
|
|
21
|
+
module.exports = function defineWidget(def, renderer) {
|
|
22
|
+
def = def.Widget || def;
|
|
23
|
+
|
|
24
|
+
if (def.E_) {
|
|
25
|
+
return def;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var ComponentClass = function () {};
|
|
29
|
+
var proto;
|
|
30
|
+
var legacyInit;
|
|
31
|
+
|
|
32
|
+
if (typeof def === "function") {
|
|
33
|
+
proto = def.prototype;
|
|
34
|
+
legacyInit = def;
|
|
35
|
+
} else if (typeof def === "object") {
|
|
36
|
+
proto = def;
|
|
37
|
+
legacyInit = def.init;
|
|
38
|
+
} else {
|
|
39
|
+
throw TypeError();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ComponentClass.prototype = proto;
|
|
43
|
+
|
|
44
|
+
// We don't use the constructor provided by the user
|
|
45
|
+
// since we don't invoke their constructor until
|
|
46
|
+
// we have had a chance to do our own initialization.
|
|
47
|
+
// Instead, we store their constructor in the "initComponent"
|
|
48
|
+
// property and that method gets called later inside
|
|
49
|
+
// init-components-browser.js
|
|
50
|
+
function Component(id, doc) {
|
|
51
|
+
BaseComponent.call(this, id, doc);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!proto.E_) {
|
|
55
|
+
// Inherit from Component if they didn't already
|
|
56
|
+
ComponentClass.prototype = Object.create(BaseComponent.prototype);
|
|
57
|
+
for (var propName in proto) {
|
|
58
|
+
if (proto.hasOwnProperty(propName)) {
|
|
59
|
+
ComponentClass.prototype[propName] = proto[propName];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The same prototype will be used by our constructor after
|
|
65
|
+
// we he have set up the prototype chain using the inherit function
|
|
66
|
+
proto = Component.prototype = ComponentClass.prototype;
|
|
67
|
+
proto.F_ = true;
|
|
68
|
+
|
|
69
|
+
proto.constructor = def.constructor = Component;
|
|
70
|
+
|
|
71
|
+
Object.defineProperty(proto, "state", {
|
|
72
|
+
get: function () {
|
|
73
|
+
var raw = this.G_ && this.G_.H_;
|
|
74
|
+
|
|
75
|
+
if (raw && !raw.toJSON) {
|
|
76
|
+
Object.defineProperty(this.G_.H_, "toJSON", stateToJSONDef);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return raw;
|
|
80
|
+
},
|
|
81
|
+
set: function (newState) {
|
|
82
|
+
newState = newState || {};
|
|
83
|
+
// eslint-disable-next-line no-constant-condition
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
this.setState(newState);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
Object.defineProperty(proto, "__document", {
|
|
101
|
+
get: function () {
|
|
102
|
+
// eslint-disable-next-line no-constant-condition
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
return this.I_;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
Object.defineProperty(proto, "el", {
|
|
111
|
+
get: function () {
|
|
112
|
+
// eslint-disable-next-line no-constant-condition
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
return this.J_;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// get legacy methods
|
|
129
|
+
|
|
130
|
+
proto.K_ = proto.onRender;
|
|
131
|
+
Object.defineProperty(proto, "onRender", {
|
|
132
|
+
get: noop,
|
|
133
|
+
set: function (v) {
|
|
134
|
+
proto.K_ = v;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
proto.L_ = proto.onUpdate;
|
|
139
|
+
Object.defineProperty(proto, "onUpdate", {
|
|
140
|
+
get: function () {
|
|
141
|
+
return modernMountOrUpdate;
|
|
142
|
+
},
|
|
143
|
+
set: function (v) {
|
|
144
|
+
proto.L_ = v;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
proto.M_ = proto.onDestroy;
|
|
149
|
+
Object.defineProperty(proto, "onDestroy", {
|
|
150
|
+
get: function () {
|
|
151
|
+
return modernOnDestory;
|
|
152
|
+
},
|
|
153
|
+
set: function (v) {
|
|
154
|
+
proto.M_ = v;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
proto.getWidget = proto.getComponent;
|
|
159
|
+
proto.getWidgets = proto.getComponents;
|
|
160
|
+
proto.onMount = modernMountOrUpdate;
|
|
161
|
+
|
|
162
|
+
if (legacyInit) {
|
|
163
|
+
proto.N_ = legacyInit;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// convert legacy to modern
|
|
167
|
+
proto.O_ = proto.update;
|
|
168
|
+
proto.update = function () {
|
|
169
|
+
if (this.P_) {
|
|
170
|
+
// eslint-disable-next-line no-constant-condition
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
this.destroy = modernOnDestory;
|
|
181
|
+
this.P_ = false;
|
|
182
|
+
}
|
|
183
|
+
this.Q_ = true;
|
|
184
|
+
if (this.J_) {
|
|
185
|
+
this.onBeforeUpdate && this.onBeforeUpdate();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
this.O_();
|
|
189
|
+
this.Q_ = false;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
function modernMountOrUpdate() {
|
|
193
|
+
var self = this;
|
|
194
|
+
var el = this.l_["@_wbind"];
|
|
195
|
+
var prevEl = this.J_;
|
|
196
|
+
|
|
197
|
+
if (prevEl !== el) {
|
|
198
|
+
this.J_ = el;
|
|
199
|
+
|
|
200
|
+
if (prevEl) {
|
|
201
|
+
this.onBeforeDestroy && this.onBeforeDestroy();
|
|
202
|
+
this.M_ && this.M_();
|
|
203
|
+
this.R_ = undefined;
|
|
204
|
+
this.removeAllListeners();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (el) {
|
|
208
|
+
this.N_ && this.N_(this.widgetConfig || {});
|
|
209
|
+
this.K_ && this.K_({ firstRender: true });
|
|
210
|
+
this.R_ = legacyRender;
|
|
211
|
+
|
|
212
|
+
// eslint-disable-next-line no-constant-condition
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
el.__widget = this;
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
} else if (el) {
|
|
226
|
+
if (prevEl) {
|
|
227
|
+
this.L_ && this.L_();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (this.S_) {
|
|
231
|
+
this.K_ &&
|
|
232
|
+
this.K_({ firstRender: false });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this.T_ = this.U_;
|
|
237
|
+
this.U_ = null;
|
|
238
|
+
this.S_ = false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function legacyRender() {
|
|
242
|
+
if (!this.Q_) {
|
|
243
|
+
this.onBeforeUpdate && this.onBeforeUpdate();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this.S_ = true;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function modernOnDestory() {
|
|
250
|
+
if (this.J_) {
|
|
251
|
+
this.onBeforeDestroy && this.onBeforeDestroy();
|
|
252
|
+
this.M_ && this.M_();
|
|
253
|
+
this.J_ = null;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Set a flag on the constructor function to make it clear this is
|
|
258
|
+
// a component so that we can short-circuit this work later
|
|
259
|
+
Component.E_ = true;
|
|
260
|
+
|
|
261
|
+
function State() {
|
|
262
|
+
BaseState.apply(this, arguments);
|
|
263
|
+
}
|
|
264
|
+
inherit(State, BaseState);
|
|
265
|
+
proto.V_ = State;
|
|
266
|
+
|
|
267
|
+
jQuery.patchComponent(
|
|
268
|
+
window.$,
|
|
269
|
+
proto,
|
|
270
|
+
true /* don't throw error until used if `$` is missing*/);
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
ready.patchComponent(proto);
|
|
274
|
+
|
|
275
|
+
if (!renderer) {
|
|
276
|
+
renderer = ComponentClass.renderer || ComponentClass.prototype.renderer;
|
|
277
|
+
if (renderer) {
|
|
278
|
+
// Legacy support
|
|
279
|
+
var createOut = renderer.createOut;
|
|
280
|
+
if (typeof renderer !== "function") {
|
|
281
|
+
var rendererObject = renderer;
|
|
282
|
+
renderer = function (input, out) {
|
|
283
|
+
var rendererFunc = rendererObject.renderer || rendererObject.render;
|
|
284
|
+
rendererFunc(input, out);
|
|
285
|
+
};
|
|
286
|
+
renderer.createOut = createOut;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
renderer.render = function (input) {
|
|
290
|
+
var out = createOut();
|
|
291
|
+
renderer(input, out);
|
|
292
|
+
return out.end();
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (renderer) {
|
|
298
|
+
// Add the rendering related methods as statics on the
|
|
299
|
+
// new component constructor function
|
|
300
|
+
Component.renderer = proto.W_ = renderer;
|
|
301
|
+
Component.render = renderer.render;
|
|
302
|
+
Component.renderSync = renderer.renderSync;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// eslint-disable-next-line no-constant-condition
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
Component._isWidget = true;
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
var template = def.template;
|
|
318
|
+
if (template) {
|
|
319
|
+
if (typeof template === "string") {
|
|
320
|
+
template = loader(template);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
registry.r(template.X_, function () {return Component;});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return Component;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
BaseState = require("../../../runtime/components/State");
|
|
330
|
+
BaseComponent = require("../../../runtime/components/Component");
|
|
331
|
+
inherit = require("raptor-util/inherit");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";module.exports = function defineWidget(def, renderer) {
|
|
2
|
+
if (def.E_) {
|
|
3
|
+
return def;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (renderer) {
|
|
7
|
+
return {
|
|
8
|
+
E_: true,
|
|
9
|
+
_isWidget: true,
|
|
10
|
+
renderer: renderer,
|
|
11
|
+
render: renderer.render,
|
|
12
|
+
renderSync: renderer.renderSync,
|
|
13
|
+
template: renderer.template
|
|
14
|
+
};
|
|
15
|
+
} else {
|
|
16
|
+
return { E_: true, _isWidget: true };
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";var registry = require("@internal/components-registry");
|
|
2
2
|
|
|
3
|
-
exports.getComponentForEl = require("@internal/components-util").
|
|
4
|
-
exports.init = registry.
|
|
3
|
+
exports.getComponentForEl = require("@internal/components-util").Y_;
|
|
4
|
+
exports.init = registry.Z_;
|
|
5
5
|
exports.register = function (id, component) {
|
|
6
6
|
registry.r(id, function () {
|
|
7
7
|
return component;
|