marko 5.22.4 → 5.22.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @template T
3
3
  * @typedef {{
4
- * value?: T;
5
- * then?: Marko.Body<[Awaited<T>], void>;
6
- * catch?: Marko.Body<[unknown], void>;
7
- * placeholder?: Marko.Body<[], void>;
8
- * client-reorder?: boolean;
4
+ * value?: readonly [T];
5
+ * then?: { renderBody: Marko.Body<[Awaited<T>], void> };
6
+ * catch?: { renderBody: Marko.Body<[unknown], void> };
7
+ * placeholder?: { renderBody: Marko.Body<[], void> };
8
+ * "client-reorder"?: boolean;
9
9
  * name?: string;
10
10
  * timeout?: number;
11
- * show-after?: string;
11
+ * "show-after"?: string;
12
12
  * }} Input
13
13
  */
@@ -10,4 +10,8 @@ exports.register = function (id, component) {
10
10
  registry.r(id, function () {
11
11
  return component;
12
12
  });
13
+ };
14
+
15
+ window.Marko = {
16
+ Component: function () {}
13
17
  };
@@ -270,4 +270,8 @@ exports.writeInitComponentsCode = writeInitComponentsCode;
270
270
  */
271
271
  exports.getRenderedComponents = function (out) {
272
272
  return warp10.stringifyPrepare(getInitComponentsDataFromOut(out));
273
+ };
274
+
275
+ globalThis.Marko = {
276
+ Component: function () {}
273
277
  };
package/index.d.ts CHANGED
@@ -78,15 +78,11 @@ declare namespace Marko {
78
78
  > {}
79
79
 
80
80
  /** Valid data types which can be passed in as a <${dynamic}/> tag name. */
81
- export type DynamicTagName =
82
- | {
83
- renderBody?: Body<any, any> | Template | string | void | false;
84
- }
81
+ export type Renderable =
82
+ | { renderBody: Body<any, any> | Template | string }
85
83
  | Body<any, any>
86
84
  | Template
87
- | string
88
- | void
89
- | false;
85
+ | string;
90
86
 
91
87
  /** Extract the return tag type from a renderBody. */
92
88
  export type BodyReturnType<B> = B extends Body<any, infer Return>
@@ -94,12 +90,16 @@ declare namespace Marko {
94
90
  : never;
95
91
 
96
92
  /** Extract the tag parameter types received by a renderBody. */
97
- export type BodyParamaters<B> = B extends Body<infer Params, any>
93
+ export type BodyParameters<B> = B extends Body<infer Params, any>
98
94
  ? Params
99
95
  : never;
100
96
 
101
- export abstract class Component<
102
- Input extends Record<PropertyKey, any> = Record<PropertyKey, any>
97
+ export class Component<
98
+ Input extends Record<PropertyKey, any> = Record<PropertyKey, any>,
99
+ State extends undefined | null | Record<PropertyKey, any> =
100
+ | undefined
101
+ | null
102
+ | Record<PropertyKey, any>
103
103
  > implements Emitter
104
104
  {
105
105
  /** A unique id for this instance. */
@@ -111,7 +111,7 @@ declare namespace Marko {
111
111
  /** @deprecated */
112
112
  public readonly els: Element[];
113
113
  /** Mutable state that when changed causes a rerender. */
114
- abstract state: undefined | null | Record<PropertyKey, any>;
114
+ state: State;
115
115
 
116
116
  /** Returns the amount of event handlers listening to a specific event. */
117
117
  listenerCount(eventName: PropertyKey): number;
@@ -197,20 +197,17 @@ declare namespace Marko {
197
197
  /** Replaces the children of an existing DOM element with the dom for the current instance. */
198
198
  replaceChildrenOf(target: ParentNode): this;
199
199
  /** Called when the component is firsted created. */
200
- abstract onCreate?(input: this["input"], out: Marko.Out): void;
200
+ onCreate?(input: this["input"], out: Marko.Out): void;
201
201
  /** Called every time the component receives input from it's parent. */
202
- abstract onInput?(
203
- input: this["input"],
204
- out: Marko.Out
205
- ): void | this["input"];
202
+ onInput?(input: this["input"], out: Marko.Out): void | this["input"];
206
203
  /** Called after a component has successfully rendered, but before it's update has been applied to the dom. */
207
- abstract onRender?(out: Marko.Out): void;
204
+ onRender?(out: Marko.Out): void;
208
205
  /** Called after the first time the component renders and is attached to the dom. */
209
- abstract onMount?(): void;
206
+ onMount?(): void;
210
207
  /** Called when a components render has been applied to the DOM (excluding when it is initially mounted). */
211
- abstract onUpdate?(): void;
208
+ onUpdate?(): void;
212
209
  /** Called when a component is destroyed and removed from the dom. */
213
- abstract onDestroy?(): void;
210
+ onDestroy?(): void;
214
211
  }
215
212
 
216
213
  /** The top level api for a Marko Template. */
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.22.4",
3
+ "version": "5.22.6",
4
4
  "license": "MIT",
5
5
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
6
6
  "dependencies": {
7
- "@marko/compiler": "^5.23.4",
8
- "@marko/translator-default": "^5.22.4",
7
+ "@marko/compiler": "^5.23.5",
8
+ "@marko/translator-default": "^5.22.5",
9
9
  "app-module-path": "^2.2.0",
10
10
  "argly": "^1.2.0",
11
11
  "browser-refresh-client": "1.1.4",
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @template T
3
3
  * @typedef {{
4
- * value?: T;
5
- * then?: Marko.Body<[Awaited<T>], void>;
6
- * catch?: Marko.Body<[unknown], void>;
7
- * placeholder?: Marko.Body<[], void>;
8
- * client-reorder?: boolean;
4
+ * value?: readonly [T];
5
+ * then?: { renderBody: Marko.Body<[Awaited<T>], void> };
6
+ * catch?: { renderBody: Marko.Body<[unknown], void> };
7
+ * placeholder?: { renderBody: Marko.Body<[], void> };
8
+ * "client-reorder"?: boolean;
9
9
  * name?: string;
10
10
  * timeout?: number;
11
- * show-after?: string;
11
+ * "show-after"?: string;
12
12
  * }} Input
13
13
  */
@@ -11,3 +11,7 @@ exports.register = function (id, component) {
11
11
  return component;
12
12
  });
13
13
  };
14
+
15
+ window.Marko = {
16
+ Component: function () {}
17
+ };
@@ -271,3 +271,7 @@ exports.writeInitComponentsCode = writeInitComponentsCode;
271
271
  exports.getRenderedComponents = function (out) {
272
272
  return warp10.stringifyPrepare(getInitComponentsDataFromOut(out));
273
273
  };
274
+
275
+ globalThis.Marko = {
276
+ Component: function () {}
277
+ };