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
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var makeRenderable = require("../../renderable");
|
|
3
|
+
var getComponentsContext =
|
|
4
|
+
require("../ComponentsContext").e_;
|
|
5
|
+
var componentLookup = require("@internal/components-util")._o_;
|
|
6
|
+
var modernRenderer = require("../renderer");
|
|
7
|
+
var loader = require("@internal/loader");
|
|
8
|
+
var resolveComponentKey = modernRenderer.aU_;
|
|
9
|
+
|
|
10
|
+
module.exports = function defineRenderer(renderingLogic) {
|
|
11
|
+
var renderer = renderingLogic.renderer;
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line no-constant-condition
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if (renderer && renderer.aV_) {
|
|
19
|
+
return renderer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var template = renderingLogic.template;
|
|
23
|
+
|
|
24
|
+
if (typeof template === "string") {
|
|
25
|
+
template = loader(template);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!renderer) {
|
|
29
|
+
var getInitialProps;
|
|
30
|
+
var getTemplateData;
|
|
31
|
+
var getInitialState;
|
|
32
|
+
var getWidgetConfig;
|
|
33
|
+
var getInitialBody;
|
|
34
|
+
|
|
35
|
+
if (renderingLogic) {
|
|
36
|
+
getInitialProps = renderingLogic.getInitialProps;
|
|
37
|
+
getTemplateData = renderingLogic.getTemplateData;
|
|
38
|
+
getInitialState = renderingLogic.getInitialState;
|
|
39
|
+
getWidgetConfig = renderingLogic.getWidgetConfig;
|
|
40
|
+
getInitialBody = renderingLogic.getInitialBody;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Create a renderer function that takes care of translating
|
|
44
|
+
// the input properties to a view state. Also, this renderer
|
|
45
|
+
// takes care of re-using existing components.
|
|
46
|
+
renderer = function renderer(input, out) {
|
|
47
|
+
var componentsContext = getComponentsContext(out);
|
|
48
|
+
var globalComponentsContext = componentsContext.f_;
|
|
49
|
+
var component = globalComponentsContext.ax_;
|
|
50
|
+
var isReceivingNewInput = !component || component._l_;
|
|
51
|
+
var parentComponentDef;
|
|
52
|
+
|
|
53
|
+
if (component) {
|
|
54
|
+
component._l_ = false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Render the template associated with the component using the final template
|
|
58
|
+
// data that we constructed
|
|
59
|
+
var newProps = input;
|
|
60
|
+
var widgetConfig;
|
|
61
|
+
var widgetState;
|
|
62
|
+
var widgetBody;
|
|
63
|
+
var id;
|
|
64
|
+
|
|
65
|
+
if (!component && componentLookup) {
|
|
66
|
+
var key = out.j_;
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
(parentComponentDef = componentsContext.k_) &&
|
|
70
|
+
key != null)
|
|
71
|
+
{
|
|
72
|
+
id = resolveComponentKey(key.toString(), parentComponentDef);
|
|
73
|
+
} else if (parentComponentDef) {
|
|
74
|
+
id = parentComponentDef.aL_();
|
|
75
|
+
} else {
|
|
76
|
+
id = globalComponentsContext.aL_();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
component = componentLookup[id];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isReceivingNewInput) {
|
|
83
|
+
// If we do not have state then we need to go through the process
|
|
84
|
+
// of converting the input to a widget state, or simply normalizing
|
|
85
|
+
// the input using getInitialProps
|
|
86
|
+
|
|
87
|
+
if (getInitialProps) {
|
|
88
|
+
// This optional method is used to normalize input state
|
|
89
|
+
newProps = getInitialProps(newProps, out) || {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (getInitialState) {
|
|
93
|
+
// This optional method is used to derive the widget state
|
|
94
|
+
// from the input properties
|
|
95
|
+
widgetState = getInitialState(newProps, out);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (getInitialBody) {
|
|
99
|
+
// If we have widget a widget body then pass it to the template
|
|
100
|
+
// so that it is available to the widget tag and can be inserted
|
|
101
|
+
// at the w-body marker
|
|
102
|
+
widgetBody = getInitialBody(newProps, out);
|
|
103
|
+
} else {
|
|
104
|
+
// Default to using the nested content as the widget body
|
|
105
|
+
// getInitialBody was not implemented
|
|
106
|
+
widgetBody = newProps.renderBody;
|
|
107
|
+
}
|
|
108
|
+
} else if (component) {
|
|
109
|
+
newProps = newProps || component.T_;
|
|
110
|
+
widgetBody = component._c_;
|
|
111
|
+
widgetState = component.aA_;
|
|
112
|
+
widgetConfig = component.widgetConfig;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Use getTemplateData(state, props, out) to get the template
|
|
116
|
+
// data. If that method is not provided then just use the
|
|
117
|
+
// the state (if provided) or the input data.
|
|
118
|
+
var templateData = clone(
|
|
119
|
+
getTemplateData ?
|
|
120
|
+
getTemplateData(widgetState, newProps, out) :
|
|
121
|
+
widgetState || newProps);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if (isReceivingNewInput && getWidgetConfig) {
|
|
125
|
+
// If getWidgetConfig() was implemented then use that to
|
|
126
|
+
// get the widget config. The widget config will be passed
|
|
127
|
+
// to the widget constructor. If rendered on the server the
|
|
128
|
+
// widget config will be serialized.
|
|
129
|
+
widgetConfig = getWidgetConfig(newProps, out);
|
|
130
|
+
}
|
|
131
|
+
// eslint-disable-next-line no-constant-condition
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
templateData.widgetProps = newProps;
|
|
143
|
+
widgetBody && (templateData.renderBody = widgetBody);
|
|
144
|
+
widgetState && (templateData.widgetState = widgetState);
|
|
145
|
+
widgetConfig && (templateData.widgetConfig = widgetConfig);
|
|
146
|
+
|
|
147
|
+
template._(templateData, out, id, renderingLogic);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
renderer.aV_ = true;
|
|
152
|
+
renderer.createOut = template ? template.createOut : renderingLogic.createOut;
|
|
153
|
+
renderer.template = template;
|
|
154
|
+
|
|
155
|
+
makeRenderable(renderer, renderer);
|
|
156
|
+
renderer.render = renderer.render.bind(this);
|
|
157
|
+
|
|
158
|
+
return renderer;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
function clone(src) {
|
|
162
|
+
var result = {};
|
|
163
|
+
|
|
164
|
+
if (src) {
|
|
165
|
+
for (var key in src) {
|
|
166
|
+
result[key] = src[key];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";module.exports = require("@internal/components-define-widget-legacy");
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";var nodePath = require("path");
|
|
2
|
+
var defaultResolveFrom = require("resolve-from");
|
|
3
|
+
var env = process.env.NODE_ENV;
|
|
4
|
+
var production = !env || env !== "development";
|
|
5
|
+
|
|
6
|
+
function getRootDeps(template, context) {
|
|
7
|
+
if (production && template.aW_) {
|
|
8
|
+
return template.aW_;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
attachDepsAndComponentsToTemplate(template, context);
|
|
12
|
+
|
|
13
|
+
var deps = template.aW_ = Object.keys(template.aX_).map(
|
|
14
|
+
(key) => template.aX_[key]);
|
|
15
|
+
|
|
16
|
+
var initModule = getInitModule(template.path, template.b_);
|
|
17
|
+
|
|
18
|
+
if (initModule) deps.push(initModule);
|
|
19
|
+
|
|
20
|
+
// these dependencies should be last
|
|
21
|
+
deps.concat = function () {
|
|
22
|
+
var result = [];
|
|
23
|
+
result = result.concat.apply(result, arguments);
|
|
24
|
+
result.push.apply(result, this);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return deps;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function attachDepsAndComponentsToTemplate(target, context) {
|
|
32
|
+
var template;
|
|
33
|
+
|
|
34
|
+
if (!target.meta && target.template) {
|
|
35
|
+
template = target.template;
|
|
36
|
+
} else {
|
|
37
|
+
template = target;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof template.createOut !== "function") return;
|
|
41
|
+
if (production && target.aX_) return;
|
|
42
|
+
|
|
43
|
+
var deps = target.aX_ = {};
|
|
44
|
+
var components = target.b_ = {};
|
|
45
|
+
|
|
46
|
+
if (!template.meta) {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.warn("Metadata not set for template at ", template.path);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var meta = template.meta;
|
|
53
|
+
var root = nodePath.dirname(template.path);
|
|
54
|
+
|
|
55
|
+
if (meta.deps) {
|
|
56
|
+
meta.deps.forEach((dep) => {
|
|
57
|
+
dep = resolveDep(dep, root, context);
|
|
58
|
+
deps[dep.virtualPath || dep.path] = dep;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (meta.id && meta.component) {
|
|
63
|
+
var resolveFrom = context && context.resolveFrom || defaultResolveFrom;
|
|
64
|
+
components[meta.id] = {
|
|
65
|
+
id: meta.id,
|
|
66
|
+
path: resolveFrom(root, meta.component)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (meta.tags) {
|
|
71
|
+
meta.tags.forEach((tagPath) => {
|
|
72
|
+
var resolveFrom = context.resolveFrom || defaultResolveFrom;
|
|
73
|
+
var tag = resolveFrom(root, tagPath);
|
|
74
|
+
var ext = nodePath.extname(tag);
|
|
75
|
+
var req = context.require || require;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
tag = req.resolve(tag.slice(0, 0 - ext.length) + ".js");
|
|
79
|
+
} catch (e) {
|
|
80
|
+
|
|
81
|
+
/* ignore error */}
|
|
82
|
+
|
|
83
|
+
tag = req(tag);
|
|
84
|
+
|
|
85
|
+
attachDepsAndComponentsToTemplate(tag, context);
|
|
86
|
+
|
|
87
|
+
if (tag.aX_) Object.assign(deps, tag.aX_);
|
|
88
|
+
if (tag.b_) Object.assign(components, tag.b_);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getInitModule(path, components) {
|
|
94
|
+
var module = null;
|
|
95
|
+
|
|
96
|
+
if (components) {
|
|
97
|
+
components = Object.keys(components).map((key) => components[key]);
|
|
98
|
+
|
|
99
|
+
if (components.length) {
|
|
100
|
+
var root = nodePath.dirname(path);
|
|
101
|
+
var virtualPath = path + ".init.js";
|
|
102
|
+
var registrations = components.map(
|
|
103
|
+
(component) =>
|
|
104
|
+
`components.register('${component.id}', require('.${
|
|
105
|
+
nodePath.sep
|
|
106
|
+
}${nodePath.relative(root, component.path)}'));`);
|
|
107
|
+
|
|
108
|
+
var code = `
|
|
109
|
+
var components = require('marko/components');
|
|
110
|
+
${registrations.join("\n")}
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
module = {
|
|
114
|
+
type: "require",
|
|
115
|
+
run: true,
|
|
116
|
+
virtualModule: {
|
|
117
|
+
path: virtualPath,
|
|
118
|
+
read: function (_, callback) {
|
|
119
|
+
// TODO: Check if read can just return string in lasso 2
|
|
120
|
+
if (callback) {
|
|
121
|
+
callback(null, code);
|
|
122
|
+
} else {
|
|
123
|
+
return code;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return module;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function resolveDep(dep, root, context) {
|
|
135
|
+
if (typeof dep === "string") {
|
|
136
|
+
dep = parseDependencyString(dep);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (dep.path) {
|
|
140
|
+
var resolveFrom = context && context.resolveFrom || defaultResolveFrom;
|
|
141
|
+
dep.path = resolveFrom(root, dep.path);
|
|
142
|
+
|
|
143
|
+
if (dep.path && !dep.type) {
|
|
144
|
+
dep.type = dep.path.slice(dep.path.lastIndexOf(".") + 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (dep.virtualPath) {
|
|
149
|
+
dep.virtualPath = nodePath.resolve(root, dep.virtualPath);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (dep.type === "js") {
|
|
153
|
+
dep.type = "require";
|
|
154
|
+
dep.run = true;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return dep;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function parseDependencyString(string) {
|
|
161
|
+
var match = /^(?:([\w-]+)(?::\s*|\s+))?(.*?(?:\.(\w+))?)$/.exec(string);
|
|
162
|
+
return {
|
|
163
|
+
type: match[1] || match[3],
|
|
164
|
+
path: match[2]
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function patch(Template) {
|
|
169
|
+
Template.prototype.getDependencies = function (context) {
|
|
170
|
+
context = context || {};
|
|
171
|
+
|
|
172
|
+
return getRootDeps(this, context);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
exports.getDeps = getRootDeps;
|
|
177
|
+
exports.resolveDep = resolveDep;
|
|
178
|
+
exports.patch = patch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";module.exports = require("@internal/components-entry-legacy");
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";var ready = require("./ready");
|
|
2
|
+
|
|
3
|
+
var idRegExp = /^#(\S+)( .*)?/;
|
|
4
|
+
|
|
5
|
+
exports.patchComponent = function (jQuery, proto, delayThrow) {
|
|
6
|
+
if (!(jQuery || (jQuery = window.$)) && !delayThrow) {
|
|
7
|
+
throw new Error("jQuery not found");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
(proto || require("../Component").prototype).$ = function jqueryProxy(arg) {
|
|
11
|
+
var args = arguments;
|
|
12
|
+
var self = this;
|
|
13
|
+
|
|
14
|
+
if (!jQuery) {
|
|
15
|
+
throw new Error("jQuery not found");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (args.length === 1) {
|
|
19
|
+
//Handle an "ondomready" callback function
|
|
20
|
+
if (typeof arg === "function") {
|
|
21
|
+
return ready(function () {
|
|
22
|
+
arg.call(self);
|
|
23
|
+
});
|
|
24
|
+
} else if (typeof arg === "string") {
|
|
25
|
+
var match = idRegExp.exec(arg);
|
|
26
|
+
//Reset the search to 0 so the next call to exec will start from the beginning for the new string
|
|
27
|
+
if (match != null) {
|
|
28
|
+
var key = match[1];
|
|
29
|
+
if (match[2] == null) {
|
|
30
|
+
return jQuery(self.getEl(key));
|
|
31
|
+
} else {
|
|
32
|
+
return jQuery(match[2].trim(), self.getEl(key));
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
var rootEl = self.getEl();
|
|
36
|
+
if (!rootEl) {
|
|
37
|
+
throw new Error("Root element is not defined for component");
|
|
38
|
+
}
|
|
39
|
+
if (rootEl) {
|
|
40
|
+
return jQuery(arg, rootEl);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else if (args.length === 2 && typeof args[1] === "string") {
|
|
45
|
+
return jQuery(arg, self.getEl(args[1]));
|
|
46
|
+
} else if (args.length === 0) {
|
|
47
|
+
return jQuery(self.el);
|
|
48
|
+
}
|
|
49
|
+
return jQuery.apply(window, arguments);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict"; /*
|
|
2
|
+
jQuery's doc.ready/$(function(){}) should
|
|
3
|
+
you wish to use a cross-browser domReady solution
|
|
4
|
+
without opting for a library.
|
|
5
|
+
|
|
6
|
+
Demo: http://jsfiddle.net/zKLpb/
|
|
7
|
+
|
|
8
|
+
usage:
|
|
9
|
+
$(function(){
|
|
10
|
+
// your code
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
Parts: jQuery project, Diego Perini, Lucent M.
|
|
14
|
+
Previous version from Addy Osmani (https://raw.github.com/addyosmani/jquery.parts/master/jquery.documentReady.js)
|
|
15
|
+
|
|
16
|
+
This version: Patrick Steele-Idem
|
|
17
|
+
- Converted to CommonJS module
|
|
18
|
+
- Code cleanup
|
|
19
|
+
- Fixes for IE <=10
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
var isReady = false;
|
|
23
|
+
var readyBound = false;
|
|
24
|
+
|
|
25
|
+
var defaultWindow = typeof window != "undefined" && window;
|
|
26
|
+
var defaultDocument = typeof document != "undefined" && document;
|
|
27
|
+
|
|
28
|
+
var listeners = [];
|
|
29
|
+
|
|
30
|
+
function domReadyCallback() {
|
|
31
|
+
for (var i = 0, len = listeners.length; i < len; i++) {
|
|
32
|
+
var listener = listeners[i];
|
|
33
|
+
listener[0].call(listener[1]);
|
|
34
|
+
}
|
|
35
|
+
listeners = null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function bindReady(doc) {
|
|
39
|
+
var toplevel = false;
|
|
40
|
+
var win = doc.defaultView || defaultWindow || doc;
|
|
41
|
+
|
|
42
|
+
// Handle when the DOM is ready
|
|
43
|
+
function domReady() {
|
|
44
|
+
// Make sure that the DOM is not already loaded
|
|
45
|
+
if (!isReady) {
|
|
46
|
+
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
|
47
|
+
if (!doc.body) {
|
|
48
|
+
return setTimeout(domReady, 1);
|
|
49
|
+
}
|
|
50
|
+
// Remember that the DOM is ready
|
|
51
|
+
isReady = true;
|
|
52
|
+
// If there are functions bound, to execute
|
|
53
|
+
domReadyCallback();
|
|
54
|
+
// Execute all of them
|
|
55
|
+
}
|
|
56
|
+
} // /ready()
|
|
57
|
+
|
|
58
|
+
// The ready event handler
|
|
59
|
+
function domContentLoaded() {
|
|
60
|
+
if (doc.addEventListener) {
|
|
61
|
+
doc.removeEventListener("DOMContentLoaded", domContentLoaded, false);
|
|
62
|
+
doc.removeEventListener("load", domContentLoaded, false);
|
|
63
|
+
} else {
|
|
64
|
+
// we're here because readyState !== "loading" in oldIE
|
|
65
|
+
// which is good enough for us to call the dom ready!
|
|
66
|
+
doc.detachEvent("onreadystatechange", domContentLoaded);
|
|
67
|
+
doc.detachEvent("onload", domContentLoaded);
|
|
68
|
+
}
|
|
69
|
+
domReady();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The DOM ready check for Internet Explorer
|
|
73
|
+
function doScrollCheck() {
|
|
74
|
+
if (isReady) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
// If IE is used, use the trick by Diego Perini
|
|
80
|
+
// http://javascript.nwbox.com/IEContentLoaded/
|
|
81
|
+
doc.documentElement.doScroll("left");
|
|
82
|
+
} catch (error) {
|
|
83
|
+
setTimeout(doScrollCheck, 1);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// and execute any waiting functions
|
|
87
|
+
domReady();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Catch cases where $ is called after the
|
|
91
|
+
// browser event has already occurred. IE <= 10 has a bug that results in 'interactive' being assigned
|
|
92
|
+
// to the readyState before the DOM is really ready
|
|
93
|
+
if (
|
|
94
|
+
document.attachEvent ?
|
|
95
|
+
document.readyState === "complete" :
|
|
96
|
+
document.readyState !== "loading")
|
|
97
|
+
{
|
|
98
|
+
// We will get here if the browser is IE and the readyState === 'complete' or the browser
|
|
99
|
+
// is not IE and the readyState === 'interactive' || 'complete'
|
|
100
|
+
domReady(doc);
|
|
101
|
+
} else if (doc.addEventListener) {
|
|
102
|
+
// Standards-based browsers support DOMContentLoaded
|
|
103
|
+
// Use the handy event callback
|
|
104
|
+
doc.addEventListener("DOMContentLoaded", domContentLoaded, false);
|
|
105
|
+
// A fallback to win.onload, that will always work
|
|
106
|
+
win.addEventListener("load", domContentLoaded, false);
|
|
107
|
+
// If IE event model is used
|
|
108
|
+
} else if (doc.attachEvent) {
|
|
109
|
+
// ensure firing before onload,
|
|
110
|
+
// maybe late but safe also for iframes
|
|
111
|
+
doc.attachEvent("onreadystatechange", domContentLoaded);
|
|
112
|
+
// A fallback to win.onload, that will always work
|
|
113
|
+
win.attachEvent("onload", domContentLoaded);
|
|
114
|
+
// If IE and not a frame
|
|
115
|
+
// continually check to see if the document is ready
|
|
116
|
+
try {
|
|
117
|
+
toplevel = win.frameElement == null;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
|
|
120
|
+
/* ignore error */}
|
|
121
|
+
if (doc.documentElement.doScroll && toplevel) {
|
|
122
|
+
doScrollCheck();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function ready(callback, thisObj, doc) {
|
|
128
|
+
if (isReady) {
|
|
129
|
+
return callback.call(thisObj);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
listeners.push([callback, thisObj]);
|
|
133
|
+
|
|
134
|
+
if (!readyBound) {
|
|
135
|
+
readyBound = true;
|
|
136
|
+
bindReady(doc || defaultDocument);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = ready;
|
|
141
|
+
|
|
142
|
+
module.exports.patchComponent = function (proto) {
|
|
143
|
+
if (proto && proto.ready) {
|
|
144
|
+
// Don't patch if the component has overwritten the ready method.
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
(proto || require("../Component").prototype).ready = function (callback) {
|
|
149
|
+
var document = this.el.ownerDocument;
|
|
150
|
+
ready(callback, this, document);
|
|
151
|
+
};
|
|
152
|
+
};
|