@koppajs/koppajs-core 3.0.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.
@@ -0,0 +1,364 @@
1
+ export {};
2
+ import './kpa.d.ts';
3
+ import './globals.d.ts';
4
+ /**
5
+ * Symbol to identify whether a function is bound to this.
6
+ */
7
+ export declare const BOUND: unique symbol;
8
+ /**
9
+ * Symbol to identify whether an object is a Proxy.
10
+ */
11
+ export declare const IS_PROXY: unique symbol;
12
+ /**
13
+ * Arguments for the Core.take() method.
14
+ * Either a ComponentSource with a name, or a Plugin/Module.
15
+ */
16
+ export type TakeArgs = [ComponentSource, string] | [IPlugin | IModule];
17
+ /**
18
+ * Generic function type.
19
+ */
20
+ export type AnyFn = (...args: any[]) => unknown;
21
+ /**
22
+ * Function that has been bound to a context.
23
+ */
24
+ export type BoundFn = AnyFn & {
25
+ [BOUND]?: true;
26
+ };
27
+ /**
28
+ * Main Core API interface.
29
+ */
30
+ export interface CoreCallable {
31
+ (): void;
32
+ take: {
33
+ (component: ComponentSource, name: string): void;
34
+ (pluginOrModule: IPlugin | IModule): void;
35
+ };
36
+ }
37
+ /**
38
+ * Registry for lifecycle hooks.
39
+ */
40
+ export type LifecycleRegistry = Map<LifecycleHook, Set<HookCallback>>;
41
+ /**
42
+ * Callback function for lifecycle hooks.
43
+ * @param context - Optional state context passed to the hook
44
+ */
45
+ export type HookCallback = (context?: State | undefined) => Promise<void>;
46
+ /**
47
+ * Context provided to plugins and modules during installation.
48
+ */
49
+ export interface CoreCtx {
50
+ registerHook: (hookName: LifecycleHook, callback: HookCallback) => void;
51
+ take: CoreCallable['take'];
52
+ }
53
+ /**
54
+ * Shared base extension interface.
55
+ */
56
+ export interface IBaseExtension {
57
+ /** Unique name of the extension */
58
+ name: string;
59
+ /**
60
+ * Installation method called when extension is registered.
61
+ * @param context - Core context with registration utilities
62
+ * @returns Optional cleanup function
63
+ */
64
+ install(context: CoreCtx): (() => void) | void;
65
+ }
66
+ /**
67
+ * Plugin extension interface.
68
+ * Plugins provide setup methods that run in component context.
69
+ */
70
+ export interface IPlugin extends IBaseExtension {
71
+ /**
72
+ * Setup method called for each component instance.
73
+ * @this {State} - Component state as this context
74
+ * @returns Plugin data or cleanup function
75
+ */
76
+ setup(this: State): Record<string, unknown> | (() => void);
77
+ attach: never;
78
+ }
79
+ /**
80
+ * Internal helper type (no global augmentation of HTMLElement required).
81
+ */
82
+ export type HTMLElementWithInstance = HTMLElement & {
83
+ instance?: ComponentInstance;
84
+ };
85
+ /**
86
+ * Context provided to modules during attachment.
87
+ */
88
+ export interface ModuleContext {
89
+ element: HTMLElementWithInstance;
90
+ parent?: ComponentInstance;
91
+ core: {
92
+ take: CoreCallable['take'];
93
+ };
94
+ }
95
+ /**
96
+ * Module extension interface.
97
+ * Modules attach to component elements and provide element-level functionality.
98
+ */
99
+ export interface IModule extends IBaseExtension {
100
+ /**
101
+ * Attach method called when component is created.
102
+ * @this {ModuleContext} - Module context with element and parent
103
+ * @returns Optional module data to attach to component
104
+ */
105
+ attach(this: ModuleContext): Record<string, unknown> | void;
106
+ setup?: never;
107
+ }
108
+ /**
109
+ * # ComponentSource Contract
110
+ *
111
+ * This interface defines the contract between the KoppaJS Vite Plugin and
112
+ * the Core runtime. The plugin produces ComponentSource objects when
113
+ * transforming `.kpa` files, and the core consumes them at runtime.
114
+ *
115
+ * ## Field Categories
116
+ *
117
+ * ### REQUIRED Fields (must exist, core will fail without them)
118
+ * - `template` - HTML template string
119
+ * - `script` - JavaScript controller code string
120
+ * - `style` - CSS style string (can be empty string)
121
+ *
122
+ * ### OPTIONAL Fields (may exist, core handles absence gracefully)
123
+ * - `scriptMap` - Sourcemap for debugging (null or object)
124
+ * - `type` - Component composition mode ("options" | "composite")
125
+ * - `deps` - Async import map for [ts] block dependencies
126
+ * - `structAttr`- Custom attribute name for structural identity
127
+ *
128
+ * ### IGNORED Fields (allowed but unused by core runtime)
129
+ * - Any additional fields not listed above are permitted and will be
130
+ * ignored by the core runtime. This allows forward compatibility
131
+ * with plugin extensions without breaking existing core versions.
132
+ *
133
+ * ## Version Compatibility
134
+ *
135
+ * The plugin is expected to emit exactly these fields. Extra fields
136
+ * (e.g., debug metadata) may be added by the plugin but will not be
137
+ * processed by the core.
138
+ *
139
+ * @see https://github.com/koppajs/koppajs-core for full documentation
140
+ */
141
+ /**
142
+ * Async import function for a single dependency.
143
+ * Returns a promise that resolves to the imported module or value.
144
+ */
145
+ export interface DepInfo {
146
+ (): Promise<unknown>;
147
+ }
148
+ /**
149
+ * Map of dependency identifiers to async import functions.
150
+ * Each key is the local identifier used in the component script,
151
+ * and the value is an async function that resolves the import.
152
+ */
153
+ export type Deps = Record<string, DepInfo> | null;
154
+ /**
155
+ * Component source payload produced by the Vite plugin for `.kpa` files.
156
+ *
157
+ * This is the primary interface for the Core ↔ Plugin contract.
158
+ * See the ComponentSource Contract documentation above for field categories.
159
+ */
160
+ export interface ComponentSource {
161
+ /**
162
+ * HTML template string for the component.
163
+ * Contains the component's DOM structure with KoppaJS directives.
164
+ * @required
165
+ */
166
+ template: string;
167
+ /**
168
+ * JavaScript controller code string.
169
+ * Executed at runtime to produce the component controller.
170
+ * @required
171
+ */
172
+ script: string;
173
+ /**
174
+ * CSS style string for the component.
175
+ * Injected into document head with component-scoped ID.
176
+ * Can be empty string if component has no styles.
177
+ * @required
178
+ */
179
+ style: string;
180
+ /**
181
+ * Optional sourcemap payload for dynamic script execution.
182
+ * The vite-plugin emits this as a parsed sourcemap object (or null).
183
+ * The core runtime may re-attach this map for DevTools when evaluating scripts.
184
+ * @optional
185
+ */
186
+ scriptMap?: unknown | null;
187
+ /**
188
+ * Component composition type.
189
+ *
190
+ * - "options" (default): Creates a userContext that combines methods and state,
191
+ * and binds it to `this` in lifecycle hooks and methods.
192
+ * - "composite": No userContext is created, no `this` binding occurs.
193
+ * Used for components that compose behavior from multiple sources.
194
+ *
195
+ * If not specified, defaults to "options".
196
+ * @optional
197
+ */
198
+ type?: 'options' | 'composite';
199
+ /**
200
+ * Imported dependencies from [ts] block.
201
+ * Each key is the local identifier, value is an async function that resolves the import.
202
+ * The core runtime resolves these before evaluating the controller script.
203
+ * @optional
204
+ */
205
+ deps?: Deps;
206
+ /**
207
+ * Optional HTML attribute name to use for structural identity fallback.
208
+ * If specified and no structId is set via runtime helper, the reconciliation
209
+ * will attempt to read structId from this attribute.
210
+ * Default: 'data-k-struct'
211
+ * @optional
212
+ */
213
+ structAttr?: string;
214
+ /**
215
+ * Index signature to allow extra fields from the plugin.
216
+ * These fields are ignored by the core runtime but permitted
217
+ * for forward compatibility with plugin extensions.
218
+ *
219
+ * Common ignored fields might include:
220
+ * - Debug metadata
221
+ * - Plugin-specific configuration
222
+ * - Future extension points
223
+ */
224
+ [key: string]: unknown;
225
+ }
226
+ /**
227
+ * Public extension union.
228
+ */
229
+ export type IExtension = ComponentSource | IPlugin | IModule;
230
+ interface PropsDefinition {
231
+ type?: string;
232
+ required?: boolean;
233
+ default?: any;
234
+ regex?: string;
235
+ }
236
+ /**
237
+ * Event definition tuple: [eventType, target, handler]
238
+ * - eventType: DOM event name (e.g., "click", "input")
239
+ * - target: Selector string, Element, Window, or ref object
240
+ * - handler: Event handler function
241
+ */
242
+ export type EventDefinition = [
243
+ string,
244
+ string | Element | Window | {
245
+ ref: string;
246
+ selector?: string;
247
+ },
248
+ AnyFn
249
+ ];
250
+ /**
251
+ * Component reactive state object.
252
+ */
253
+ export type State = Record<string, any>;
254
+ /**
255
+ * Component methods object.
256
+ */
257
+ export type Methods = Record<string, AnyFn>;
258
+ /**
259
+ * Component props definition.
260
+ */
261
+ export type Props = Record<string, PropsDefinition>;
262
+ /**
263
+ * Component events array.
264
+ */
265
+ export type Events = Array<EventDefinition>;
266
+ /**
267
+ * List of property paths to watch for changes.
268
+ */
269
+ export type WatchList = string[];
270
+ /**
271
+ * Snapshot of watched properties.
272
+ */
273
+ export type WatchListSnapshot = {
274
+ parent: object;
275
+ properties: string[];
276
+ };
277
+ /**
278
+ * Component element references.
279
+ */
280
+ export type Refs = Record<string, HTMLElement>;
281
+ /**
282
+ * Options for composeBySource function.
283
+ */
284
+ export type ComposeOptions = {
285
+ /** Index of layer to write to when property doesn't exist in any layer */
286
+ defaultWriteIndex?: number;
287
+ /** Whether to include prototype properties in layer search */
288
+ includePrototype?: boolean;
289
+ };
290
+ export declare const lifecycleHooks: readonly ["created", "beforeMount", "mounted", "beforeUpdate", "updated", "beforeDestroy", "destroyed", "processed"];
291
+ /**
292
+ * Available lifecycle hook names.
293
+ */
294
+ export type LifecycleHook = (typeof lifecycleHooks)[number];
295
+ /**
296
+ * Lifecycle hook handler function.
297
+ * @this {State} - Component state as this context
298
+ */
299
+ export type LifecycleHandler = (this: State) => void | Promise<void>;
300
+ interface LifecycleHooks {
301
+ created?: LifecycleHandler;
302
+ beforeMount?: LifecycleHandler;
303
+ mounted?: LifecycleHandler;
304
+ beforeUpdate?: LifecycleHandler;
305
+ updated?: LifecycleHandler;
306
+ beforeDestroy?: LifecycleHandler;
307
+ destroyed?: LifecycleHandler;
308
+ processed?: LifecycleHandler;
309
+ }
310
+ export interface Lifecycle {
311
+ on: (name: LifecycleHook, fn: (this: State) => void | Promise<void>) => void;
312
+ off: (name: LifecycleHook, fn: (this: State) => void | Promise<void>) => void;
313
+ clear: () => void;
314
+ emit(hook: LifecycleHook): Promise<void>;
315
+ }
316
+ /**
317
+ * Context provided to component script during compilation.
318
+ */
319
+ export interface ComponentContext {
320
+ /** Element references */
321
+ $refs: Refs;
322
+ /** Parent component instance */
323
+ $parent?: ComponentInstance;
324
+ /** Emit event to parent components */
325
+ $emit: (eventName: string, ...args: unknown[]) => void;
326
+ /** Get plugin data */
327
+ $take: (pluginName: string) => Record<string, unknown> | AnyFn | void | undefined;
328
+ /** Dynamic module properties ($router, $store, ...) */
329
+ [key: `$${string}`]: unknown;
330
+ }
331
+ /**
332
+ * Compiled component script function.
333
+ * @param context - Component context with $refs, $parent, etc.
334
+ * @returns Component controller with state, methods, etc.
335
+ */
336
+ export type CompiledScript = (context: ComponentContext) => ComponentController;
337
+ /**
338
+ * Component controller returned from compiled script.
339
+ * Contains component definition: state, methods, props, events, etc.
340
+ */
341
+ export interface ComponentController extends LifecycleHooks {
342
+ /** Component reactive state */
343
+ state?: State;
344
+ /** User context (composed from methods + state for "options" type) */
345
+ userContext?: State;
346
+ /** Component methods */
347
+ methods?: Methods;
348
+ /** Component props definition */
349
+ props?: Props;
350
+ /** Component events */
351
+ events?: Events;
352
+ /** Properties to watch for changes */
353
+ watchList?: WatchList;
354
+ }
355
+ /**
356
+ * Runtime component instance.
357
+ * Extends ComponentController with runtime properties like element, template, etc.
358
+ */
359
+ export interface ComponentInstance extends ComponentContext, Omit<ComponentController, keyof LifecycleHooks> {
360
+ element: HTMLElementWithInstance;
361
+ template: HTMLTemplateElement;
362
+ readyPromise: Promise<void>;
363
+ lifecycleRegistry: LifecycleRegistry;
364
+ }
@@ -0,0 +1,3 @@
1
+ export declare const domExtensions: {
2
+ [key: string]: PropertyDescriptor;
3
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Extends global prototypes with KoppaJS helper utilities.
3
+ *
4
+ * - Object.prototype is always extended (always available in JS)
5
+ * - HTMLElement.prototype is only extended when DOM APIs exist
6
+ *
7
+ * In Node/SSR environments DOM-specific extensions are skipped automatically.
8
+ */
9
+ export declare const extend: () => void;
@@ -0,0 +1,10 @@
1
+ import type { IModule, IPlugin } from '../types';
2
+ /**
3
+ * Global registry for extensions (plugins and modules).
4
+ * Plugins provide setup methods for components.
5
+ * Modules provide attach methods for component elements.
6
+ */
7
+ export declare const ExtensionRegistry: {
8
+ modules: Record<string, IModule>;
9
+ plugins: Record<string, IPlugin>;
10
+ };
@@ -0,0 +1,55 @@
1
+ import { type AnyFn, type State, type Methods } from '../types';
2
+ /**
3
+ * Binds a function to a context once, preventing multiple bindings.
4
+ * Uses a symbol to mark bound functions.
5
+ * @param fn - Function to bind
6
+ * @param userContext - Context to bind function to
7
+ * @returns Bound function (or original if already bound or not a function)
8
+ */
9
+ export declare function bindOnce(fn: AnyFn, userContext: State): AnyFn;
10
+ /**
11
+ * Binds all methods from the `methods` object to the provided `userContext`.
12
+ * @param methods - A map of method names and functions
13
+ * @param userContext - The user context object (this context for user functions)
14
+ */
15
+ export declare function bindMethods(methods: Methods, userContext: State): void;
16
+ /**
17
+ * Checks if a string contains basic HTML tags.
18
+ * @param input - The input string to check
19
+ * @returns True if the string contains HTML-like syntax, otherwise false
20
+ */
21
+ export declare function containsHTML(input: string): boolean;
22
+ /**
23
+ * Safely retrieves a value from a nested object using a string path.
24
+ * Supports dot/bracket notation: "foo.bar[0].baz"
25
+ * Does NOT throw (returns undefined on invalid access).
26
+ * @param obj - Object to read from
27
+ * @param path - Property path (dot/bracket notation)
28
+ * @returns Value at path or undefined if not found
29
+ */
30
+ export declare function getValueByPath(obj: unknown, path: string): unknown;
31
+ /**
32
+ * Resolves a type constructor or string into a normalized lowercase type name.
33
+ * Used for comparing prop types during runtime validation.
34
+ * @param input - A string type name or a constructor function
35
+ * @returns A lowercase string type (e.g. "string", "array") or "unknown"
36
+ */
37
+ export declare function getExpectedPropTypeName(input: unknown): string;
38
+ /**
39
+ * Checks whether a string is a simple property path expression.
40
+ * Supports: foo.bar.baz, foo[0].bar, foo.bar[0].baz
41
+ * @param expression - Expression string to check
42
+ * @returns True if expression is a simple path
43
+ */
44
+ export declare function isSimplePathExpression(expression: string): boolean;
45
+ /**
46
+ * Sets a value on a nested object using a dot/bracket-notated path.
47
+ * Does NOT create missing objects/arrays. Children may not "invent" structure in parent.
48
+ * Throws descriptive errors when the path is invalid or non-writable.
49
+ * Supports bracket tokens like [0] or [key] (key treated as string unless numeric).
50
+ * @param obj - Object to write to
51
+ * @param path - Property path (dot/bracket notation)
52
+ * @param value - Value to set
53
+ * @throws Error if path is invalid or property is read-only
54
+ */
55
+ export declare function setValueByPath(obj: Record<string, unknown>, path: string, value: unknown): void;
@@ -0,0 +1,34 @@
1
+ import type { State, HookCallback, LifecycleHook, LifecycleRegistry } from '../types';
2
+ /**
3
+ * Creates a new lifecycle hook registry.
4
+ * @returns New empty lifecycle registry
5
+ */
6
+ export declare function createHookRegistry(): LifecycleRegistry;
7
+ /**
8
+ * Registers a hook callback for the given event name.
9
+ * Creates the internal Set if it doesn't exist yet.
10
+ * @param registry - Registry to register in, or "global" for global registry
11
+ * @param name - Lifecycle hook name
12
+ * @param cb - Callback function to register
13
+ */
14
+ export declare function hookOn(registry: LifecycleRegistry | 'global', name: LifecycleHook, cb: HookCallback): void;
15
+ /**
16
+ * Unregisters a specific hook callback for the given event name.
17
+ * @param registry - Registry to unregister from, or "global" for global registry
18
+ * @param name - Lifecycle hook name
19
+ * @param cb - Callback function to unregister
20
+ */
21
+ export declare function hookOff(registry: LifecycleRegistry | 'global', name: LifecycleHook, cb: HookCallback): void;
22
+ /**
23
+ * Emits an event to all registered callbacks for the given name.
24
+ * Each callback is wrapped in try-catch to prevent one failure from stopping others.
25
+ * @param registry - Registry to emit from, or "global" for global registry
26
+ * @param name - Lifecycle hook name
27
+ * @param context - Optional state context to pass to callbacks
28
+ */
29
+ export declare function hookEmit(registry: LifecycleRegistry | 'global', name: LifecycleHook, context?: State): Promise<void>;
30
+ /**
31
+ * Clears all registered hooks in the registry.
32
+ * @param registry - Registry to clear, or "global" for global registry
33
+ */
34
+ export declare function hookClear(registry: LifecycleRegistry | 'global'): void;
@@ -0,0 +1,6 @@
1
+ export declare const STRUCT_ID: unique symbol;
2
+ export declare const SLOT_ID: unique symbol;
3
+ export declare function setStructId(node: object, id: unknown): void;
4
+ export declare function getStructId(node: object): unknown;
5
+ export declare function setSlotId(node: object, id: unknown): void;
6
+ export declare function getSlotId(node: object): unknown;
@@ -0,0 +1,15 @@
1
+ export * from './helper';
2
+ export * from './dom';
3
+ export { domExtensions } from './dom';
4
+ export * from './object';
5
+ export { objectExtensions } from './object';
6
+ export * from './string';
7
+ export * from './script';
8
+ export * from './template-watch';
9
+ export * from './hook-registry';
10
+ export * from './logger';
11
+ export { ExtensionRegistry } from './extension-registry';
12
+ export * from './type-guards';
13
+ export { extend } from './extend';
14
+ export { reconcileDOM } from './reconcile';
15
+ export * from './identity';
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Logging system with configurable log levels and emoji indicators.
3
+ * Supports different configurations for development and production.
4
+ */
5
+ /**
6
+ * Log levels in order of severity.
7
+ */
8
+ export declare enum LogLevel {
9
+ DEBUG = 0,
10
+ INFO = 1,
11
+ WARN = 2,
12
+ ERROR = 3,
13
+ NONE = 4
14
+ }
15
+ type LogContext = {
16
+ component?: string;
17
+ method?: string;
18
+ [key: string]: unknown;
19
+ };
20
+ /**
21
+ * Logger class for consistent logging across the framework.
22
+ */
23
+ declare class Logger {
24
+ private level;
25
+ private isDevelopment;
26
+ /**
27
+ * Initialize logger with environment detection.
28
+ * @param options - Logger configuration options
29
+ * @param options.level - Minimum log level (defaults based on environment)
30
+ * @param options.isDevelopment - Whether in development mode
31
+ */
32
+ init(options?: {
33
+ level?: LogLevel;
34
+ isDevelopment?: boolean;
35
+ }): void;
36
+ /**
37
+ * Set the minimum log level.
38
+ * @param level - Minimum log level to display
39
+ */
40
+ setLevel(level: LogLevel): void;
41
+ /**
42
+ * Get current log level.
43
+ * @returns Current minimum log level
44
+ */
45
+ getLevel(): LogLevel;
46
+ private shouldLog;
47
+ private formatMessage;
48
+ /**
49
+ * Log an error message.
50
+ * @param message - Error message
51
+ * @param args - Additional arguments to log
52
+ */
53
+ error(message: string, ...args: any[]): void;
54
+ /**
55
+ * Log a warning message.
56
+ * @param message - Warning message
57
+ * @param args - Additional arguments to log
58
+ */
59
+ warn(message: string, ...args: any[]): void;
60
+ /**
61
+ * Log an info message.
62
+ * @param message - Info message
63
+ * @param args - Additional arguments to log
64
+ */
65
+ info(message: string, ...args: any[]): void;
66
+ /**
67
+ * Log a debug message.
68
+ * @param message - Debug message
69
+ * @param args - Additional arguments to log
70
+ */
71
+ debug(message: string, ...args: any[]): void;
72
+ /**
73
+ * Log an error with context information.
74
+ * @param message - Error message
75
+ * @param context - Context object with additional information
76
+ * @param error - Optional error object
77
+ */
78
+ errorWithContext(message: string, context: LogContext, error?: Error | unknown): void;
79
+ /**
80
+ * Log a warning with context information.
81
+ * @param message - Warning message
82
+ * @param context - Context object with additional information
83
+ */
84
+ warnWithContext(message: string, context: LogContext): void;
85
+ }
86
+ export declare const logger: Logger;
87
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const objectExtensions: {
2
+ [key: string]: PropertyDescriptor;
3
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * DOM Reconciliation Utility
3
+ *
4
+ * Provides efficient DOM diffing to update the DOM without destroying
5
+ * and recreating custom element instances. This prevents infinite mount
6
+ * loops when parent components re-render.
7
+ */
8
+ /**
9
+ * Reconciles the DOM content of a host element with new content.
10
+ * This is the main entry point for DOM reconciliation.
11
+ *
12
+ * The algorithm:
13
+ * 1. For the first render (host has no children), simply append the new content
14
+ * 2. For subsequent renders, diff the existing children against new content
15
+ * 3. Preserve custom element instances where possible
16
+ * 4. Only update what has changed
17
+ *
18
+ * @param host - The host element to update
19
+ * @param newContent - The new DocumentFragment with desired content
20
+ * @param isFirstRender - Whether this is the initial render
21
+ * @param structAttr - Optional attribute name for structural identity fallback
22
+ */
23
+ export declare function reconcileDOM(host: HTMLElement, newContent: DocumentFragment, isFirstRender: boolean, structAttr?: string): void;
@@ -0,0 +1,18 @@
1
+ import type { CompiledScript } from '../types';
2
+ /**
3
+ * Resolved dependencies object passed to the compiled script.
4
+ * Keys are the local identifiers, values are the resolved import values.
5
+ */
6
+ export type ResolvedDeps = Record<string, unknown>;
7
+ /**
8
+ * Compiles component script string into an executable function.
9
+ * Exposes context variables ($refs, $parent, etc.) and dynamic module properties.
10
+ * Optionally injects resolved dependencies as local variables.
11
+ *
12
+ * @param strg - Component script string
13
+ * @param resolvedDeps - Optional resolved dependencies to inject as local variables
14
+ * @returns Compiled script function
15
+ * @throws Error if compilation fails
16
+ * @throws SyntaxError if user script redeclares an injected dependency name
17
+ */
18
+ export declare function compileCode(strg: string, resolvedDeps?: ResolvedDeps): CompiledScript;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Converts a kebab-case string to camelCase.
3
+ * @param s - The kebab-case string to convert
4
+ * @returns The converted camelCase string
5
+ */
6
+ export declare function kebabToCamel(s: string): string;
7
+ /**
8
+ * Evaluates a JavaScript expression in a controlled, restricted scope.
9
+ * Blocks access to dangerous globals (window, document, eval, etc.).
10
+ * Treats simple property paths as "safe" and resolves them via getValueByPath.
11
+ * Evaluates complex expressions using Function, but only with variables from state.
12
+ * Functions are called with state as this context.
13
+ * Note: This is not a full sandbox. It's "restricted and pragmatic".
14
+ * @param expression - Expression string to evaluate
15
+ * @param state - State object to use as context
16
+ * @returns Evaluated result or undefined on error/forbidden keywords
17
+ */
18
+ export declare function evaluateExpression(expression: string, state?: Record<string, unknown>): unknown;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Extracts property paths from template expressions for automatic watching.
3
+ * Parses {{ expression }} syntax and extracts simple property paths.
4
+ * @param templateHtml - Template HTML string
5
+ * @returns Array of unique property paths to watch
6
+ */
7
+ export declare function extractWatchListFromTemplate(templateHtml: string): string[];