marko 6.0.31 → 6.0.32

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.
@@ -80,6 +80,7 @@ export interface Template {
80
80
  render(input?: Input): RenderedTemplate;
81
81
  }
82
82
  export interface MountedTemplate {
83
+ value: unknown;
83
84
  update(input: unknown): void;
84
85
  destroy(): void;
85
86
  }
package/dist/debug/dom.js CHANGED
@@ -2303,6 +2303,7 @@ function mount(input = {}, reference, position) {
2303
2303
  nextSibling = reference.nextSibling;
2304
2304
  break;
2305
2305
  }
2306
+ let curValue;
2306
2307
  const args = this.___params;
2307
2308
  const effects = prepareEffects(() => {
2308
2309
  branch = createBranch(
@@ -2311,6 +2312,9 @@ function mount(input = {}, reference, position) {
2311
2312
  void 0,
2312
2313
  parentNode
2313
2314
  );
2315
+ branch["#TagVariable" /* TagVariable */] = (newValue) => {
2316
+ curValue = newValue;
2317
+ };
2314
2318
  this.___setup?.(branch);
2315
2319
  args?.(branch, input);
2316
2320
  });
@@ -2322,6 +2326,12 @@ function mount(input = {}, reference, position) {
2322
2326
  );
2323
2327
  runEffects(effects);
2324
2328
  return {
2329
+ get value() {
2330
+ return curValue;
2331
+ },
2332
+ set value(newValue) {
2333
+ tagVarSignalChange(branch, newValue);
2334
+ },
2325
2335
  update(newInput) {
2326
2336
  if (args) {
2327
2337
  runEffects(
@@ -2210,6 +2210,7 @@ function mount(input = {}, reference, position) {
2210
2210
  nextSibling = reference.nextSibling;
2211
2211
  break;
2212
2212
  }
2213
+ let curValue;
2213
2214
  const args = this.___params;
2214
2215
  const effects = prepareEffects(() => {
2215
2216
  branch = createBranch(
@@ -2218,6 +2219,9 @@ function mount(input = {}, reference, position) {
2218
2219
  void 0,
2219
2220
  parentNode
2220
2221
  );
2222
+ branch["#TagVariable" /* TagVariable */] = (newValue) => {
2223
+ curValue = newValue;
2224
+ };
2221
2225
  this.___setup?.(branch);
2222
2226
  args?.(branch, input);
2223
2227
  });
@@ -2229,6 +2233,12 @@ function mount(input = {}, reference, position) {
2229
2233
  );
2230
2234
  runEffects(effects);
2231
2235
  return {
2236
+ get value() {
2237
+ return curValue;
2238
+ },
2239
+ set value(newValue) {
2240
+ tagVarSignalChange(branch, newValue);
2241
+ },
2232
2242
  update(newInput) {
2233
2243
  if (args) {
2234
2244
  runEffects(
@@ -1,3 +1,3 @@
1
- import type { Scope, Template } from "../common/types";
2
- import type { Signal } from "./signals";
1
+ import { type Scope, type Template } from "../common/types";
2
+ import { type Signal } from "./signals";
3
3
  export declare const createTemplate: (id: string, template: string | 0, walks?: string | 0, setup?: ((scope: Scope) => void) | 0, inputSignal?: Signal<unknown>) => Template;
package/dist/dom.js CHANGED
@@ -1509,13 +1509,15 @@ function mount(input = {}, reference, position) {
1509
1509
  parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1510
1510
  break;
1511
1511
  }
1512
- let args = this.m, effects = prepareEffects(() => {
1512
+ let curValue, args = this.m, effects = prepareEffects(() => {
1513
1513
  branch = createBranch(
1514
1514
  $global,
1515
1515
  this,
1516
1516
  void 0,
1517
1517
  parentNode
1518
- ), this.D?.(branch), args?.(branch, input);
1518
+ ), branch.e = (newValue) => {
1519
+ curValue = newValue;
1520
+ }, this.D?.(branch), args?.(branch, input);
1519
1521
  });
1520
1522
  return insertChildNodes(
1521
1523
  parentNode,
@@ -1523,6 +1525,12 @@ function mount(input = {}, reference, position) {
1523
1525
  branch.h,
1524
1526
  branch.j
1525
1527
  ), runEffects(effects), {
1528
+ get value() {
1529
+ return curValue;
1530
+ },
1531
+ set value(newValue) {
1532
+ tagVarSignalChange(branch, newValue);
1533
+ },
1526
1534
  update(newInput) {
1527
1535
  args && runEffects(
1528
1536
  prepareEffects(() => {
package/dist/dom.mjs CHANGED
@@ -1419,13 +1419,15 @@ function mount(input = {}, reference, position) {
1419
1419
  parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1420
1420
  break;
1421
1421
  }
1422
- let args = this.m, effects = prepareEffects(() => {
1422
+ let curValue, args = this.m, effects = prepareEffects(() => {
1423
1423
  branch = createBranch(
1424
1424
  $global,
1425
1425
  this,
1426
1426
  void 0,
1427
1427
  parentNode
1428
- ), this.D?.(branch), args?.(branch, input);
1428
+ ), branch.e = (newValue) => {
1429
+ curValue = newValue;
1430
+ }, this.D?.(branch), args?.(branch, input);
1429
1431
  });
1430
1432
  return insertChildNodes(
1431
1433
  parentNode,
@@ -1433,6 +1435,12 @@ function mount(input = {}, reference, position) {
1433
1435
  branch.h,
1434
1436
  branch.j
1435
1437
  ), runEffects(effects), {
1438
+ get value() {
1439
+ return curValue;
1440
+ },
1441
+ set value(newValue) {
1442
+ tagVarSignalChange(branch, newValue);
1443
+ },
1436
1444
  update(newInput) {
1437
1445
  args && runEffects(
1438
1446
  prepareEffects(() => {
@@ -3313,13 +3313,17 @@ function getTranslatedExtraArgs(signal) {
3313
3313
  }
3314
3314
  return emptyExtraArgs;
3315
3315
  }
3316
- function subscribe(provider, subscriber) {
3317
- if (Array.isArray(provider)) {
3318
- provider.forEach((p) => subscribe(p, subscriber));
3319
- return;
3316
+ function subscribe(references, subscriber) {
3317
+ if (references) {
3318
+ forEach(references, (binding) => {
3319
+ const source = binding.property === void 0 && binding.upstreamAlias || binding;
3320
+ const providerSignal = getSignal(subscriber.section, source);
3321
+ providerSignal.intersection = push(
3322
+ providerSignal.intersection,
3323
+ subscriber
3324
+ );
3325
+ });
3320
3326
  }
3321
- const providerSignal = getSignal(subscriber.section, provider);
3322
- providerSignal.intersection = push(providerSignal.intersection, subscriber);
3323
3327
  }
3324
3328
  function generateSignalName(referencedBindings) {
3325
3329
  let name2;
@@ -35,7 +35,7 @@ export declare function getHoistFunctionIdentifier(hoistedBinding: Binding): t.I
35
35
  export declare function getSignal(section: Section, referencedBindings: ReferencedBindings, name?: string): Signal;
36
36
  export declare function initValue(binding: Binding, runtimeHelper?: "value" | "state"): Signal;
37
37
  export declare function getSignalFn(signal: Signal): t.Expression;
38
- export declare function subscribe(provider: ReferencedBindings, subscriber: Signal): void;
38
+ export declare function subscribe(references: ReferencedBindings, subscriber: Signal): void;
39
39
  export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
40
40
  export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], usedReferences?: ReferencedBindings[] | false): void;
41
41
  export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal["values"][number]["signal"], value: t.Expression): void;
package/index.d.ts CHANGED
@@ -46,7 +46,8 @@ declare global {
46
46
  };
47
47
 
48
48
  /** The result of calling `template.mount`. */
49
- export type MountedTemplate<Input = unknown> = {
49
+ export type MountedTemplate<Input = unknown, Return = unknown> = {
50
+ value: Return;
50
51
  update(input: Marko.TemplateInput<Input>): void;
51
52
  destroy(): void;
52
53
  };
@@ -95,7 +96,7 @@ declare global {
95
96
  input: Marko.TemplateInput<Input>,
96
97
  reference: Node,
97
98
  position?: "afterbegin" | "afterend" | "beforebegin" | "beforeend",
98
- ): Marko.MountedTemplate<typeof input>;
99
+ ): Marko.MountedTemplate<typeof input, Return>;
99
100
  /** @marko-overload-end */
100
101
  }
101
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.31",
3
+ "version": "6.0.32",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",