@patterkit/runtime 0.2.0 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [34429f0]
8
+ - Updated dependencies [34429f0]
9
+ - Updated dependencies [c61c146]
10
+ - @patterkit/model@0.2.0
11
+ - @patterkit/dialect@0.1.3
12
+
3
13
  All notable changes to `@patterkit/runtime` (Patterplay JS) are documented here. The
4
14
  Patterplay runtimes - JS, Unity, Unreal, and Godot - are versioned in lockstep: the same
5
15
  version number always means the same runtime behaviour. This package is versioned by
@@ -7,9 +17,17 @@ version number always means the same runtime behaviour. This package is versione
7
17
 
8
18
  ## [Unreleased]
9
19
 
20
+ ## [0.2.2] - 2026-07-13
21
+
22
+ ### Changed
23
+ - Internal: the Best match (`specificity`) selection metric now uses the shared
24
+ `@wildwinter/expr-specificity` package instead of a per-engine inline copy. Behaviour is
25
+ unchanged and conformance-verified across all four engines.
26
+
10
27
  ## [0.2.0] - 2026-07-07
11
28
 
12
29
  ### Added
30
+
13
31
  - **Best match** selection (a new `sequence` order, `specificity`): among the eligible children,
14
32
  play the one whose condition most specifically fits the current state; equally-specific ties break
15
33
  by the seeded shuffle, and a condition-less child is the filler that wins only when nothing more
@@ -19,6 +37,7 @@ version number always means the same runtime behaviour. This package is versione
19
37
  ## [0.1.0] - 2026-07-04
20
38
 
21
39
  ### Added
40
+
22
41
  - The Patter runtime in JS/TS: `Engine` + `Flow` over a compiled `.patterc` bundle - scenes,
23
42
  blocks, run/choice/branch/sequence selectors, sticky/fallback options, call-return jumps,
24
43
  conditions + effects, visit counts, `{@ref}` interpolation, game events, tags, gameData
package/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ module.exports = __toCommonJS(index_exports);
31
31
 
32
32
  // src/engine.ts
33
33
  var import_expr = require("@wildwinter/expr");
34
+ var import_expr_specificity = require("@wildwinter/expr-specificity");
34
35
  var import_scoperegistry = require("@wildwinter/scoperegistry");
35
36
  var import_dialect = require("@patterkit/dialect");
36
37
  var import_model = require("@patterkit/model");
@@ -1036,21 +1037,8 @@ var Flow = class {
1036
1037
  * node (comparisons, scoped vars, literals, other calls) is an atom, evaluated whole.
1037
1038
  */
1038
1039
  matchedSpec(node, want) {
1039
- if (node.kind === "binary" && (node.op === "and" || node.op === "or")) {
1040
- const behaveAsAnd = node.op === "and" === want;
1041
- const l = this.matchedSpec(node.left, want);
1042
- const r = this.matchedSpec(node.right, want);
1043
- return behaveAsAnd ? l > 0 && r > 0 ? l + r : 0 : Math.max(l, r);
1044
- }
1045
- if (node.kind === "unary" && node.op === "not") {
1046
- return this.matchedSpec(node.operand, !want);
1047
- }
1048
- if (node.kind === "call" && node.name === "check_flags") {
1049
- const operands = Math.max(1, node.args.length - 1);
1050
- const hit = truthy((0, import_expr.evaluate)(node, this.evalCtx, import_dialect.patterDialect));
1051
- return want ? hit ? operands : 0 : hit ? 0 : 1;
1052
- }
1053
- return truthy((0, import_expr.evaluate)(node, this.evalCtx, import_dialect.patterDialect)) === want ? 1 : 0;
1040
+ const evalTruthy = (n) => truthy((0, import_expr.evaluate)(n, this.evalCtx, import_dialect.patterDialect));
1041
+ return (0, import_expr_specificity.matchedSpecificity)(node, evalTruthy, { want });
1054
1042
  }
1055
1043
  /** A selector's cursor state - shared across flows (`group.shared`) or this flow's own. */
1056
1044
  selectorState(group) {