@jay-framework/compiler-jay-html 0.25.5 → 0.26.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.
Files changed (2) hide show
  1. package/dist/index.js +36 -9
  2. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -14488,27 +14488,42 @@ function elementNameToJayType(element) {
14488
14488
  }
14489
14489
  class RefNameGenerator {
14490
14490
  nextId = 1;
14491
- constNamesToVariables = /* @__PURE__ */ new Map();
14491
+ constNameOwners = /* @__PURE__ */ new Map();
14492
14492
  newAutoRefNameGenerator() {
14493
14493
  return "aR" + this.nextId++;
14494
14494
  }
14495
- newConstantName(refName, variables) {
14495
+ /**
14496
+ * Allocate a unique local const name for a ref.
14497
+ *
14498
+ * A const name is reused (returned unchanged) only when the SAME ref is requested again in the
14499
+ * same render scope — "same ref" being identified by `identity`, not by `refName`. `refName` is
14500
+ * only the base used to build the const (e.g. `input` → `refInput`); `identity` is the ref's
14501
+ * stable key, which for an imported/headless ref is its full template path (e.g.
14502
+ * `form.firstName.input`). This distinguishes "one ref used by several elements" (reuse) from
14503
+ * "two distinct refs that happen to share a leaf tag name" (DL#226) — the latter get distinct
14504
+ * consts (`refInput`, `refInput2`, …) instead of colliding.
14505
+ *
14506
+ * `identity` defaults to `refName`, which preserves prior behavior for page-own refs where
14507
+ * `refName` is already the full, unique ref path.
14508
+ */
14509
+ newConstantName(refName, variables, identity = refName) {
14496
14510
  let suffix = 2;
14497
14511
  let constName = camelCase$1(`ref ${refName}`);
14498
- while (this.constNamesToVariables.has(constName)) {
14499
- if (this.constNamesToVariables.get(constName) === variables) {
14512
+ while (this.constNameOwners.has(constName)) {
14513
+ const owner = this.constNameOwners.get(constName);
14514
+ if (owner.variables === variables && owner.identity === identity) {
14500
14515
  return constName;
14501
14516
  }
14502
14517
  constName = camelCase$1(`ref ${refName}${suffix++}`);
14503
14518
  }
14504
- this.constNamesToVariables.set(constName, variables);
14519
+ this.constNameOwners.set(constName, { variables, identity });
14505
14520
  return constName;
14506
14521
  }
14507
14522
  /** Create a snapshot of the current state for use in parallel code generation paths. */
14508
14523
  clone() {
14509
14524
  const copy = new RefNameGenerator();
14510
14525
  copy.nextId = this.nextId;
14511
- copy.constNamesToVariables = new Map(this.constNamesToVariables);
14526
+ copy.constNameOwners = new Map(this.constNameOwners);
14512
14527
  return copy;
14513
14528
  }
14514
14529
  }
@@ -15128,6 +15143,9 @@ const DIRECTIVE_ATTRIBUTES = /* @__PURE__ */ new Set([
15128
15143
  // DL#202 — template-side content-slot marker. A pure build-time authoring directive read by the
15129
15144
  // drift/sync differ; it rides into the flattened page copy (verbatim flatten) but must never render.
15130
15145
  "jay-content",
15146
+ // DL#231 — editing-policy marker (`jay-policy="<name>"`) on a plain element or region tag. Read only
15147
+ // by the editing-policy engine; never a component prop or a rendered attribute.
15148
+ "jay-policy",
15131
15149
  AsyncDirectiveTypes.loading.directive,
15132
15150
  AsyncDirectiveTypes.resolved.directive,
15133
15151
  AsyncDirectiveTypes.rejected.directive
@@ -21738,7 +21756,11 @@ function renderElementRef$1(element, { dynamicRef, variables, importedRefNameToR
21738
21756
  if (element.attributes.ref) {
21739
21757
  if (importedRefNameToRef.has(element.attributes.ref)) {
21740
21758
  const importedRef = importedRefNameToRef.get(element.attributes.ref);
21741
- const uniqueConstName = refNameGenerator.newConstantName(importedRef.ref, variables);
21759
+ const uniqueConstName = refNameGenerator.newConstantName(
21760
+ importedRef.ref,
21761
+ variables,
21762
+ element.attributes.ref
21763
+ );
21742
21764
  const refWithUniqueConstName = mkRef(
21743
21765
  importedRef.ref,
21744
21766
  element.attributes.ref,
@@ -21812,7 +21834,8 @@ function renderChildCompProps$1(element, { variables }, contractProps) {
21812
21834
  Object.keys(attributes2).forEach((attrName) => {
21813
21835
  let attrCanonical = attrName.toLowerCase();
21814
21836
  let attrKey = attrName.match(attributesRequiresQuotes$1) ? `"${attrName}"` : attrName;
21815
- if (attrCanonical === "if" || attrCanonical === "foreach" || attrCanonical === "trackby" || attrCanonical === "jay-coordinate-base" || attrCanonical === "jay-scope")
21837
+ if (attrCanonical === "if" || attrCanonical === "foreach" || attrCanonical === "trackby" || attrCanonical === "jay-coordinate-base" || attrCanonical === "jay-scope" || // DL#231 — editing-policy marker on a region tag is a bare directive, never a component prop.
21838
+ attrCanonical === "jay-policy")
21816
21839
  return;
21817
21840
  if (attrCanonical === "props") {
21818
21841
  isPropsDirectAssignment = true;
@@ -21847,7 +21870,11 @@ function renderChildCompProps$1(element, { variables }, contractProps) {
21847
21870
  function renderChildCompRef$1(element, { dynamicRef, variables, refNameGenerator, importedRefNameToRef }, componentName) {
21848
21871
  if (importedRefNameToRef.has(element.attributes.ref)) {
21849
21872
  const importedRef = importedRefNameToRef.get(element.attributes.ref);
21850
- const uniqueConstName = refNameGenerator.newConstantName(importedRef.ref, variables);
21873
+ const uniqueConstName = refNameGenerator.newConstantName(
21874
+ importedRef.ref,
21875
+ variables,
21876
+ element.attributes.ref
21877
+ );
21851
21878
  const refWithUniqueConstName = mkRef(
21852
21879
  importedRef.ref,
21853
21880
  element.attributes.ref,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/compiler-jay-html",
3
- "version": "0.25.5",
3
+ "version": "0.26.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -34,12 +34,12 @@
34
34
  },
35
35
  "author": "",
36
36
  "dependencies": {
37
- "@jay-framework/compiler-analyze-exported-types": "^0.25.5",
38
- "@jay-framework/compiler-shared": "^0.25.5",
39
- "@jay-framework/component": "^0.25.5",
40
- "@jay-framework/logger": "^0.25.5",
41
- "@jay-framework/runtime": "^0.25.5",
42
- "@jay-framework/secure": "^0.25.5",
37
+ "@jay-framework/compiler-analyze-exported-types": "^0.26.0",
38
+ "@jay-framework/compiler-shared": "^0.26.0",
39
+ "@jay-framework/component": "^0.26.0",
40
+ "@jay-framework/logger": "^0.26.0",
41
+ "@jay-framework/runtime": "^0.26.0",
42
+ "@jay-framework/secure": "^0.26.0",
43
43
  "@types/js-yaml": "^4.0.9",
44
44
  "change-case": "^4.1.2",
45
45
  "he": "^1.2.0",
@@ -52,8 +52,8 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@caiogondim/strip-margin": "^1.0.0",
55
- "@jay-framework/4-react": "^0.25.5",
56
- "@jay-framework/dev-environment": "^0.25.5",
55
+ "@jay-framework/4-react": "^0.26.0",
56
+ "@jay-framework/dev-environment": "^0.26.0",
57
57
  "@testing-library/jest-dom": "^6.2.0",
58
58
  "@types/js-beautify": "^1",
59
59
  "@types/node": "^20.11.5",
@@ -65,7 +65,7 @@
65
65
  "react-dom": "^18.2.0",
66
66
  "rimraf": "^5.0.5",
67
67
  "tsup": "^8.0.1",
68
- "vite": "^5.0.11",
69
- "vitest": "^1.2.1"
68
+ "vite": "^6.4.4",
69
+ "vitest": "^4.1.11"
70
70
  }
71
71
  }