@zenithbuild/core 0.4.7 → 0.5.0-beta.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.
Files changed (110) hide show
  1. package/CORE_CONTRACT.md +143 -0
  2. package/README.md +11 -31
  3. package/bin/zenith.js +68 -0
  4. package/package.json +41 -53
  5. package/src/config.js +134 -0
  6. package/src/core-template.js +30 -0
  7. package/src/errors.js +54 -0
  8. package/src/guards.js +61 -0
  9. package/src/hash.js +52 -0
  10. package/src/index.js +26 -0
  11. package/src/ir/index.js +1 -0
  12. package/src/order.js +69 -0
  13. package/src/path.js +131 -0
  14. package/src/schema.js +28 -0
  15. package/src/version.js +67 -0
  16. package/bin/zen-build.ts +0 -2
  17. package/bin/zen-dev.ts +0 -2
  18. package/bin/zen-preview.ts +0 -2
  19. package/bin/zenith.ts +0 -2
  20. package/cli/commands/add.ts +0 -37
  21. package/cli/commands/build.ts +0 -37
  22. package/cli/commands/create.ts +0 -702
  23. package/cli/commands/dev.ts +0 -335
  24. package/cli/commands/index.ts +0 -112
  25. package/cli/commands/preview.ts +0 -62
  26. package/cli/commands/remove.ts +0 -33
  27. package/cli/index.ts +0 -10
  28. package/cli/main.ts +0 -101
  29. package/cli/utils/branding.ts +0 -178
  30. package/cli/utils/content.ts +0 -112
  31. package/cli/utils/logger.ts +0 -46
  32. package/cli/utils/plugin-manager.ts +0 -114
  33. package/cli/utils/project.ts +0 -77
  34. package/compiler/README.md +0 -380
  35. package/compiler/build-analyzer.ts +0 -122
  36. package/compiler/css/index.ts +0 -317
  37. package/compiler/discovery/componentDiscovery.ts +0 -178
  38. package/compiler/discovery/layouts.ts +0 -70
  39. package/compiler/errors/compilerError.ts +0 -56
  40. package/compiler/finalize/finalizeOutput.ts +0 -192
  41. package/compiler/finalize/generateFinalBundle.ts +0 -82
  42. package/compiler/index.ts +0 -82
  43. package/compiler/ir/types.ts +0 -162
  44. package/compiler/output/types.ts +0 -34
  45. package/compiler/parse/detectMapExpressions.ts +0 -102
  46. package/compiler/parse/parseScript.ts +0 -46
  47. package/compiler/parse/parseTemplate.ts +0 -599
  48. package/compiler/parse/parseZenFile.ts +0 -66
  49. package/compiler/parse/scriptAnalysis.ts +0 -91
  50. package/compiler/parse/trackLoopContext.ts +0 -82
  51. package/compiler/runtime/dataExposure.ts +0 -317
  52. package/compiler/runtime/generateDOM.ts +0 -246
  53. package/compiler/runtime/generateHydrationBundle.ts +0 -407
  54. package/compiler/runtime/hydration.ts +0 -309
  55. package/compiler/runtime/navigation.ts +0 -432
  56. package/compiler/runtime/thinRuntime.ts +0 -160
  57. package/compiler/runtime/transformIR.ts +0 -363
  58. package/compiler/runtime/wrapExpression.ts +0 -95
  59. package/compiler/runtime/wrapExpressionWithLoop.ts +0 -83
  60. package/compiler/spa-build.ts +0 -917
  61. package/compiler/ssg-build.ts +0 -422
  62. package/compiler/test/validate-test.ts +0 -104
  63. package/compiler/transform/classifyExpression.ts +0 -444
  64. package/compiler/transform/componentResolver.ts +0 -312
  65. package/compiler/transform/componentScriptTransformer.ts +0 -147
  66. package/compiler/transform/expressionTransformer.ts +0 -385
  67. package/compiler/transform/fragmentLowering.ts +0 -634
  68. package/compiler/transform/generateBindings.ts +0 -47
  69. package/compiler/transform/generateHTML.ts +0 -28
  70. package/compiler/transform/layoutProcessor.ts +0 -132
  71. package/compiler/transform/slotResolver.ts +0 -292
  72. package/compiler/transform/transformNode.ts +0 -126
  73. package/compiler/transform/transformTemplate.ts +0 -38
  74. package/compiler/validate/invariants.ts +0 -292
  75. package/compiler/validate/validateExpressions.ts +0 -168
  76. package/core/config/index.ts +0 -16
  77. package/core/config/loader.ts +0 -69
  78. package/core/config/types.ts +0 -89
  79. package/core/index.ts +0 -135
  80. package/core/lifecycle/index.ts +0 -49
  81. package/core/lifecycle/zen-mount.ts +0 -182
  82. package/core/lifecycle/zen-unmount.ts +0 -88
  83. package/core/plugins/index.ts +0 -7
  84. package/core/plugins/registry.ts +0 -81
  85. package/core/reactivity/index.ts +0 -54
  86. package/core/reactivity/tracking.ts +0 -167
  87. package/core/reactivity/zen-batch.ts +0 -57
  88. package/core/reactivity/zen-effect.ts +0 -139
  89. package/core/reactivity/zen-memo.ts +0 -146
  90. package/core/reactivity/zen-ref.ts +0 -52
  91. package/core/reactivity/zen-signal.ts +0 -121
  92. package/core/reactivity/zen-state.ts +0 -180
  93. package/core/reactivity/zen-untrack.ts +0 -44
  94. package/dist/cli.js +0 -11659
  95. package/dist/zen-build.js +0 -15633
  96. package/dist/zen-dev.js +0 -15633
  97. package/dist/zen-preview.js +0 -15633
  98. package/dist/zenith.js +0 -15633
  99. package/router/index.ts +0 -76
  100. package/router/manifest.ts +0 -314
  101. package/router/navigation/ZenLink.zen +0 -231
  102. package/router/navigation/index.ts +0 -78
  103. package/router/navigation/zen-link.ts +0 -584
  104. package/router/runtime.ts +0 -458
  105. package/router/types.ts +0 -168
  106. package/runtime/build.ts +0 -17
  107. package/runtime/bundle-generator.ts +0 -943
  108. package/runtime/client-runtime.ts +0 -549
  109. package/runtime/serve.ts +0 -93
  110. package/tsconfig.json +0 -28
@@ -1,180 +0,0 @@
1
- /**
2
- * Zenith State - Deep Reactive Object
3
- *
4
- * Creates a deeply reactive object using Proxy. Any property access
5
- * is tracked, and any mutation triggers effects.
6
- *
7
- * Features:
8
- * - Deep reactivity via nested Proxies
9
- * - Automatic dependency tracking on property access
10
- * - Triggers effects on property mutation
11
- *
12
- * @example
13
- * ```ts
14
- * const user = zenState({
15
- * name: 'John',
16
- * address: {
17
- * city: 'NYC'
18
- * }
19
- * })
20
- *
21
- * // Access triggers tracking
22
- * console.log(user.name)
23
- *
24
- * // Mutation triggers effects
25
- * user.name = 'Jane'
26
- * user.address.city = 'LA'
27
- * ```
28
- */
29
-
30
- import { trackDependency, notifySubscribers, type Subscriber } from './tracking'
31
-
32
- /**
33
- * WeakMap to store proxy targets and their subscriber maps
34
- * Key: target object
35
- * Value: Map of property key -> subscriber set
36
- */
37
- const proxySubscribers = new WeakMap<object, Map<string | symbol, Set<Subscriber>>>()
38
-
39
- /**
40
- * WeakMap to store original objects and their proxies
41
- * Prevents creating multiple proxies for the same object
42
- */
43
- const proxyCache = new WeakMap<object, object>()
44
-
45
- /**
46
- * Get or create subscriber set for a property
47
- */
48
- function getPropertySubscribers(target: object, key: string | symbol): Set<Subscriber> {
49
- let propertyMap = proxySubscribers.get(target)
50
-
51
- if (!propertyMap) {
52
- propertyMap = new Map()
53
- proxySubscribers.set(target, propertyMap)
54
- }
55
-
56
- let subscribers = propertyMap.get(key)
57
-
58
- if (!subscribers) {
59
- subscribers = new Set()
60
- propertyMap.set(key, subscribers)
61
- }
62
-
63
- return subscribers
64
- }
65
-
66
- /**
67
- * Check if a value should be wrapped in a proxy
68
- */
69
- function shouldProxy(value: unknown): value is object {
70
- if (value === null || typeof value !== 'object') {
71
- return false
72
- }
73
-
74
- // Don't proxy special objects
75
- if (value instanceof Date ||
76
- value instanceof RegExp ||
77
- value instanceof Map ||
78
- value instanceof Set ||
79
- value instanceof WeakMap ||
80
- value instanceof WeakSet ||
81
- value instanceof Promise ||
82
- ArrayBuffer.isView(value)) {
83
- return false
84
- }
85
-
86
- return true
87
- }
88
-
89
- /**
90
- * Create a reactive proxy for an object
91
- */
92
- function createReactiveProxy<T extends object>(target: T): T {
93
- // Check cache first
94
- const cached = proxyCache.get(target)
95
- if (cached) {
96
- return cached as T
97
- }
98
-
99
- const proxy = new Proxy(target, {
100
- get(target, key, receiver) {
101
- // Track dependency
102
- const subscribers = getPropertySubscribers(target, key)
103
- trackDependency(subscribers)
104
-
105
- const value = Reflect.get(target, key, receiver)
106
-
107
- // Recursively proxy nested objects
108
- if (shouldProxy(value)) {
109
- return createReactiveProxy(value)
110
- }
111
-
112
- return value
113
- },
114
-
115
- set(target, key, value, receiver) {
116
- const oldValue = Reflect.get(target, key, receiver)
117
-
118
- // Unwrap proxies before storing
119
- const rawValue = value
120
-
121
- const result = Reflect.set(target, key, rawValue, receiver)
122
-
123
- // Only notify if value actually changed
124
- if (!Object.is(oldValue, rawValue)) {
125
- const subscribers = getPropertySubscribers(target, key)
126
- notifySubscribers(subscribers)
127
- }
128
-
129
- return result
130
- },
131
-
132
- deleteProperty(target, key) {
133
- const hadKey = Reflect.has(target, key)
134
- const result = Reflect.deleteProperty(target, key)
135
-
136
- if (hadKey && result) {
137
- const subscribers = getPropertySubscribers(target, key)
138
- notifySubscribers(subscribers)
139
- }
140
-
141
- return result
142
- },
143
-
144
- has(target, key) {
145
- // Track dependency for 'in' operator
146
- const subscribers = getPropertySubscribers(target, key)
147
- trackDependency(subscribers)
148
-
149
- return Reflect.has(target, key)
150
- },
151
-
152
- ownKeys(target) {
153
- // Track a special 'keys' dependency for iteration
154
- const subscribers = getPropertySubscribers(target, Symbol.for('zen:keys'))
155
- trackDependency(subscribers)
156
-
157
- return Reflect.ownKeys(target)
158
- }
159
- })
160
-
161
- // Cache the proxy
162
- proxyCache.set(target, proxy)
163
-
164
- return proxy
165
- }
166
-
167
- /**
168
- * Create a deeply reactive state object
169
- *
170
- * @param initialValue - The initial state object
171
- * @returns A reactive proxy of the object
172
- */
173
- export function zenState<T extends object>(initialValue: T): T {
174
- if (!shouldProxy(initialValue)) {
175
- throw new Error('zenState requires a plain object or array')
176
- }
177
-
178
- return createReactiveProxy(initialValue)
179
- }
180
-
@@ -1,44 +0,0 @@
1
- /**
2
- * Zenith Untrack - Escape Dependency Tracking
3
- *
4
- * Allows reading reactive values without creating a dependency.
5
- * Useful when you need to read a value inside an effect but don't
6
- * want the effect to re-run when that value changes.
7
- *
8
- * Features:
9
- * - Disables dependency tracking within the callback
10
- * - Returns the callback's return value
11
- * - Can be nested
12
- *
13
- * @example
14
- * ```ts
15
- * const count = zenSignal(0)
16
- * const multiplier = zenSignal(2)
17
- *
18
- * zenEffect(() => {
19
- * // This creates a dependency on 'count'
20
- * const c = count()
21
- *
22
- * // This does NOT create a dependency on 'multiplier'
23
- * const m = zenUntrack(() => multiplier())
24
- *
25
- * console.log(c * m)
26
- * })
27
- *
28
- * count(5) // Effect re-runs
29
- * multiplier(3) // Effect does NOT re-run
30
- * ```
31
- */
32
-
33
- import { runUntracked } from './tracking'
34
-
35
- /**
36
- * Execute a function without tracking dependencies
37
- *
38
- * @param fn - The function to execute
39
- * @returns The return value of the function
40
- */
41
- export function zenUntrack<T>(fn: () => T): T {
42
- return runUntracked(fn)
43
- }
44
-