marko 5.37.43 → 5.37.44

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  // eslint-disable-next-line no-constant-binary-expression
3
3
 
4
+ var getRenderId = require("../../../runtime/html/get-render-id");
4
5
  var AsyncValue = require("./AsyncValue");
5
6
 
6
7
  function safeRenderBody(renderBody, targetOut, data) {
@@ -124,7 +125,7 @@ module.exports = function awaitTag(input, out) {
124
125
 
125
126
  var id = awaitInfo.id =
126
127
  input.name ||
127
- (out.global.componentIdPrefix || 0) + clientReorderContext.nextId++;
128
+ (getRenderId(out.global) || 0) + clientReorderContext.nextId++;
128
129
  var placeholderIdAttrValue = reorderFunctionId + "ph" + id;
129
130
 
130
131
  if (placeholderRenderer) {
@@ -3,6 +3,7 @@ require("../../../runtime/html/marko-namespace");
3
3
 
4
4
  var warp10 = require("warp10");
5
5
  var w10ToJSON = require("../../../runtime/helpers/serialize-noop").V_;
6
+ var getRenderId = require("../../../runtime/html/get-render-id");
6
7
  var safeJSONRegExp = /<\/|\u2028|\u2029/g;
7
8
  var IGNORE_GLOBAL_TYPES = new Set(["undefined", "function", "symbol"]);
8
9
  var DEFAULT_RUNTIME_ID = "M";
@@ -187,7 +188,7 @@ function getInitComponentsData(out, componentDefs) {
187
188
  const $global = out.global;
188
189
  const isLast = $global.d_;
189
190
  const didSerializeComponents = $global._e_;
190
- const prefix = $global.componentIdPrefix || $global.widgetIdPrefix;
191
+ const prefix = getRenderId($global);
191
192
 
192
193
  if (len === 0) {
193
194
  if (isLast && didSerializeComponents) {
@@ -476,6 +476,7 @@ function initServerRendered(renderedComponents, host) {
476
476
 
477
477
  if (!meta._B_) {
478
478
  meta._B_ = Object.assign({
479
+ renderId: prefix,
479
480
  runtimeId: runtimeId,
480
481
  componentIdPrefix: prefix
481
482
  }, renderedComponents.g);
@@ -1,20 +1,12 @@
1
- "use strict";var FLAG_WILL_RERENDER_IN_BROWSER = 1;
1
+ "use strict";var getRenderId = require("../../../runtime/html/get-render-id");
2
+
3
+ var FLAG_WILL_RERENDER_IN_BROWSER = 1;
2
4
  // var FLAG_HAS_RENDER_BODY = 2;
3
5
 
4
6
  function nextComponentIdProvider(out) {
5
- var prefix = out.global.componentIdPrefix || out.global.widgetIdPrefix || "s"; // "s" is for server (we use "b" for the browser)
7
+ var prefix = getRenderId(out.global) || "s"; // "s" is for server (we use "b" for the browser)
6
8
  var nextId = 0;
7
9
 
8
- // eslint-disable-next-line no-constant-condition
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
10
  return function nextComponentId() {
19
11
  return prefix + nextId++;
20
12
  };
@@ -78,7 +78,7 @@ exports.p = function (htmlCompat) {
78
78
  htmlCompat.registerRenderBody(renderBody5);
79
79
  }
80
80
  return (input, ...args) => {
81
- const out = defaultCreateOut();
81
+ const out = defaultCreateOut(htmlCompat.$global());
82
82
  let customEvents;
83
83
 
84
84
  if (renderer5) {
@@ -0,0 +1,20 @@
1
+ "use strict";module.exports = function getRenderId($global) {
2
+ if (!("renderId" in $global)) {
3
+ $global.renderId =
4
+ $global.componentIdPrefix || $global.widgetIdPrefix || "s";
5
+
6
+ // eslint-disable-next-line no-constant-condition
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ }
16
+
17
+ if ($global.renderId !== "s") {
18
+ return $global.renderId;
19
+ }
20
+ };
package/index.d.ts CHANGED
@@ -13,15 +13,21 @@ declare global {
13
13
  namespace Marko {
14
14
  /** A mutable global object for the current render. */
15
15
  export interface Global {
16
- /** A list of globals that should be serialized to the browser. */
17
- serializedGlobals?: Record<string, boolean>;
16
+ [x: PropertyKey]: unknown;
17
+ /** An AbortSignal instance that, when aborted, stops further streamed content. */
18
+ signal?: AbortSignal;
18
19
  /** A CSP Nonce to add to each script output from Marko. */
19
20
  cspNonce?: string;
21
+ /** Used for rendering multiple Marko templates in a single hydrated page. */
22
+ renderId?: string;
20
23
  /** Used to uniquely identify a instance of a Marko runtime. */
21
24
  runtimeId?: string;
22
- /** Used for rendering multiple Marko templates in a single hydrated page. */
25
+ /** A list of globals that should be serialized to the browser. */
26
+ serializedGlobals?: Record<string, boolean>;
27
+ /** @deprecated prefer `renderId` */
28
+ widgetIdPrefix?: string;
29
+ /** @deprecated prefer `renderId` */
23
30
  componentIdPrefix?: string;
24
- [attr: PropertyKey]: unknown;
25
31
  }
26
32
 
27
33
  export type TemplateInput<Input> = Input & {
@@ -29,9 +35,9 @@ declare global {
29
35
  };
30
36
 
31
37
  /** The result of calling `template.render`. */
32
- export type RenderedTemplate<
33
- Component extends Marko.Component = Marko.Component,
34
- > = Promise<RenderResult<Component>> &
38
+ export type RenderedTemplate<Component = unknown> = Promise<
39
+ Component extends Marko.Component ? RenderResult<Component> : string
40
+ > &
35
41
  AsyncIterable<string> & {
36
42
  toReadable(): ReadableStream<Uint8Array<ArrayBufferLike>>;
37
43
  pipe(stream: {
@@ -44,11 +50,17 @@ declare global {
44
50
 
45
51
  /** The result of calling `template.mount`. */
46
52
  export type MountedTemplate<Input = unknown, Return = unknown> = {
53
+ get value(): Return extends { value: infer Value } ? Value : void;
54
+ set value(
55
+ next: Return extends { valueChange?(next: infer Next): any }
56
+ ? Next
57
+ : never,
58
+ ): void;
47
59
  update(input: Marko.TemplateInput<Input>): void;
48
60
  destroy(): void;
49
61
  };
50
62
 
51
- export interface Out<Component extends Marko.Component = Marko.Component>
63
+ export interface Out<Component = unknown>
52
64
  extends Marko.RenderedTemplate<Component> {
53
65
  /** The underlying ReadableStream Marko is writing into. */
54
66
  stream: unknown;
@@ -102,7 +114,10 @@ declare global {
102
114
 
103
115
  /** Valid data types which can be passed in as a <${dynamic}/> tag name. */
104
116
  export type Renderable =
105
- | { renderBody: Body<any, any> | Template | string }
117
+ | {
118
+ content?: Body<any, any> | Template | string;
119
+ renderBody?: Body<any, any> | Template | string;
120
+ }
106
121
  | Body<any, any>
107
122
  | Template
108
123
  | string;
@@ -337,11 +352,6 @@ declare global {
337
352
  [Symbol.iterator](): Iterator<T>;
338
353
  };
339
354
 
340
- /**
341
- * @deprecated Prefer to use AttrTag
342
- */
343
- export type RepeatableAttrTag<T> = AttrTag<T>;
344
-
345
355
  export interface NativeTag<
346
356
  Input extends Record<string, any>,
347
357
  Return extends Element,
@@ -388,6 +398,9 @@ declare global {
388
398
  ? Return
389
399
  : never;
390
400
 
401
+ /** @deprecated @see {@link Marko.AttrTag} */
402
+ export type RepeatableAttrTag<T> = AttrTag<T>;
403
+
391
404
  /** @deprecated @see {@link Marko.Input} */
392
405
  export type NativeTagInput<Name extends keyof NativeTags> =
393
406
  NativeTags[Name]["input"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.37.43",
3
+ "version": "5.37.44",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@babel/runtime": "^7.28.2",
73
- "@marko/compiler": "^5.39.32",
73
+ "@marko/compiler": "^5.39.33",
74
74
  "app-module-path": "^2.2.0",
75
75
  "argly": "^1.2.0",
76
76
  "browser-refresh-client": "1.1.4",
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  // eslint-disable-next-line no-constant-binary-expression
3
3
  var complain = "MARKO_DEBUG" && require("complain");
4
+ var getRenderId = require("../../../runtime/html/get-render-id");
4
5
  var AsyncValue = require("./AsyncValue");
5
6
 
6
7
  function safeRenderBody(renderBody, targetOut, data) {
@@ -124,7 +125,7 @@ module.exports = function awaitTag(input, out) {
124
125
 
125
126
  var id = (awaitInfo.id =
126
127
  input.name ||
127
- (out.global.componentIdPrefix || 0) + clientReorderContext.nextId++);
128
+ (getRenderId(out.global) || 0) + clientReorderContext.nextId++);
128
129
  var placeholderIdAttrValue = reorderFunctionId + "ph" + id;
129
130
 
130
131
  if (placeholderRenderer) {
@@ -3,6 +3,7 @@ require("../../../runtime/html/marko-namespace");
3
3
 
4
4
  var warp10 = require("warp10");
5
5
  var w10ToJSON = require("../../../runtime/helpers/serialize-noop").___toJSON;
6
+ var getRenderId = require("../../../runtime/html/get-render-id");
6
7
  var safeJSONRegExp = /<\/|\u2028|\u2029/g;
7
8
  var IGNORE_GLOBAL_TYPES = new Set(["undefined", "function", "symbol"]);
8
9
  var DEFAULT_RUNTIME_ID = "M";
@@ -187,7 +188,7 @@ function getInitComponentsData(out, componentDefs) {
187
188
  const $global = out.global;
188
189
  const isLast = $global.___isLastFlush;
189
190
  const didSerializeComponents = $global.___didSerializeComponents;
190
- const prefix = $global.componentIdPrefix || $global.widgetIdPrefix;
191
+ const prefix = getRenderId($global);
191
192
 
192
193
  if (len === 0) {
193
194
  if (isLast && didSerializeComponents) {
@@ -476,6 +476,7 @@ function initServerRendered(renderedComponents, host) {
476
476
 
477
477
  if (!meta.___globals) {
478
478
  meta.___globals = Object.assign({
479
+ renderId: prefix,
479
480
  runtimeId: runtimeId,
480
481
  componentIdPrefix: prefix,
481
482
  }, renderedComponents.g);
@@ -1,20 +1,12 @@
1
+ var getRenderId = require("../../../runtime/html/get-render-id");
2
+
1
3
  var FLAG_WILL_RERENDER_IN_BROWSER = 1;
2
4
  // var FLAG_HAS_RENDER_BODY = 2;
3
5
 
4
6
  function nextComponentIdProvider(out) {
5
- var prefix = out.global.componentIdPrefix || out.global.widgetIdPrefix || "s"; // "s" is for server (we use "b" for the browser)
7
+ var prefix = getRenderId(out.global) || "s"; // "s" is for server (we use "b" for the browser)
6
8
  var nextId = 0;
7
9
 
8
- // eslint-disable-next-line no-constant-condition
9
- if ("MARKO_DEBUG") {
10
- if (out.global.widgetIdPrefix) {
11
- require("complain")(
12
- "$global.widgetIdPrefix is deprecated. use $global.componentIdPrefix instead.",
13
- { location: false }
14
- );
15
- }
16
- }
17
-
18
10
  return function nextComponentId() {
19
11
  return prefix + nextId++;
20
12
  };
@@ -78,7 +78,7 @@ exports.p = function (htmlCompat) {
78
78
  htmlCompat.registerRenderBody(renderBody5);
79
79
  }
80
80
  return (input, ...args) => {
81
- const out = defaultCreateOut();
81
+ const out = defaultCreateOut(htmlCompat.$global());
82
82
  let customEvents;
83
83
 
84
84
  if (renderer5) {
@@ -0,0 +1,20 @@
1
+ module.exports = function getRenderId($global) {
2
+ if (!("renderId" in $global)) {
3
+ $global.renderId =
4
+ $global.componentIdPrefix || $global.widgetIdPrefix || "s";
5
+
6
+ // eslint-disable-next-line no-constant-condition
7
+ if ("MARKO_DEBUG") {
8
+ if ($global.renderId !== "s") {
9
+ require("complain")(
10
+ "$global.componentIdPrefix and $global.widgetIdPrefix are deprecated. Use $global.renderId instead.",
11
+ { location: false },
12
+ );
13
+ }
14
+ }
15
+ }
16
+
17
+ if ($global.renderId !== "s") {
18
+ return $global.renderId;
19
+ }
20
+ };
package/tags-html.d.ts CHANGED
@@ -2571,6 +2571,12 @@ declare global {
2571
2571
  */
2572
2572
  renderBody?: Marko.Body<[], void>;
2573
2573
 
2574
+ /**
2575
+ * Provide body content for the tag as a Marko.Body.
2576
+ * @see Marko.Body
2577
+ */
2578
+ content?: Marko.Body<[], void>;
2579
+
2574
2580
  /**
2575
2581
  * Fired when resource was not fully loaded, but not as the result of an error.
2576
2582
  * @see https://html.spec.whatwg.org/multipage/media.html#event-media-abort