@zenithbuild/core 0.6.2 → 0.6.4
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/CORE_CONTRACT.md +145 -0
- package/README.md +14 -29
- package/bin/zenith.js +89 -0
- package/package.json +39 -56
- package/src/config.js +136 -0
- package/src/core-template.js +30 -0
- package/src/errors.js +54 -0
- package/src/guards.js +61 -0
- package/src/hash.js +52 -0
- package/src/index.js +26 -0
- package/src/ir/index.js +1 -0
- package/src/order.js +69 -0
- package/src/path.js +131 -0
- package/src/schema.js +28 -0
- package/src/version.js +67 -0
- package/bin/zen-build.ts +0 -2
- package/bin/zen-dev.ts +0 -2
- package/bin/zen-preview.ts +0 -2
- package/bin/zenith.ts +0 -2
- package/cli/commands/add.ts +0 -37
- package/cli/commands/build.ts +0 -37
- package/cli/commands/create.ts +0 -702
- package/cli/commands/dev.ts +0 -388
- package/cli/commands/index.ts +0 -112
- package/cli/commands/preview.ts +0 -62
- package/cli/commands/remove.ts +0 -33
- package/cli/index.ts +0 -10
- package/cli/main.ts +0 -101
- package/cli/utils/branding.ts +0 -178
- package/cli/utils/content.ts +0 -112
- package/cli/utils/logger.ts +0 -46
- package/cli/utils/plugin-manager.ts +0 -114
- package/cli/utils/project.ts +0 -77
- package/compiler/README.md +0 -380
- package/compiler/build-analyzer.ts +0 -122
- package/compiler/css/index.ts +0 -317
- package/compiler/discovery/componentDiscovery.ts +0 -178
- package/compiler/discovery/layouts.ts +0 -70
- package/compiler/errors/compilerError.ts +0 -56
- package/compiler/finalize/finalizeOutput.ts +0 -192
- package/compiler/finalize/generateFinalBundle.ts +0 -82
- package/compiler/index.ts +0 -83
- package/compiler/ir/types.ts +0 -174
- package/compiler/output/types.ts +0 -34
- package/compiler/parse/detectMapExpressions.ts +0 -102
- package/compiler/parse/importTypes.ts +0 -78
- package/compiler/parse/parseImports.ts +0 -309
- package/compiler/parse/parseScript.ts +0 -46
- package/compiler/parse/parseTemplate.ts +0 -599
- package/compiler/parse/parseZenFile.ts +0 -66
- package/compiler/parse/scriptAnalysis.ts +0 -91
- package/compiler/parse/trackLoopContext.ts +0 -82
- package/compiler/runtime/dataExposure.ts +0 -317
- package/compiler/runtime/generateDOM.ts +0 -246
- package/compiler/runtime/generateHydrationBundle.ts +0 -407
- package/compiler/runtime/hydration.ts +0 -309
- package/compiler/runtime/navigation.ts +0 -432
- package/compiler/runtime/thinRuntime.ts +0 -160
- package/compiler/runtime/transformIR.ts +0 -370
- package/compiler/runtime/wrapExpression.ts +0 -95
- package/compiler/runtime/wrapExpressionWithLoop.ts +0 -83
- package/compiler/spa-build.ts +0 -917
- package/compiler/ssg-build.ts +0 -422
- package/compiler/test/validate-test.ts +0 -104
- package/compiler/transform/classifyExpression.ts +0 -444
- package/compiler/transform/componentResolver.ts +0 -312
- package/compiler/transform/componentScriptTransformer.ts +0 -303
- package/compiler/transform/expressionTransformer.ts +0 -385
- package/compiler/transform/fragmentLowering.ts +0 -634
- package/compiler/transform/generateBindings.ts +0 -47
- package/compiler/transform/generateHTML.ts +0 -28
- package/compiler/transform/layoutProcessor.ts +0 -132
- package/compiler/transform/slotResolver.ts +0 -292
- package/compiler/transform/transformNode.ts +0 -126
- package/compiler/transform/transformTemplate.ts +0 -38
- package/compiler/validate/invariants.ts +0 -292
- package/compiler/validate/validateExpressions.ts +0 -168
- package/core/config/index.ts +0 -16
- package/core/config/loader.ts +0 -69
- package/core/config/types.ts +0 -89
- package/core/index.ts +0 -135
- package/core/lifecycle/index.ts +0 -49
- package/core/lifecycle/zen-mount.ts +0 -182
- package/core/lifecycle/zen-unmount.ts +0 -88
- package/core/plugins/index.ts +0 -7
- package/core/plugins/registry.ts +0 -81
- package/core/reactivity/index.ts +0 -54
- package/core/reactivity/tracking.ts +0 -167
- package/core/reactivity/zen-batch.ts +0 -57
- package/core/reactivity/zen-effect.ts +0 -139
- package/core/reactivity/zen-memo.ts +0 -146
- package/core/reactivity/zen-ref.ts +0 -52
- package/core/reactivity/zen-signal.ts +0 -121
- package/core/reactivity/zen-state.ts +0 -180
- package/core/reactivity/zen-untrack.ts +0 -44
- package/dist/cli.js +0 -11665
- package/dist/zen-build.js +0 -21172
- package/dist/zen-dev.js +0 -21172
- package/dist/zen-preview.js +0 -21172
- package/dist/zenith.js +0 -21172
- package/router/index.ts +0 -28
- package/router/manifest.ts +0 -314
- package/router/navigation/ZenLink.zen +0 -231
- package/router/navigation/index.ts +0 -78
- package/router/navigation/zen-link.ts +0 -584
- package/router/runtime.ts +0 -458
- package/router/types.ts +0 -168
- package/runtime/build.ts +0 -17
- package/runtime/bundle-generator.ts +0 -1247
- package/runtime/client-runtime.ts +0 -549
- package/runtime/serve.ts +0 -93
- 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
|
-
|