marko 5.39.50 → 5.40.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 +0 -2
- package/dist/core-tags/core/await/index.d.marko +17 -0
- package/dist/core-tags/core/script.d.marko +6 -1
- package/dist/runtime/helpers/dynamic-tag.js +11 -4
- package/dist/runtime/helpers/load-tag.js +1 -1
- package/dist/runtime/helpers/tags-compat/dom-debug.js +1 -1
- package/dist/runtime/helpers/tags-compat/dom-debug.mjs +1 -1
- package/dist/runtime/helpers/tags-compat/dom.js +1 -1
- package/dist/runtime/helpers/tags-compat/dom.mjs +1 -1
- package/dist/runtime/helpers/tags-compat/html-debug.js +3 -1
- package/dist/runtime/helpers/tags-compat/html-debug.mjs +1 -1
- package/dist/runtime/helpers/tags-compat/html.js +3 -1
- package/dist/runtime/helpers/tags-compat/html.mjs +1 -1
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +50 -51
- package/dist/runtime/helpers/tags-compat/runtime-html.js +18 -20
- package/dist/runtime/html/AsyncStream.js +10 -10
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +2 -2
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/renderable.js +1 -1
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +65 -65
- package/dist/runtime/vdom/VComment.js +7 -7
- package/dist/runtime/vdom/VComponent.js +3 -3
- package/dist/runtime/vdom/VDocumentFragment.js +6 -6
- package/dist/runtime/vdom/VElement.js +39 -58
- package/dist/runtime/vdom/VFragment.js +5 -5
- package/dist/runtime/vdom/VNode.js +29 -29
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/const-element.js +3 -3
- package/dist/runtime/vdom/hot-reload.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +3 -3
- package/dist/runtime/vdom/morphdom/helpers.js +1 -1
- package/dist/runtime/vdom/morphdom/index.js +34 -35
- package/dist/runtime/vdom/vdom.js +15 -15
- package/dist/taglib/index.js +3 -6
- package/dist/translator/index.js +8 -23
- package/dist/translator/tag/attribute/index.js +0 -16
- package/dist/translator/tag/attribute-tag.js +4 -11
- package/dist/translator/tag/custom-tag.js +1 -2
- package/dist/translator/tag/native-tag[html]/index.js +1 -13
- package/dist/translator/tag/native-tag[vdom]/index.js +0 -12
- package/dist/translator/tag/util.js +69 -55
- package/dist/translator/taglib/core/index.js +17 -366
- package/dist/translator/util/get-component-files.js +1 -1
- package/dist/translator/util/runtime-flags.js +2 -3
- package/dist/translator.js +4 -2
- package/docs/marko-json.md +3 -6
- package/index.d.ts +3 -8
- package/package.json +4 -4
- package/src/compiler/index.js +0 -2
- package/src/core-tags/core/await/index.d.marko +17 -0
- package/src/core-tags/core/script.d.marko +6 -1
- package/src/runtime/helpers/dynamic-tag.js +10 -3
- package/src/runtime/helpers/tags-compat/dom-debug.js +1 -1
- package/src/runtime/helpers/tags-compat/dom-debug.mjs +1 -1
- package/src/runtime/helpers/tags-compat/dom.js +1 -1
- package/src/runtime/helpers/tags-compat/dom.mjs +1 -1
- package/src/runtime/helpers/tags-compat/html-debug.js +3 -1
- package/src/runtime/helpers/tags-compat/html-debug.mjs +1 -1
- package/src/runtime/helpers/tags-compat/html.js +3 -1
- package/src/runtime/helpers/tags-compat/html.mjs +1 -1
- package/src/runtime/helpers/tags-compat/runtime-dom.js +40 -41
- package/src/runtime/helpers/tags-compat/runtime-html.js +14 -16
- package/src/runtime/vdom/VElement.js +10 -29
- package/src/runtime/vdom/morphdom/index.js +0 -1
- package/src/taglib/index.js +3 -6
- package/src/translator/index.js +6 -21
- package/src/translator/tag/attribute/index.js +1 -17
- package/src/translator/tag/attribute-tag.js +4 -11
- package/src/translator/tag/custom-tag.js +1 -2
- package/src/translator/tag/native-tag[html]/index.js +0 -12
- package/src/translator/tag/native-tag[vdom]/index.js +1 -13
- package/src/translator/tag/util.js +69 -55
- package/src/translator/taglib/core/index.js +0 -349
- package/src/translator/util/runtime-flags.js +1 -2
- package/src/translator.js +2 -0
- package/translator/index.d.ts +1 -0
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";exports.__esModule = true;exports.SPREAD_ATTRS = exports.
|
|
2
|
-
const
|
|
3
|
-
const SPREAD_ATTRS = exports.SPREAD_ATTRS = 4; // TODO: impl custom elements.
|
|
1
|
+
"use strict";exports.__esModule = true;exports.SPREAD_ATTRS = exports.HAS_SIMPLE_ATTRS = void 0;const HAS_SIMPLE_ATTRS = exports.HAS_SIMPLE_ATTRS = 1;
|
|
2
|
+
const SPREAD_ATTRS = exports.SPREAD_ATTRS = 4;
|
package/dist/translator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";exports.__esModule = true;exports.version = exports.translate = exports.transform = exports.taglibs = exports.tagDiscoveryDirs = exports.preferAPI = exports.getRuntimeEntryFiles = exports.analyze = void 0;var tagsAPI = _interopRequireWildcard(require("@marko/runtime-tags/translator"));
|
|
1
|
+
"use strict";exports.__esModule = true;exports.version = exports.translate = exports.transform = exports.taglibs = exports.tagDiscoveryDirs = exports.preferAPI = exports.optionalTaglibs = exports.getRuntimeEntryFiles = exports.classTaglibs = exports.analyze = void 0;var tagsAPI = _interopRequireWildcard(require("@marko/runtime-tags/translator"));
|
|
2
2
|
|
|
3
3
|
var classAPI = _interopRequireWildcard(require("./translator/index"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);}
|
|
4
4
|
|
|
@@ -6,9 +6,11 @@ const {
|
|
|
6
6
|
version,
|
|
7
7
|
preferAPI,
|
|
8
8
|
tagDiscoveryDirs,
|
|
9
|
+
classTaglibs,
|
|
10
|
+
optionalTaglibs,
|
|
9
11
|
transform,
|
|
10
12
|
analyze,
|
|
11
13
|
translate,
|
|
12
14
|
taglibs,
|
|
13
15
|
getRuntimeEntryFiles
|
|
14
|
-
} = tagsAPI.createInteropTranslator(classAPI);exports.getRuntimeEntryFiles = getRuntimeEntryFiles;exports.taglibs = taglibs;exports.translate = translate;exports.analyze = analyze;exports.transform = transform;exports.tagDiscoveryDirs = tagDiscoveryDirs;exports.preferAPI = preferAPI;exports.version = version;
|
|
16
|
+
} = tagsAPI.createInteropTranslator(classAPI);exports.getRuntimeEntryFiles = getRuntimeEntryFiles;exports.taglibs = taglibs;exports.translate = translate;exports.analyze = analyze;exports.transform = transform;exports.optionalTaglibs = optionalTaglibs;exports.classTaglibs = classTaglibs;exports.tagDiscoveryDirs = tagDiscoveryDirs;exports.preferAPI = preferAPI;exports.version = version;
|
package/docs/marko-json.md
CHANGED
|
@@ -35,7 +35,7 @@ There are 2 types of configuration files:
|
|
|
35
35
|
|
|
36
36
|
### Attributes
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Attributes declared in this config file control how they are passed to the tag's `input`.
|
|
39
39
|
|
|
40
40
|
```js
|
|
41
41
|
{
|
|
@@ -45,9 +45,7 @@ One commonly-used feature of this config file is compile-time checks for attribu
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
The
|
|
49
|
-
|
|
50
|
-
The `string` value is used as documentation for the custom tag. It may be picked up by tooling, like Marko’s editor plugins, to provide hints to the user.
|
|
48
|
+
The `string` value only documents the attribute. For type checking and editor hints, type the tag's `Input` with TypeScript instead.
|
|
51
49
|
|
|
52
50
|
The recommended list of attribute types are as follows:
|
|
53
51
|
|
|
@@ -69,11 +67,10 @@ You can also provide an object for an attribute definition’s value for additio
|
|
|
69
67
|
"heading": {
|
|
70
68
|
"type": "string", // Same as setting "string" above.
|
|
71
69
|
"default-value": 0, // The attribute will default to this value.
|
|
72
|
-
"required": true, // Error during compilation if this attribute is undefined. (Mutually exclusive with "default-value"
|
|
73
70
|
"preserve-name": true, // By default component attributes are camelCased; this disables that feature.
|
|
74
71
|
"remove-dashes": true, // By default native tag attributes are dash-cased; this disables that feature.
|
|
75
72
|
|
|
76
|
-
// The following
|
|
73
|
+
// The following are ignored.
|
|
77
74
|
"deprecated": true,
|
|
78
75
|
"description": "The component’s heading text" // Describes the attribute’s purpose.
|
|
79
76
|
}
|
package/index.d.ts
CHANGED
|
@@ -287,7 +287,7 @@ declare global {
|
|
|
287
287
|
input: Marko.TemplateInput<Input>,
|
|
288
288
|
reference: Node,
|
|
289
289
|
position?: "afterbegin" | "afterend" | "beforebegin" | "beforeend",
|
|
290
|
-
): Marko.MountedTemplate<typeof input>;
|
|
290
|
+
): Marko.MountedTemplate<typeof input, Return>;
|
|
291
291
|
/** @marko-overload-end */
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -363,9 +363,7 @@ declare global {
|
|
|
363
363
|
? Name extends keyof NativeTags
|
|
364
364
|
? NativeTags[Name]["input"]
|
|
365
365
|
: Record<string, unknown>
|
|
366
|
-
: Name extends
|
|
367
|
-
| Template<infer Input, any>
|
|
368
|
-
| { _(): () => (input: infer Input) => any }
|
|
366
|
+
: Name extends Template<infer Input, any>
|
|
369
367
|
? Input
|
|
370
368
|
: Name extends Body<infer Args, any>
|
|
371
369
|
? Args extends {
|
|
@@ -385,10 +383,7 @@ declare global {
|
|
|
385
383
|
? Name extends keyof NativeTags
|
|
386
384
|
? NativeTags[Name]["return"]
|
|
387
385
|
: () => Element
|
|
388
|
-
: Name extends
|
|
389
|
-
| { _(): () => (input: any) => { return: infer Return } }
|
|
390
|
-
| Template<any, infer Return>
|
|
391
|
-
| Body<any, infer Return>
|
|
386
|
+
: Name extends Template<any, infer Return> | Body<any, infer Return>
|
|
392
387
|
? Return
|
|
393
388
|
: never;
|
|
394
389
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.40.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
|
|
6
6
|
"keywords": [
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
},
|
|
68
68
|
"types": "index.d.ts",
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@marko/compiler": "^5.
|
|
71
|
-
"@marko/runtime-tags": "
|
|
70
|
+
"@marko/compiler": "^5.43.0",
|
|
71
|
+
"@marko/runtime-tags": "6.4.13",
|
|
72
72
|
"app-module-path": "^2.2.0",
|
|
73
73
|
"argly": "^1.2.0",
|
|
74
74
|
"browser-refresh-client": "1.1.4",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"warp10": "^2.1.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"marko": "5.
|
|
86
|
+
"marko": "5.40.0"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">=22.12.0"
|
package/src/compiler/index.js
CHANGED
|
@@ -147,8 +147,6 @@ exports.compileFileForBrowser = compileFileForBrowser;
|
|
|
147
147
|
exports.configure = configure;
|
|
148
148
|
|
|
149
149
|
exports.taglibLookup = taglib.lookup;
|
|
150
|
-
exports.taglibLoader = taglib.loader;
|
|
151
|
-
exports.taglibFinder = taglib.finder;
|
|
152
150
|
exports.buildTaglibLookup = taglib.lookup.buildLookup;
|
|
153
151
|
exports.clearCaches = function clearCaches() {
|
|
154
152
|
compiler._clearDefaults();
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders asynchronously with the result of the promise in its argument:
|
|
3
|
+
* `@then` with the value it resolves to, `@catch` with the error it rejects
|
|
4
|
+
* with, and `@placeholder` while it is pending.
|
|
5
|
+
*
|
|
6
|
+
* [Marko 5 docs](https://v5.markojs.com/docs/core-tags/#await)
|
|
7
|
+
*/
|
|
1
8
|
export type Input<T> = {
|
|
2
9
|
value: readonly [T];
|
|
10
|
+
/** Rendered with the value the promise resolves to. */
|
|
3
11
|
then?: Marko.AttrTag<{ renderBody: Marko.Body<[Awaited<T>]> }>;
|
|
12
|
+
/** Rendered with the error the promise rejects with. */
|
|
4
13
|
catch?: Marko.AttrTag<{ renderBody: Marko.Body<[unknown]> }>;
|
|
14
|
+
/** Displayed while the promise is pending. */
|
|
5
15
|
placeholder?: Marko.AttrTag<{ renderBody: Marko.Body }>;
|
|
16
|
+
/**
|
|
17
|
+
* Sends the content after this tag without waiting for the promise, and
|
|
18
|
+
* moves this tag's content into place in the browser once it settles.
|
|
19
|
+
*/
|
|
6
20
|
"client-reorder"?: boolean;
|
|
21
|
+
/** Names this tag for debugging and for another tag's `show-after`. */
|
|
7
22
|
name?: string;
|
|
23
|
+
/** Rejects with a `TimeoutError` after this many milliseconds (10,000 by default). */
|
|
8
24
|
timeout?: number;
|
|
25
|
+
/** With `client-reorder`, keeps this tag after the `<await>` with this name. */
|
|
9
26
|
"show-after"?: string;
|
|
10
27
|
} | {
|
|
11
28
|
value: T;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/* File for types only, not actual implementation */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A native `<script>` element.
|
|
5
|
+
*
|
|
6
|
+
* [MDN](https://developer.mozilla.org/docs/Web/HTML/Element/script)
|
|
7
|
+
*/
|
|
3
8
|
export interface Input extends Marko.HTML.Script {
|
|
4
9
|
value?(): unknown;
|
|
5
10
|
}
|
|
@@ -69,9 +69,7 @@ module.exports = function dynamicTag(
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
var renderer =
|
|
73
|
-
tag._ ||
|
|
74
|
-
(tag.renderer ? tag.renderer.renderer || tag.renderer : tag.render);
|
|
72
|
+
var renderer = getRenderer(tag);
|
|
75
73
|
var render = (tag && tag.renderBody) || tag;
|
|
76
74
|
|
|
77
75
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -244,4 +242,13 @@ function addEvents(componentDef, customEvents, props) {
|
|
|
244
242
|
return result;
|
|
245
243
|
}
|
|
246
244
|
|
|
245
|
+
// A template's Class renderer, from any of the shapes a template or component takes.
|
|
246
|
+
function getRenderer(tag) {
|
|
247
|
+
var renderer =
|
|
248
|
+
tag._ ||
|
|
249
|
+
(tag.renderer ? tag.renderer.renderer || tag.renderer : tag.render);
|
|
250
|
+
return typeof renderer === "function" ? renderer : undefined;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
module.exports.___getRenderer = getRenderer;
|
|
247
254
|
module.exports.___CLASS_EVENT_MARKER = CLASS_EVENT_MARKER;
|
|
@@ -137,47 +137,44 @@ exports.p = function (domCompat) {
|
|
|
137
137
|
}));
|
|
138
138
|
|
|
139
139
|
const rendererCache = new WeakMap();
|
|
140
|
+
const createFragment = () => ___createFragmentNode();
|
|
141
|
+
const createTemplate = domCompat.createTemplate(
|
|
142
|
+
(scope, renderer, input) =>
|
|
143
|
+
renderAndMorph(scope, renderer, undefined, input),
|
|
144
|
+
createFragment,
|
|
145
|
+
);
|
|
146
|
+
const createContent = domCompat.createContent(
|
|
147
|
+
(scope, renderBody, args) =>
|
|
148
|
+
renderAndMorph(scope, undefined, renderBody, args),
|
|
149
|
+
createFragment,
|
|
150
|
+
);
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
renderer._ ||
|
|
157
|
-
renderer.render ||
|
|
158
|
-
(renderer.renderer && renderer.renderer.renderer) ||
|
|
159
|
-
renderer.renderer;
|
|
160
|
-
|
|
161
|
-
if (!domCompat.isRenderer(rendererFromAnywhere || renderer)) {
|
|
162
|
-
newRenderer = rendererCache.get(renderer);
|
|
163
|
-
if (!newRenderer) {
|
|
164
|
-
newRenderer = domCompat.createRenderer(
|
|
165
|
-
(scope, input) =>
|
|
166
|
-
renderAndMorph(scope, rendererFromAnywhere, renderer, input),
|
|
167
|
-
() => ___createFragmentNode(),
|
|
168
|
-
);
|
|
169
|
-
domCompat.setRendererId(newRenderer, renderer);
|
|
170
|
-
rendererCache.set(renderer, newRenderer);
|
|
171
|
-
}
|
|
152
|
+
// The Tags runtime hands over what no Tags renderer matches: a Class template becomes a
|
|
153
|
+
// Tags template, and Class content becomes Tags content that morphs in its Class output.
|
|
154
|
+
domCompat.setClassAPIRenderer((value) => {
|
|
155
|
+
if (domCompat.isRenderer(value)) return value;
|
|
156
|
+
let renderer = rendererCache.get(value);
|
|
157
|
+
if (!renderer) {
|
|
158
|
+
const classRenderer = dynamicTag.___getRenderer(value);
|
|
159
|
+
const renderBody = value.renderBody || value;
|
|
160
|
+
if (classRenderer) {
|
|
161
|
+
renderer = createTemplate(value, classRenderer);
|
|
162
|
+
} else if (renderBody === noopRenderer) {
|
|
163
|
+
// Content only the server can render resumes as noop; its markup stays.
|
|
164
|
+
renderer = domCompat.createRenderer(renderBody, createFragment);
|
|
165
|
+
} else if (typeof renderBody === "function") {
|
|
166
|
+
renderer = createContent(renderBody);
|
|
172
167
|
}
|
|
168
|
+
rendererCache.set(value, renderer);
|
|
173
169
|
}
|
|
174
|
-
return
|
|
175
|
-
}
|
|
170
|
+
return renderer;
|
|
171
|
+
});
|
|
176
172
|
|
|
177
173
|
domCompat.init(noopRenderer);
|
|
178
174
|
|
|
179
175
|
function renderAndMorph(scope, renderer, renderBody, input) {
|
|
180
|
-
const
|
|
176
|
+
const $global = domCompat.getGlobal(scope);
|
|
177
|
+
const out = defaultCreateOut($global);
|
|
181
178
|
let host = domCompat.getStartNode(scope);
|
|
182
179
|
let rootNode = host.fragment;
|
|
183
180
|
if (!rootNode) {
|
|
@@ -203,18 +200,19 @@ exports.p = function (domCompat) {
|
|
|
203
200
|
domCompat.setScopeNodes(scope, rootNode.startNode, rootNode.endNode);
|
|
204
201
|
}
|
|
205
202
|
const existingComponent = scope.___marko5Component;
|
|
206
|
-
const componentsContext = ___getComponentsContext(out);
|
|
207
|
-
const globalComponentsContext = componentsContext.___globalContext;
|
|
208
203
|
let customEvents;
|
|
209
204
|
let normalizedInput;
|
|
210
|
-
|
|
205
|
+
// Cleared so this render gets a context of its own: sharing a Class parent's
|
|
206
|
+
// mid-render context would reset its rerender state for later siblings.
|
|
207
|
+
$global.___components = undefined;
|
|
208
|
+
const componentsContext = ___getComponentsContext(out);
|
|
209
|
+
componentsContext.___globalContext.___rerenderComponent = existingComponent;
|
|
211
210
|
out.sync();
|
|
212
211
|
if (renderer) {
|
|
213
|
-
const [rawInput] = input;
|
|
214
212
|
normalizedInput = {};
|
|
215
213
|
|
|
216
|
-
for (const key in
|
|
217
|
-
const value =
|
|
214
|
+
for (const key in input) {
|
|
215
|
+
const value = input[key];
|
|
218
216
|
if (/^on[-A-Z]/.test(key) && typeof value === "function") {
|
|
219
217
|
(customEvents || (customEvents = {}))[toCustomEventName(key)] = [
|
|
220
218
|
value,
|
|
@@ -226,7 +224,8 @@ exports.p = function (domCompat) {
|
|
|
226
224
|
|
|
227
225
|
renderer(normalizedInput, out);
|
|
228
226
|
} else {
|
|
229
|
-
|
|
227
|
+
// Content a native tag renders has no arguments.
|
|
228
|
+
normalizedInput = input && input[0];
|
|
230
229
|
RenderBodyComponent({ renderBody, args: input }, out);
|
|
231
230
|
}
|
|
232
231
|
|
|
@@ -20,9 +20,7 @@ exports.p = function (htmlCompat) {
|
|
|
20
20
|
require("../load-tag").___tagsCompat = htmlCompat;
|
|
21
21
|
const writersByGlobal = new WeakMap();
|
|
22
22
|
const boundaryModeByRenderer = new WeakMap();
|
|
23
|
-
const
|
|
24
|
-
const isMarko5 = (fn) =>
|
|
25
|
-
typeof fn !== "function" || !htmlCompat.isTagsAPI(fn);
|
|
23
|
+
const isMarko5 = (fn) => !htmlCompat.isRenderer(fn);
|
|
26
24
|
const writeClassAPIResultToTagsAPI = ({ out }) => {
|
|
27
25
|
const { writer } = out._state;
|
|
28
26
|
htmlCompat.write(writer._content);
|
|
@@ -184,22 +182,18 @@ exports.p = function (htmlCompat) {
|
|
|
184
182
|
{},
|
|
185
183
|
);
|
|
186
184
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const renderer5 =
|
|
193
|
-
tag._ ||
|
|
194
|
-
tag.render ||
|
|
195
|
-
(tag.renderer && tag.renderer.renderer) ||
|
|
196
|
-
tag.renderer;
|
|
185
|
+
// The Tags runtime hands over what no Tags renderer matches: a Class template or
|
|
186
|
+
// Class content becomes a Tags renderer that writes its Class output in place.
|
|
187
|
+
htmlCompat.setClassAPIRenderer((tag) => {
|
|
188
|
+
if (htmlCompat.isRenderer(tag)) return tag;
|
|
189
|
+
const renderer5 = dynamicTag5.___getRenderer(tag);
|
|
197
190
|
const renderBody5 = tag.renderBody || tag;
|
|
198
191
|
|
|
199
|
-
if (!renderer5
|
|
192
|
+
if (!renderer5) {
|
|
193
|
+
if (typeof renderBody5 !== "function") return;
|
|
200
194
|
htmlCompat.registerRenderBody(renderBody5);
|
|
201
195
|
}
|
|
202
|
-
|
|
196
|
+
const render = (input, ...args) => {
|
|
203
197
|
// tags to class
|
|
204
198
|
const $global = htmlCompat.$global();
|
|
205
199
|
htmlCompat.ensureState($global);
|
|
@@ -260,9 +254,13 @@ exports.p = function (htmlCompat) {
|
|
|
260
254
|
|
|
261
255
|
if (async !== false) {
|
|
262
256
|
async = true;
|
|
263
|
-
htmlCompat.fork(
|
|
257
|
+
htmlCompat.fork(branchId, out, writeClassAPIResultToTagsAPI);
|
|
264
258
|
}
|
|
265
259
|
};
|
|
260
|
+
// Keyed by the value, which resumes as itself for a template and as a noop for
|
|
261
|
+
// content, so live content's first client render replaces the server's markup.
|
|
262
|
+
htmlCompat.setRendererId(render, tag);
|
|
263
|
+
return render;
|
|
266
264
|
});
|
|
267
265
|
|
|
268
266
|
return function register(id, renderer, boundaryMode) {
|
|
@@ -8,7 +8,6 @@ var VNode = require("./VNode");
|
|
|
8
8
|
var isTextOnly = require("./is-text-only");
|
|
9
9
|
var ATTR_XLINK_HREF = "xlink:href";
|
|
10
10
|
var xmlnsRegExp = /^xmlns(:|$)/;
|
|
11
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
12
11
|
var NS_XLINK = "http://www.w3.org/1999/xlink";
|
|
13
12
|
var NS_HTML = "http://www.w3.org/1999/xhtml";
|
|
14
13
|
var NS_MATH = "http://www.w3.org/1998/Math/MathML";
|
|
@@ -19,7 +18,6 @@ var DEFAULT_NS = {
|
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
var FLAG_SIMPLE_ATTRS = 1;
|
|
22
|
-
var FLAG_CUSTOM_ELEMENT = 2;
|
|
23
21
|
var FLAG_SPREAD_ATTRS = 4;
|
|
24
22
|
|
|
25
23
|
var ATTR_HREF = "href";
|
|
@@ -72,14 +70,6 @@ function normalizeValue(value) {
|
|
|
72
70
|
return value + "";
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
function assign(a, b) {
|
|
76
|
-
for (var key in b) {
|
|
77
|
-
if (hasOwnProperty.call(b, key)) {
|
|
78
|
-
a[key] = b[key];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
73
|
function VElementClone(other) {
|
|
84
74
|
this.___firstChildInternal = other.___firstChildInternal;
|
|
85
75
|
this.___parentNode = null;
|
|
@@ -174,30 +164,25 @@ VElement.prototype = {
|
|
|
174
164
|
var attributes = this.___attributes;
|
|
175
165
|
var namespaceURI = DEFAULT_NS[tagName] || parentNamespaceURI || NS_HTML;
|
|
176
166
|
|
|
177
|
-
var flags = this.___flags;
|
|
178
167
|
var el = (host.ownerDocument || host).createElementNS(
|
|
179
168
|
namespaceURI,
|
|
180
169
|
tagName,
|
|
181
170
|
);
|
|
182
171
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} else {
|
|
186
|
-
for (var attrName in attributes) {
|
|
187
|
-
var attrValue = normalizeValue(attributes[attrName]);
|
|
172
|
+
for (var attrName in attributes) {
|
|
173
|
+
var attrValue = normalizeValue(attributes[attrName]);
|
|
188
174
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
175
|
+
if (attrValue !== undefined) {
|
|
176
|
+
if (attrName == ATTR_XLINK_HREF) {
|
|
177
|
+
el.setAttributeNS(NS_XLINK, ATTR_HREF, attrValue);
|
|
178
|
+
} else {
|
|
179
|
+
el.setAttribute(attrName, attrValue);
|
|
195
180
|
}
|
|
196
181
|
}
|
|
182
|
+
}
|
|
197
183
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
184
|
+
if (isTextOnly(tagName)) {
|
|
185
|
+
el.textContent = this.___textContent;
|
|
201
186
|
}
|
|
202
187
|
|
|
203
188
|
vElementByDOMNode.set(el, this);
|
|
@@ -266,10 +251,6 @@ VElement.___morphAttrs = function (fromEl, vFromEl, toEl) {
|
|
|
266
251
|
var toFlags = toEl.___flags;
|
|
267
252
|
var attrs = toEl.___attributes;
|
|
268
253
|
|
|
269
|
-
if (toFlags & FLAG_CUSTOM_ELEMENT) {
|
|
270
|
-
return assign(fromEl, attrs);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
254
|
var props = toEl.___properties;
|
|
274
255
|
var attrName;
|
|
275
256
|
|
package/src/taglib/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// eslint-disable-next-line no-constant-binary-expression
|
|
4
4
|
let complain = "MARKO_DEBUG" && require("complain");
|
|
5
5
|
const compiler = require("@marko/compiler");
|
|
6
|
+
const path = require("path");
|
|
6
7
|
|
|
7
8
|
function clearCache() {
|
|
8
9
|
compiler.taglib.clearCaches();
|
|
@@ -12,11 +13,9 @@ function register(taglibProps, taglibPath) {
|
|
|
12
13
|
return compiler.taglib.register(taglibPath, taglibProps);
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
// A path relative to the working directory, as it was read before.
|
|
15
17
|
function registerFromFile(taglibPath) {
|
|
16
|
-
return register(
|
|
17
|
-
compiler.taglib._loader.loadTaglibFromFile(taglibPath),
|
|
18
|
-
taglibPath,
|
|
19
|
-
);
|
|
18
|
+
return register(undefined, path.resolve(taglibPath));
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
exports.clearCache = clearCache;
|
|
@@ -25,8 +24,6 @@ exports.registerFromFile = registerFromFile;
|
|
|
25
24
|
exports.buildLookup = compiler.taglib.buildLookup;
|
|
26
25
|
exports.excludeDir = compiler.taglib.excludeDir;
|
|
27
26
|
exports.excludePackage = compiler.taglib.excludePackage;
|
|
28
|
-
exports.loader = compiler.taglib._loader;
|
|
29
|
-
exports.finder = compiler.taglib._finder;
|
|
30
27
|
exports.lookup = {
|
|
31
28
|
buildLookup: function (dir, translator) {
|
|
32
29
|
if (!translator || !Array.isArray(translator.taglibs)) {
|
package/src/translator/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { resolve } from "path";
|
|
2
|
-
|
|
3
1
|
import { types as t } from "@marko/compiler";
|
|
4
2
|
import {
|
|
5
3
|
findParentTag,
|
|
@@ -39,6 +37,9 @@ const CLASS_HYDRATION_DESCENDANT = "descendant";
|
|
|
39
37
|
|
|
40
38
|
export const version = markoPkg.version;
|
|
41
39
|
export const tagDiscoveryDirs = ["components"];
|
|
40
|
+
// Its taglibs declare attributes, nested tags and renderers, and its tag folders
|
|
41
|
+
// take renderers, hook files and older template names.
|
|
42
|
+
export const classTaglibs = true;
|
|
42
43
|
export { optionalTaglibs, default as taglibs } from "./taglib";
|
|
43
44
|
export { entryBuilder as internalEntryBuilder } from "./util/add-dependencies";
|
|
44
45
|
|
|
@@ -105,19 +106,7 @@ export const analyze = {
|
|
|
105
106
|
let relativePath;
|
|
106
107
|
|
|
107
108
|
if (tagDef) {
|
|
108
|
-
if (
|
|
109
|
-
if (tagDef.htmlType === "custom-element") {
|
|
110
|
-
if (tagDef.parseOptions && tagDef.parseOptions.import) {
|
|
111
|
-
// TODO: the taglib should be updated to support this as a top level option.
|
|
112
|
-
meta.deps.push(
|
|
113
|
-
resolve(
|
|
114
|
-
tagDef.dir,
|
|
115
|
-
resolve(tagDef.dir, tagDef.parseOptions.import),
|
|
116
|
-
),
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
} else if (t.isStringLiteral(tag.node.name)) {
|
|
109
|
+
if (!isNativeTag(tag)) {
|
|
121
110
|
relativePath = resolveRelativeTagEntry(file, tagDef);
|
|
122
111
|
}
|
|
123
112
|
|
|
@@ -130,11 +119,7 @@ export const analyze = {
|
|
|
130
119
|
const tagName = tag.node.name.value;
|
|
131
120
|
const binding =
|
|
132
121
|
/^[A-Z][a-zA-Z0-9_$]*$/.test(tagName) && tag.scope.getBinding(tagName);
|
|
133
|
-
if (
|
|
134
|
-
binding &&
|
|
135
|
-
binding.path.isImportDefaultSpecifier() &&
|
|
136
|
-
binding.identifier.loc
|
|
137
|
-
) {
|
|
122
|
+
if (binding && binding.path.isImportDefaultSpecifier()) {
|
|
138
123
|
const importSource = binding.path.parent.source.value;
|
|
139
124
|
relativePath = resolveTagImport(tag, importSource) || importSource;
|
|
140
125
|
tag.node.extra = tag.node.extra || {};
|
|
@@ -168,7 +153,7 @@ export const analyze = {
|
|
|
168
153
|
// expression (identifiers, conditionals, etc.) to detect the boundary.
|
|
169
154
|
const markIfTagsImport = (scope, name) => {
|
|
170
155
|
const binding = name && scope.getBinding(name);
|
|
171
|
-
if (binding && binding.kind === "module"
|
|
156
|
+
if (binding && binding.kind === "module") {
|
|
172
157
|
const childFile = loadFileForImport(
|
|
173
158
|
file,
|
|
174
159
|
binding.path.parent.source.value,
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTagDef,
|
|
3
|
-
importDefault,
|
|
4
|
-
isNativeTag,
|
|
5
|
-
} from "@marko/compiler/babel-utils";
|
|
1
|
+
import { importDefault, isNativeTag } from "@marko/compiler/babel-utils";
|
|
6
2
|
|
|
7
3
|
import directives from "./directives";
|
|
8
4
|
import modifiers from "./modifiers";
|
|
@@ -91,18 +87,6 @@ export default {
|
|
|
91
87
|
return;
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
const tagDef = getTagDef(tag);
|
|
95
|
-
|
|
96
|
-
if (tagDef) {
|
|
97
|
-
if (!tagDef.html && !tagDef.getAttribute(name)) {
|
|
98
|
-
throw attr.buildCodeFrameError(
|
|
99
|
-
`<${
|
|
100
|
-
tag.get("name.value").node
|
|
101
|
-
}> does not support the "${name}" attribute.`,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
90
|
if (args && args.length) {
|
|
107
91
|
throw attr.buildCodeFrameError(
|
|
108
92
|
`Unsupported arguments on the "${name}" attribute.`,
|