assign-gingerly 0.0.58 → 0.0.60

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 (42) hide show
  1. package/README.md +511 -142
  2. package/assignFrom-extension.js +25 -0
  3. package/assignFrom-extension.ts +53 -0
  4. package/assignFrom.js +306 -133
  5. package/assignFrom.ts +318 -232
  6. package/assignFromAsync-extension.js +28 -0
  7. package/assignFromAsync-extension.ts +58 -0
  8. package/assignFromAsync.js +120 -0
  9. package/assignFromAsync.ts +256 -0
  10. package/assignGingerly.js +50 -0
  11. package/assignGingerly.ts +51 -0
  12. package/builtInEmoji.js +25 -0
  13. package/builtInEmoji.ts +33 -0
  14. package/getValues.js +223 -0
  15. package/getValues.ts +255 -0
  16. package/handlers/join.ts +1 -1
  17. package/handlers/lazyLoad.js +33 -2
  18. package/handlers/lazyLoad.ts +47 -2
  19. package/handlers/lazyLoadSwitch.ts +1 -1
  20. package/handlers/manageTemplateList.js +226 -0
  21. package/handlers/manageTemplateList.ts +263 -0
  22. package/handlers/microDataJoin.ts +1 -1
  23. package/index.js +1 -0
  24. package/index.ts +2 -0
  25. package/inferencer/inferencer.js +9 -21
  26. package/inferencer/inferencer.ts +10 -21
  27. package/inferredAssignments.js +35 -5
  28. package/inferredAssignments.ts +58 -8
  29. package/markerUtils.js +136 -127
  30. package/package.json +30 -1
  31. package/playwright.config.ts +3 -2
  32. package/processHandlerCommands.js +36 -4
  33. package/processHandlerCommands.ts +38 -8
  34. package/resolveIdRef.js +70 -19
  35. package/resolveIdRef.ts +73 -21
  36. package/resolveValues.js +41 -125
  37. package/resolveValues.ts +131 -255
  38. package/types/assign-gingerly/types.d.ts +61 -0
  39. package/waitForSettled.js +57 -0
  40. package/waitForSettled.ts +65 -0
  41. package/withIdsCorrector.js +47 -0
  42. package/withIdsCorrector.ts +59 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * withIdsCorrector.ts — Dev-time diagnostic for stale withIds coordinates.
3
+ *
4
+ * Dynamically imported only on mismatch — zero cost in production or when coordinates are correct.
5
+ * Computes and logs the correct child index path for a given selector.
6
+ */
7
+ /**
8
+ * Compute the child index path from a root element to a target element.
9
+ * Returns the array of children indices, or null if not found.
10
+ */
11
+ function computeChildPath(root, target) {
12
+ const path = [];
13
+ let current = target;
14
+ while (current && current !== root) {
15
+ const parent = current.parentElement;
16
+ if (!parent)
17
+ return null;
18
+ const idx = Array.prototype.indexOf.call(parent.children, current);
19
+ if (idx === -1)
20
+ return null;
21
+ path.unshift(idx);
22
+ current = parent;
23
+ }
24
+ return current === root ? path : null;
25
+ }
26
+ /**
27
+ * Log a correction suggestion for a mismatched withIds config.
28
+ */
29
+ export function logConfigCorrection(target, varName, config) {
30
+ if (!config.expect)
31
+ return;
32
+ const correctEl = target.querySelector?.(config.expect);
33
+ if (!correctEl) {
34
+ console.warn(`withIds["${varName}"]: path [${config.path}] did not match "${config.expect}" ` +
35
+ `and querySelector also found no match. Check that the selector is correct.`);
36
+ return;
37
+ }
38
+ const correctPath = computeChildPath(target, correctEl);
39
+ if (correctPath) {
40
+ console.warn(`withIds["${varName}"]: path [${config.path}] did not match "${config.expect}". ` +
41
+ `Suggested correction: [${correctPath.join(', ')}]`);
42
+ }
43
+ else {
44
+ console.warn(`withIds["${varName}"]: path [${config.path}] did not match "${config.expect}". ` +
45
+ `Could not compute a child index path (element may not be a descendant of target).`);
46
+ }
47
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * withIdsCorrector.ts — Dev-time diagnostic for stale withIds coordinates.
3
+ *
4
+ * Dynamically imported only on mismatch — zero cost in production or when coordinates are correct.
5
+ * Computes and logs the correct child index path for a given selector.
6
+ */
7
+
8
+ /**
9
+ * Compute the child index path from a root element to a target element.
10
+ * Returns the array of children indices, or null if not found.
11
+ */
12
+ function computeChildPath(root: Element, target: Element): number[] | null {
13
+ const path: number[] = [];
14
+ let current: Element | null = target;
15
+
16
+ while (current && current !== root) {
17
+ const parent = current.parentElement;
18
+ if (!parent) return null;
19
+ const idx = Array.prototype.indexOf.call(parent.children, current);
20
+ if (idx === -1) return null;
21
+ path.unshift(idx);
22
+ current = parent;
23
+ }
24
+
25
+ return current === root ? path : null;
26
+ }
27
+
28
+ /**
29
+ * Log a correction suggestion for a mismatched withIds config.
30
+ */
31
+ export function logConfigCorrection(
32
+ target: any,
33
+ varName: string,
34
+ config: { path: number[]; expect?: string; fallback?: boolean }
35
+ ): void {
36
+ if (!config.expect) return;
37
+
38
+ const correctEl = target.querySelector?.(config.expect);
39
+ if (!correctEl) {
40
+ console.warn(
41
+ `withIds["${varName}"]: path [${config.path}] did not match "${config.expect}" ` +
42
+ `and querySelector also found no match. Check that the selector is correct.`
43
+ );
44
+ return;
45
+ }
46
+
47
+ const correctPath = computeChildPath(target, correctEl);
48
+ if (correctPath) {
49
+ console.warn(
50
+ `withIds["${varName}"]: path [${config.path}] did not match "${config.expect}". ` +
51
+ `Suggested correction: [${correctPath.join(', ')}]`
52
+ );
53
+ } else {
54
+ console.warn(
55
+ `withIds["${varName}"]: path [${config.path}] did not match "${config.expect}". ` +
56
+ `Could not compute a child index path (element may not be a descendant of target).`
57
+ );
58
+ }
59
+ }