j-templates 7.0.97 → 7.0.98

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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -0
  3. package/{SYNTAX_PRIMER.md → lib/SYNTAX_PRIMER.md} +93 -64
  4. package/lib/Store/Tree/observableNode.d.ts +83 -0
  5. package/{Store → lib/Store}/Tree/observableNode.js +42 -9
  6. package/{Store → lib/Store}/Tree/observableScope.d.ts +29 -0
  7. package/{Store → lib/Store}/Tree/observableScope.js +29 -0
  8. package/lib/package.json +13 -0
  9. package/package.json +28 -3
  10. package/Store/Tree/observableNode.d.ts +0 -43
  11. /package/{DOM → lib/DOM}/createAssignment.d.ts +0 -0
  12. /package/{DOM → lib/DOM}/createAssignment.js +0 -0
  13. /package/{DOM → lib/DOM}/createAttributeAssignment.d.ts +0 -0
  14. /package/{DOM → lib/DOM}/createAttributeAssignment.js +0 -0
  15. /package/{DOM → lib/DOM}/createEventAssignment.d.ts +0 -0
  16. /package/{DOM → lib/DOM}/createEventAssignment.js +0 -0
  17. /package/{DOM → lib/DOM}/createPropertyAssignment.d.ts +0 -0
  18. /package/{DOM → lib/DOM}/createPropertyAssignment.js +0 -0
  19. /package/{DOM → lib/DOM}/domNodeConfig.d.ts +0 -0
  20. /package/{DOM → lib/DOM}/domNodeConfig.js +0 -0
  21. /package/{DOM → lib/DOM}/elements.d.ts +0 -0
  22. /package/{DOM → lib/DOM}/elements.js +0 -0
  23. /package/{DOM → lib/DOM}/index.d.ts +0 -0
  24. /package/{DOM → lib/DOM}/index.js +0 -0
  25. /package/{DOM → lib/DOM}/svgElements.d.ts +0 -0
  26. /package/{DOM → lib/DOM}/svgElements.js +0 -0
  27. /package/{Node → lib/Node}/component.d.ts +0 -0
  28. /package/{Node → lib/Node}/component.js +0 -0
  29. /package/{Node → lib/Node}/component.types.d.ts +0 -0
  30. /package/{Node → lib/Node}/component.types.js +0 -0
  31. /package/{Node → lib/Node}/nodeConfig.d.ts +0 -0
  32. /package/{Node → lib/Node}/nodeConfig.js +0 -0
  33. /package/{Node → lib/Node}/vNode.d.ts +0 -0
  34. /package/{Node → lib/Node}/vNode.js +0 -0
  35. /package/{Node → lib/Node}/vNode.types.d.ts +0 -0
  36. /package/{Node → lib/Node}/vNode.types.js +0 -0
  37. /package/{Store → lib/Store}/Diff/diffAsync.d.ts +0 -0
  38. /package/{Store → lib/Store}/Diff/diffAsync.js +0 -0
  39. /package/{Store → lib/Store}/Diff/diffSync.d.ts +0 -0
  40. /package/{Store → lib/Store}/Diff/diffSync.js +0 -0
  41. /package/{Store → lib/Store}/Diff/diffTree.d.ts +0 -0
  42. /package/{Store → lib/Store}/Diff/diffTree.js +0 -0
  43. /package/{Store → lib/Store}/Diff/diffWorker.d.ts +0 -0
  44. /package/{Store → lib/Store}/Diff/diffWorker.js +0 -0
  45. /package/{Store → lib/Store}/Diff/workerQueue.d.ts +0 -0
  46. /package/{Store → lib/Store}/Diff/workerQueue.js +0 -0
  47. /package/{Store → lib/Store}/Store/store.d.ts +0 -0
  48. /package/{Store → lib/Store}/Store/store.js +0 -0
  49. /package/{Store → lib/Store}/Store/storeAsync.d.ts +0 -0
  50. /package/{Store → lib/Store}/Store/storeAsync.js +0 -0
  51. /package/{Store → lib/Store}/Store/storeSync.d.ts +0 -0
  52. /package/{Store → lib/Store}/Store/storeSync.js +0 -0
  53. /package/{Store → lib/Store}/index.d.ts +0 -0
  54. /package/{Store → lib/Store}/index.js +0 -0
  55. /package/{Utils → lib/Utils}/animation.d.ts +0 -0
  56. /package/{Utils → lib/Utils}/animation.js +0 -0
  57. /package/{Utils → lib/Utils}/asyncQueue.d.ts +0 -0
  58. /package/{Utils → lib/Utils}/asyncQueue.js +0 -0
  59. /package/{Utils → lib/Utils}/decorators.d.ts +0 -0
  60. /package/{Utils → lib/Utils}/decorators.js +0 -0
  61. /package/{Utils → lib/Utils}/emitter.d.ts +0 -0
  62. /package/{Utils → lib/Utils}/emitter.js +0 -0
  63. /package/{Utils → lib/Utils}/functions.d.ts +0 -0
  64. /package/{Utils → lib/Utils}/functions.js +0 -0
  65. /package/{Utils → lib/Utils}/index.d.ts +0 -0
  66. /package/{Utils → lib/Utils}/index.js +0 -0
  67. /package/{Utils → lib/Utils}/injector.d.ts +0 -0
  68. /package/{Utils → lib/Utils}/injector.js +0 -0
  69. /package/{Utils → lib/Utils}/json.d.ts +0 -0
  70. /package/{Utils → lib/Utils}/json.js +0 -0
  71. /package/{Utils → lib/Utils}/list.d.ts +0 -0
  72. /package/{Utils → lib/Utils}/list.js +0 -0
  73. /package/{Utils → lib/Utils}/router.d.ts +0 -0
  74. /package/{Utils → lib/Utils}/router.js +0 -0
  75. /package/{Utils → lib/Utils}/scheduling.d.ts +0 -0
  76. /package/{Utils → lib/Utils}/scheduling.js +0 -0
  77. /package/{Utils → lib/Utils}/thread.d.ts +0 -0
  78. /package/{Utils → lib/Utils}/thread.js +0 -0
  79. /package/{Utils → lib/Utils}/utils.types.d.ts +0 -0
  80. /package/{Utils → lib/Utils}/utils.types.js +0 -0
  81. /package/{_not_used → lib/_not_used}/array.d.ts +0 -0
  82. /package/{_not_used → lib/_not_used}/array.js +0 -0
  83. /package/{_not_used → lib/_not_used}/avlTree.d.ts +0 -0
  84. /package/{_not_used → lib/_not_used}/avlTree.js +0 -0
  85. /package/{index.d.ts → lib/index.d.ts} +0 -0
  86. /package/{index.js → lib/index.js} +0 -0
@@ -115,6 +115,9 @@ export declare function PeekScope<T>(callback: () => T | Promise<T>, idOverride?
115
115
  export declare namespace ObservableScope {
116
116
  /**
117
117
  * Creates a new observable scope from a value function.
118
+ * The scope auto-tracks the reactive dependencies the valueFunction reads. If it reads no
119
+ * reactive dependencies, `Create` returns a static scope that does not emit on `Update` — use
120
+ * `Basic` for a manually-updatable scope whose value doesn't derive from reactive state.
118
121
  * @template T The type of value returned by the function.
119
122
  * @param valueFunction Function that returns the scope's value. Can be async.
120
123
  * @returns A new observable scope.
@@ -122,9 +125,26 @@ export declare namespace ObservableScope {
122
125
  function Create<T>(valueFunction: {
123
126
  (): T | Promise<T>;
124
127
  }): IObservableScope<T>;
128
+ /**
129
+ * Creates a greedy observable scope that batches updates via the microtask queue.
130
+ * Unlike `Create`, a greedy scope does not emit immediately on change — updates are coalesced
131
+ * and emitted on the next microtask. Used by `@Watch` for batched side effects.
132
+ * @template T The type of value returned by the function.
133
+ * @param valueFunction Function that returns the scope's value. Can be async.
134
+ * @returns A new greedy observable scope.
135
+ */
125
136
  function Gated<T>(valueFunction: {
126
137
  (): T | Promise<T>;
127
138
  }): IObservableScope<T>;
139
+ /**
140
+ * Creates a lightweight basic scope that stores a value directly without a proxy.
141
+ * Used by `@Value` for primitives. Basic scopes do not automatically track dependencies —
142
+ * after creation, `ObservableScope.Update` must be called for the scope to emit. They also do
143
+ * not cache a value internally: the valueFunction is invoked on every read.
144
+ * @template T The type of value stored in the scope.
145
+ * @param valueFunction Function that returns the scope's value.
146
+ * @returns A new basic observable scope.
147
+ */
128
148
  function Basic<T>(valueFunction: {
129
149
  (): T;
130
150
  }): IBasicObservableScope<T>;
@@ -167,6 +187,13 @@ export declare namespace ObservableScope {
167
187
  * @param callback The callback function to remove.
168
188
  */
169
189
  function Unwatch<T>(scope: IObservableScope<T>, callback: (scope: IObservableScope<T>) => void): void;
190
+ /**
191
+ * Registers a callback to be invoked when the scope's value is updated.
192
+ * Only applies to dynamic scopes; no-op for static scopes.
193
+ * @template T The type of value stored in the scope.
194
+ * @param scope The scope to monitor for updates.
195
+ * @param callback Function invoked with the last value and the scope on each update.
196
+ */
170
197
  function OnUpdated<T>(scope: IObservableScope<T>, callback: {
171
198
  (lastValue: T, scope: IObservableScope<T>): void;
172
199
  }): void;
@@ -180,6 +207,8 @@ export declare namespace ObservableScope {
180
207
  }): void;
181
208
  /**
182
209
  * Marks a scope as dirty, triggering recomputation on next access or batch.
210
+ * No-op for static scopes (created when a `Create` valueFunction reads no reactive
211
+ * dependencies) — they never emit. Use `Basic` for scopes you drive manually with `Update`.
183
212
  * @param scope The scope to mark for update.
184
213
  */
185
214
  function Update(scope: IObservableScope<any> | IBasicObservableScope<any>): void;
@@ -538,6 +538,9 @@ var ObservableScope;
538
538
  (function (ObservableScope) {
539
539
  /**
540
540
  * Creates a new observable scope from a value function.
541
+ * The scope auto-tracks the reactive dependencies the valueFunction reads. If it reads no
542
+ * reactive dependencies, `Create` returns a static scope that does not emit on `Update` — use
543
+ * `Basic` for a manually-updatable scope whose value doesn't derive from reactive state.
541
544
  * @template T The type of value returned by the function.
542
545
  * @param valueFunction Function that returns the scope's value. Can be async.
543
546
  * @returns A new observable scope.
@@ -546,10 +549,27 @@ var ObservableScope;
546
549
  return ExecuteFunction(valueFunction, false);
547
550
  }
548
551
  ObservableScope.Create = Create;
552
+ /**
553
+ * Creates a greedy observable scope that batches updates via the microtask queue.
554
+ * Unlike `Create`, a greedy scope does not emit immediately on change — updates are coalesced
555
+ * and emitted on the next microtask. Used by `@Watch` for batched side effects.
556
+ * @template T The type of value returned by the function.
557
+ * @param valueFunction Function that returns the scope's value. Can be async.
558
+ * @returns A new greedy observable scope.
559
+ */
549
560
  function Gated(valueFunction) {
550
561
  return ExecuteFunction(valueFunction, true);
551
562
  }
552
563
  ObservableScope.Gated = Gated;
564
+ /**
565
+ * Creates a lightweight basic scope that stores a value directly without a proxy.
566
+ * Used by `@Value` for primitives. Basic scopes do not automatically track dependencies —
567
+ * after creation, `ObservableScope.Update` must be called for the scope to emit. They also do
568
+ * not cache a value internally: the valueFunction is invoked on every read.
569
+ * @template T The type of value stored in the scope.
570
+ * @param valueFunction Function that returns the scope's value.
571
+ * @returns A new basic observable scope.
572
+ */
553
573
  function Basic(valueFunction) {
554
574
  return CreateBasicScope(valueFunction);
555
575
  }
@@ -620,6 +640,13 @@ var ObservableScope;
620
640
  emitter_1.Emitter.Remove(scope.emitter, callback);
621
641
  }
622
642
  ObservableScope.Unwatch = Unwatch;
643
+ /**
644
+ * Registers a callback to be invoked when the scope's value is updated.
645
+ * Only applies to dynamic scopes; no-op for static scopes.
646
+ * @template T The type of value stored in the scope.
647
+ * @param scope The scope to monitor for updates.
648
+ * @param callback Function invoked with the last value and the scope on each update.
649
+ */
623
650
  function OnUpdated(scope, callback) {
624
651
  if (scope.type !== "dynamic")
625
652
  return;
@@ -639,6 +666,8 @@ var ObservableScope;
639
666
  ObservableScope.OnDestroyed = OnDestroyed;
640
667
  /**
641
668
  * Marks a scope as dirty, triggering recomputation on next access or batch.
669
+ * No-op for static scopes (created when a `Create` valueFunction reads no reactive
670
+ * dependencies) — they never emit. Use `Basic` for scopes you drive manually with `Update`.
642
671
  * @param scope The scope to mark for update.
643
672
  */
644
673
  function Update(scope) {
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "j-templates",
3
+ "version": "7.0.98",
4
+ "description": "j-templates",
5
+ "license": "MIT",
6
+ "repository": "https://github.com/TypesInCode/jTemplates",
7
+ "author": "Jay Landrum",
8
+ "keywords": [
9
+ ""
10
+ ],
11
+ "main": "./index.js",
12
+ "typings": "./index.d.ts"
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.97",
3
+ "version": "7.0.98",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",
@@ -8,6 +8,31 @@
8
8
  "keywords": [
9
9
  ""
10
10
  ],
11
- "main": "./index.js",
12
- "typings": "./index.d.ts"
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "main": "lib/index.js",
15
+ "typings": "lib/index.d.ts",
16
+ "scripts": {
17
+ "clean": "rimraf lib",
18
+ "build": "npm run buildquick && node ./tools/copy-package-json.js",
19
+ "buildquick": "npm run clean && echo Using TypeScript && tsc --version && tsc --pretty",
20
+ "builddocs": "typedoc --out docs src/index.ts src/DOM/index.ts src/Utils/index.ts src/Store/index.ts && touch docs/.nojekyll",
21
+ "test": "vitest run",
22
+ "test_watch": "vitest --ui"
23
+ },
24
+ "devDependencies": {
25
+ "@fission-ai/openspec": "^1.1.1",
26
+ "@types/node": "^25.2.0",
27
+ "@vitest/ui": "^4.1.5",
28
+ "fs-extra": "^11.3.3",
29
+ "jsdom": "^27.4.0",
30
+ "rimraf": "^6.1.2",
31
+ "typedoc": "^0.28.16",
32
+ "typescript": "^5.9.3",
33
+ "vitest": "^4.1.5"
34
+ },
35
+ "engines": {
36
+ "node": ">=4.0.0"
37
+ }
13
38
  }
@@ -1,43 +0,0 @@
1
- import { JsonDiffResult } from "../../Utils/json";
2
- export declare namespace ObservableNode {
3
- /**
4
- * Unwraps an observable node to get the raw underlying value.
5
- * Recursively unwraps nested objects and arrays.
6
- * @template T The type of value to unwrap.
7
- * @param value The value to unwrap, which may be an observable node or plain value.
8
- * @returns The unwrapped raw value without proxy wrappers.
9
- */
10
- function Unwrap<T>(value: T): T;
11
- function Clone<T>(value: T): T;
12
- /**
13
- * Creates an observable node from a plain value.
14
- * Wraps the value in a proxy that tracks changes and enables reactive updates.
15
- * @template T The type of value to wrap.
16
- * @param value The plain value (object, array, or primitive) to make observable.
17
- * @returns A proxied version of the value that emits change events.
18
- */
19
- function Create<T>(value: T): T;
20
- /**
21
- * Marks an observable node or its property as changed, triggering reactive updates.
22
- * Used internally to notify dependencies that a value has been modified.
23
- * @param value The observable node to touch.
24
- * @param prop Optional property name or index to touch a specific nested property.
25
- */
26
- function Update(value: unknown, prop?: string | number | symbol): void;
27
- function Apply(rootNode: any, update: any): void;
28
- /**
29
- * Applies a JSON diff result to an observable node, efficiently updating only changed properties.
30
- * Optimizes nested object updates by computing paths incrementally and touching modified properties.
31
- * @param rootNode The observable node to apply the diff to.
32
- * @param diffResult The diff result from JsonDiff containing path-value pairs of changes.
33
- */
34
- function ApplyDiff(rootNode: any, diffResult: JsonDiffResult): void;
35
- /**
36
- * Creates a factory function for making values observable with optional aliasing.
37
- * The alias function transforms values before creating the observable proxy,
38
- * useful for read-only views or value transformations.
39
- * @param alias Optional function to transform values before making them observable.
40
- * @returns A function that creates observable nodes from plain values.
41
- */
42
- function CreateFactory(alias?: (value: any) => any | undefined): <T>(value: T) => T;
43
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes