regor 1.3.4 → 1.3.6
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/README.md +41 -18
- package/dist/regor.d.ts +279 -29
- package/dist/regor.es2015.cjs.js +856 -439
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +856 -439
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +856 -439
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +856 -439
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +856 -439
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +856 -439
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +847 -427
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +847 -427
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +847 -427
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# Regor
|
|
4
4
|
|
|
5
|
-
Regor is a
|
|
5
|
+
Regor is a runtime-first UI framework for teams that want direct DOM control, strong TypeScript ergonomics, and precise reactivity behavior without being forced into a Virtual DOM architecture.
|
|
6
|
+
|
|
7
|
+
Its template syntax is familiar to Vue users (`r-if`, `r-model`, `r-for`, `r-bind`), but its runtime model is intentionally different: Regor is built for progressive enhancement, mixed-rendering environments, and incremental adoption.
|
|
6
8
|
|
|
7
9
|
### [](https://www.npmjs.com/package/regor)
|
|
8
10
|
|
|
@@ -10,9 +12,9 @@ Regor is a powerful UI framework designed to streamline the development of HTML5
|
|
|
10
12
|
|
|
11
13
|
## Key Features
|
|
12
14
|
|
|
13
|
-
- **
|
|
14
|
-
- **TypeScript:**
|
|
15
|
-
- **No Build Step Required:** Define components in TypeScript using tagged string templates,
|
|
15
|
+
- **No VDOM Layer:** Bind directly to real DOM for transparent runtime behavior and straightforward debugging.
|
|
16
|
+
- **TypeScript-Native:** Use standard TypeScript interfaces, classes, and generics without framework-specific file formats.
|
|
17
|
+
- **No Build Step Required:** Define components in TypeScript using tagged string templates with npm, CDN ESM, or global build workflows.
|
|
16
18
|
- **Secure Evaluation:** Regor's secure JavaScript VM ensures safe runtime compilation. You can enable security policy in your page without removing runtime compilation support.
|
|
17
19
|
|
|
18
20
|
```html
|
|
@@ -22,9 +24,9 @@ Regor is a powerful UI framework designed to streamline the development of HTML5
|
|
|
22
24
|
/>
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
- **Flexible Reactivity:**
|
|
26
|
-
- **
|
|
27
|
-
- **Reentrance:**
|
|
27
|
+
- **Flexible Reactivity:** Combine `ref`, `sref`, `batch`, `pause`, `resume`, and `entangle` for explicit state orchestration.
|
|
28
|
+
- **Static-First + Islands:** Bind to existing DOM without removing server-rendered HTML, ideal for progressive enhancement.
|
|
29
|
+
- **Reentrance:** Mount multiple times in already-mounted regions with same or different app contexts.
|
|
28
30
|
- **Compatibility:** Rendered pages are designed for seamless integration with other libraries manipulating the DOM.
|
|
29
31
|
|
|
30
32
|
## Documentation
|
|
@@ -72,16 +74,13 @@ const template = html`<button @click="count++">
|
|
|
72
74
|
|
|
73
75
|
const props = ['message']
|
|
74
76
|
|
|
75
|
-
const myComponent = createComponent<MyComponent>(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
props,
|
|
83
|
-
},
|
|
84
|
-
)
|
|
77
|
+
const myComponent = createComponent<MyComponent>(template, {
|
|
78
|
+
context: (head) => ({
|
|
79
|
+
message: head.props.message,
|
|
80
|
+
count: ref(0),
|
|
81
|
+
}),
|
|
82
|
+
props,
|
|
83
|
+
})
|
|
85
84
|
|
|
86
85
|
createApp({
|
|
87
86
|
components: { myComponent },
|
|
@@ -161,7 +160,31 @@ or
|
|
|
161
160
|
|
|
162
161
|
## Comparison with VueJs
|
|
163
162
|
|
|
164
|
-
Regor
|
|
163
|
+
Regor is openly inspired by Vue’s concepts (even adopting a similar directive syntax like r-if / r-model instead of v-if / v-model), but it fundamentally diverges in its implementation. It prioritizes runtime flexibility, build-less environments, and strict TypeScript integration over the Virtual DOM (VDOM) paradigm.
|
|
164
|
+
|
|
165
|
+
### Architecture and rendering model
|
|
166
|
+
|
|
167
|
+
- **Vue:** Uses a Virtual DOM. This provides excellent performance for highly dynamic Single Page Applications (SPAs) because Vue calculates diffs in memory before updating the browser. However, it usually requires a compilation step to optimize templates, and hydrating existing server-rendered HTML can be notoriously strict (hydration mismatches).
|
|
168
|
+
- **Regor:** Ditches the VDOM entirely. It binds directly to the actual DOM. Regor explicitly supports Static-first + dynamic islands and "Reentrance." You can mount an application multiple times over already-mounted regions or existing server-rendered HTML without destroying the elements.
|
|
169
|
+
- **Verdict:** Regor is significantly more flexible for integrating into existing applications, multi-page applications (MPAs), or legacy backends.
|
|
170
|
+
|
|
171
|
+
### Runtime and deployment model
|
|
172
|
+
|
|
173
|
+
- **Vue:** Commonly paired with a build pipeline for SFCs and tooling depth.
|
|
174
|
+
- **Regor:** Designed to require no build step. You can write standard TypeScript using tagged string templates (e.g., `html` tags for templates) and it will evaluate at runtime. Crucially, Regor features a Secure JavaScript VM for runtime compilation that adheres to strict Content Security Policies (CSP)—a common pain point when using Vue's runtime compiler in enterprise environments.
|
|
175
|
+
- **Verdict:** Regor wins in deployment flexibility and zero-config setups. It respects modern security policies out of the box without demanding a bundler.
|
|
176
|
+
|
|
177
|
+
### Reactivity control model
|
|
178
|
+
|
|
179
|
+
- **Vue:** Uses ES6 Proxies for a highly automated, "magical" reactivity system. You update an object, and Vue figures out what to re-render. However, this magic can sometimes abstract away performance bottlenecks, leading to over-rendering if you aren't careful with deep reactivity.
|
|
180
|
+
- **Regor:** Provides fine-tuned, manual control. It offers `ref` (deep reactivity) and `sref` (simple/shallow reactivity without nested observation). Furthermore, Regor provides advanced control APIs like `pause()` and `resume()` to stop a ref's auto-triggers, `entangle()` to sync two refs effortlessly, and `batch()` for precise state grouping.
|
|
181
|
+
- **Verdict:** Vue's reactivity is easier for beginners.. Regor’s reactivity is more flexible and transparent, giving engineers exact tools to orchestrate update semantics and prevent unwanted DOM paints.
|
|
182
|
+
|
|
183
|
+
### TypeScript ergonomics
|
|
184
|
+
|
|
185
|
+
- **Vue:** TypeScript support in Vue has improved massively, but it still relies on heavy IDE plugins (Volar) and specialized compilers (vue-tsc) to understand .vue files. The separation between the `<template>` and `<script>` requires tooling to bridge the gap.
|
|
186
|
+
- **Regor:** Offers native TypeScript support without workarounds. Because components and templates are defined using standard TypeScript functions, class-based contexts, and `ComponentHead<T>`, standard TypeScript compilers and IDEs understand 100% of the code immediately.
|
|
187
|
+
- **Verdict:** Regor offers a purer, higher-quality TypeScript experience. It leverages the language itself rather than relying on framework-specific compiler magic to provide type safety.
|
|
165
188
|
|
|
166
189
|
## Supported Directives
|
|
167
190
|
|
package/dist/regor.d.ts
CHANGED
|
@@ -1,28 +1,134 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Runtime metadata passed to a component's `context(head)` factory.
|
|
5
|
+
*
|
|
6
|
+
* `ComponentHead` gives component authors controlled access to:
|
|
7
|
+
* - incoming values from parent (`head.props`)
|
|
8
|
+
* - component mount boundaries (`head.start`, `head.end`)
|
|
9
|
+
* - parent-context event bridge (`head.emit(...)`)
|
|
10
|
+
* - optional behavior toggles (`head.autoProps`, `head.entangle`, `head.enableSwitch`)
|
|
11
|
+
*
|
|
12
|
+
* Typical usage:
|
|
13
|
+
* ```ts
|
|
14
|
+
* const Card = createComponent(
|
|
15
|
+
* `<article><h3 r-text="title"></h3></article>`,
|
|
16
|
+
* {
|
|
17
|
+
* props: ['title'],
|
|
18
|
+
* context(head) {
|
|
19
|
+
* // read parent values
|
|
20
|
+
* const initialTitle = head.props.title
|
|
21
|
+
*
|
|
22
|
+
* // optional event to parent/listener
|
|
23
|
+
* const close = () => head.emit('close', { reason: 'user' })
|
|
24
|
+
*
|
|
25
|
+
* return { title: initialTitle, close }
|
|
26
|
+
* },
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
3
30
|
export declare class ComponentHead<TContext extends IRegorContext | object = IRegorContext> {
|
|
31
|
+
/**
|
|
32
|
+
* Values provided by parent for this component instance.
|
|
33
|
+
*
|
|
34
|
+
* Sources:
|
|
35
|
+
* - declared props via `props: ['foo']` + attribute binding (`:foo="..."`)
|
|
36
|
+
* - object binding via `:context="{ ... }"`
|
|
37
|
+
*/
|
|
4
38
|
props: TContext;
|
|
39
|
+
/**
|
|
40
|
+
* Comment node that marks the beginning of this mounted component block.
|
|
41
|
+
* Advanced use only.
|
|
42
|
+
*/
|
|
5
43
|
start: Comment;
|
|
44
|
+
/**
|
|
45
|
+
* Comment node that marks the end of this mounted component block.
|
|
46
|
+
* Advanced use only.
|
|
47
|
+
*/
|
|
6
48
|
end: Comment;
|
|
49
|
+
/**
|
|
50
|
+
* Captured context chain used by this component instance.
|
|
51
|
+
* Used internally for lifecycle/unmount behavior.
|
|
52
|
+
*/
|
|
7
53
|
ctx: IRegorContext[];
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
54
|
+
/**
|
|
55
|
+
* Controls whether Regor should automatically apply incoming `head.props`
|
|
56
|
+
* values to the component context after `context(head)` returns.
|
|
57
|
+
*
|
|
58
|
+
* Think of it as "auto wire parent inputs into my component fields".
|
|
59
|
+
*
|
|
60
|
+
* - `true` (default):
|
|
61
|
+
* - If a key exists in `head.props` but does not exist on the object
|
|
62
|
+
* returned by `context(head)`, Regor adds that key to component context.
|
|
63
|
+
* - Existing ref fields can receive incoming values automatically.
|
|
64
|
+
* - Ref-to-ref inputs can be entangled when `head.entangle` is enabled.
|
|
65
|
+
* - `false`:
|
|
66
|
+
* - Regor does not auto-apply props.
|
|
67
|
+
* - You fully control mapping manually inside `context(head)`.
|
|
68
|
+
*
|
|
69
|
+
* Use `false` when you need strict custom mapping/validation/transforms
|
|
70
|
+
* before any value touches component state.
|
|
71
|
+
*
|
|
72
|
+
* "Missing key" is always checked against the returned component context object.
|
|
73
|
+
*
|
|
74
|
+
* Example (auto add):
|
|
75
|
+
* ```ts
|
|
76
|
+
* // Parent passes: :context="{ badge: 'pro' }"
|
|
77
|
+
* context(head) {
|
|
78
|
+
* // Returned context has no "badge" key:
|
|
79
|
+
* return { name: ref('Ada') }
|
|
80
|
+
* }
|
|
81
|
+
* // Resulting component context becomes:
|
|
82
|
+
* // { name: ref('Ada'), badge: 'pro' }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* Example:
|
|
86
|
+
* ```ts
|
|
87
|
+
* context(head) {
|
|
88
|
+
* head.autoProps = false
|
|
89
|
+
* const title = ref((head.props.title as string) ?? 'Untitled')
|
|
90
|
+
* return { title }
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
10
94
|
autoProps: boolean;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
95
|
+
/**
|
|
96
|
+
* Enables two-way ref linking between incoming props and component context
|
|
97
|
+
* when `autoProps` is also enabled.
|
|
98
|
+
*
|
|
99
|
+
* - `true` (default): parent and component refs stay synchronized.
|
|
100
|
+
* - `false`: component keeps local ref isolation.
|
|
101
|
+
*/
|
|
17
102
|
entangle: boolean;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
103
|
+
/**
|
|
104
|
+
* Enables slot context switch behavior for advanced slot scenarios.
|
|
105
|
+
* Default: `false`.
|
|
106
|
+
*/
|
|
20
107
|
enableSwitch: boolean;
|
|
21
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Optional hook called after automatic prop assignment completes.
|
|
110
|
+
* Useful when post-assignment normalization is needed.
|
|
111
|
+
*/
|
|
22
112
|
onAutoPropsAssigned?: () => void;
|
|
23
113
|
constructor(props: TContext, element: Element, ctx: IRegorContext[], start: Comment, end: Comment);
|
|
24
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Emits a custom DOM event from the component host element.
|
|
116
|
+
*
|
|
117
|
+
* Example:
|
|
118
|
+
* ```ts
|
|
119
|
+
* head.emit('saved', { id: 42 })
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* Parent markup can listen via regular event binding:
|
|
123
|
+
* ```html
|
|
124
|
+
* <MyComp @saved="onSaved"></MyComp>
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
25
127
|
emit: (event: string, args: Record<string, unknown>) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Unmounts this component instance by removing nodes between `start` and `end`
|
|
130
|
+
* and calling unmount lifecycle handlers for captured contexts.
|
|
131
|
+
*/
|
|
26
132
|
unmount(): void;
|
|
27
133
|
}
|
|
28
134
|
export declare class RegorConfig {
|
|
@@ -83,17 +189,34 @@ export declare interface IRegorContext extends Record<string, unknown> {
|
|
|
83
189
|
}
|
|
84
190
|
export type IsLazy = (i: number, d: number) => boolean;
|
|
85
191
|
export type IsLazyKey = (key: string, d: number) => boolean;
|
|
192
|
+
export interface DirectiveUpdatePayload {
|
|
193
|
+
el: HTMLElement;
|
|
194
|
+
expr: string;
|
|
195
|
+
values: unknown[];
|
|
196
|
+
previousValues?: unknown[];
|
|
197
|
+
option?: unknown;
|
|
198
|
+
previousOption?: unknown;
|
|
199
|
+
flags?: string[];
|
|
200
|
+
parseResult: ParseResult;
|
|
201
|
+
dynamicOption?: ParseResult;
|
|
202
|
+
}
|
|
203
|
+
export interface MountedDirective {
|
|
204
|
+
update?: (payload: DirectiveUpdatePayload) => void;
|
|
205
|
+
unmount?: Unbinder;
|
|
206
|
+
}
|
|
86
207
|
export interface Directive {
|
|
87
208
|
isLazy?: IsLazy;
|
|
88
209
|
isLazyKey?: IsLazyKey;
|
|
89
210
|
collectRefObj?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* The refs in parseResult are still reactive. */
|
|
211
|
+
/** If once is enabled, updates are not re-triggered after initial mount. */
|
|
92
212
|
once?: boolean;
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Called once at bind time.
|
|
215
|
+
* Returns either:
|
|
216
|
+
* - unmount function
|
|
217
|
+
* - mounted object with `update` and/or `unmount`
|
|
218
|
+
*/
|
|
219
|
+
mount: (payload: DirectiveUpdatePayload) => Unbinder | MountedDirective | void;
|
|
97
220
|
}
|
|
98
221
|
export interface BindData {
|
|
99
222
|
unbinders: Unbinder[];
|
|
@@ -101,9 +224,9 @@ export interface BindData {
|
|
|
101
224
|
}
|
|
102
225
|
export type Unbinder = () => void;
|
|
103
226
|
export interface ParseResult {
|
|
104
|
-
value:
|
|
227
|
+
value: () => unknown[];
|
|
105
228
|
stop: StopObserving;
|
|
106
|
-
subscribe
|
|
229
|
+
subscribe: (observer: ObserveCallback<unknown[]>, init?: boolean) => StopObserving;
|
|
107
230
|
refs: Array<AnyRef | undefined>;
|
|
108
231
|
context: Record<string, unknown>;
|
|
109
232
|
}
|
|
@@ -198,24 +321,77 @@ export interface Component<TContext extends IRegorContext | object = IRegorConte
|
|
|
198
321
|
export type OnMounted = () => void;
|
|
199
322
|
export type OnUnmounted = () => void;
|
|
200
323
|
export interface CreateComponentOptions<TContext extends IRegorContext | object = IRegorContext> {
|
|
324
|
+
/**
|
|
325
|
+
* Enables interpolation transform inside the component template.
|
|
326
|
+
*
|
|
327
|
+
* When `true` (default), text like `{{ expr }}` / `[[ expr ]]` is converted
|
|
328
|
+
* to directive bindings during component template preparation.
|
|
329
|
+
*
|
|
330
|
+
* Set to `false` when the template should keep interpolation markers as plain text.
|
|
331
|
+
*/
|
|
201
332
|
useInterpolation?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Regor configuration used while creating this component.
|
|
335
|
+
*
|
|
336
|
+
* Useful when the component must use a specific config instance
|
|
337
|
+
* (custom directives, global context, registered components).
|
|
338
|
+
*/
|
|
202
339
|
config?: RegorConfig;
|
|
203
340
|
/**
|
|
204
|
-
*
|
|
341
|
+
* Factory that creates the component context.
|
|
342
|
+
*
|
|
343
|
+
* `head` contains incoming parent-bound values (`head.props`) and mount controls.
|
|
344
|
+
*
|
|
345
|
+
* Example:
|
|
346
|
+
* ```ts
|
|
347
|
+
* context(head) {
|
|
348
|
+
* return {
|
|
349
|
+
* title: head.props.title ?? 'Untitled',
|
|
350
|
+
* close: () => head.emit('close', { reason: 'user' }),
|
|
351
|
+
* }
|
|
352
|
+
* }
|
|
353
|
+
* ```
|
|
205
354
|
*/
|
|
206
355
|
context?(head: ComponentHead<TContext>): TContext;
|
|
356
|
+
/**
|
|
357
|
+
* Controls attribute fallthrough from component host to component root.
|
|
358
|
+
*
|
|
359
|
+
* - `true` (default): non-prop attributes like `class`, `style`, `id` are inherited.
|
|
360
|
+
* - `false`: host attributes are not forwarded automatically.
|
|
361
|
+
*/
|
|
207
362
|
inheritAttrs?: boolean;
|
|
208
363
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
364
|
+
* Declares prop names accepted via single-prop binding (`:foo`, `r-bind:foo`, `.foo`).
|
|
365
|
+
*
|
|
366
|
+
* Use camelCase names in this list.
|
|
367
|
+
* Kebab-case template attributes are matched to camelCase automatically.
|
|
368
|
+
*
|
|
369
|
+
* Example:
|
|
370
|
+
* ```ts
|
|
371
|
+
* props: ['userName', 'isActive']
|
|
372
|
+
* ```
|
|
373
|
+
* ```html
|
|
374
|
+
* <UserCard :user-name="name" r-bind:is-active="enabled"></UserCard>
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* Note:
|
|
378
|
+
* `:context="{ ... }"` can assign arbitrary component fields even when
|
|
379
|
+
* they are not declared in `props`.
|
|
214
380
|
*/
|
|
215
381
|
props?: string[];
|
|
216
|
-
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
382
|
+
/**
|
|
383
|
+
* Default component name used by global registration (`config.addComponent(...)`).
|
|
384
|
+
*
|
|
385
|
+
* Required for global registration.
|
|
386
|
+
* Optional when component is provided via app/component local `components` context.
|
|
387
|
+
*
|
|
388
|
+
* Example:
|
|
389
|
+
* ```ts
|
|
390
|
+
* const Card = createComponent('<div>...</div>', { defaultName: 'CardView' })
|
|
391
|
+
* cfg.addComponent(Card)
|
|
392
|
+
* // usable as <CardView></CardView>
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
219
395
|
defaultName?: string;
|
|
220
396
|
}
|
|
221
397
|
export interface Scope<TRegorContext> {
|
|
@@ -224,7 +400,81 @@ export interface Scope<TRegorContext> {
|
|
|
224
400
|
[ScopeSymbol]: true;
|
|
225
401
|
[key: string]: unknown;
|
|
226
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Creates and mounts a Regor application on an existing DOM root.
|
|
405
|
+
*
|
|
406
|
+
* The app can bind directly to existing markup or replace root content with
|
|
407
|
+
* a provided `template`/`json` before binding.
|
|
408
|
+
*
|
|
409
|
+
* @typeParam TRegorContext - Root app context type.
|
|
410
|
+
* @param context - App context object (or `useScope(... )` result).
|
|
411
|
+
* @param template - Mount target + optional template source.
|
|
412
|
+
* @param config -Optional Regor config. Uses `RegorConfig.getDefault()` when omitted.
|
|
413
|
+
*
|
|
414
|
+
* @returns App handle with:
|
|
415
|
+
* - `context`: the same context instance used for binding
|
|
416
|
+
* - `unbind()`: removes Regor observers/listeners from the root
|
|
417
|
+
* - `unmount()`: removes the root element from DOM
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```ts
|
|
421
|
+
* const root = document.getElementById('app')!
|
|
422
|
+
* const app = createApp(
|
|
423
|
+
* { count: ref(0) },
|
|
424
|
+
* {
|
|
425
|
+
* element: root,
|
|
426
|
+
* template: `<button @click="count(count()+1)" r-text="count"></button>`,
|
|
427
|
+
* },
|
|
428
|
+
* )
|
|
429
|
+
* ```
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* // Bind against existing markup without replacing it.
|
|
434
|
+
* const app = createApp(
|
|
435
|
+
* { user: ref('Ada') },
|
|
436
|
+
* { selector: '#header-island' },
|
|
437
|
+
* )
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
227
440
|
export declare const createApp: <TRegorContext extends IRegorContext | object = IRegorContext>(context: TRegorContext | Scope<TRegorContext>, template?: Template | string, config?: RegorConfig) => App<TRegorContext>;
|
|
441
|
+
/**
|
|
442
|
+
* Creates a reusable Regor component definition.
|
|
443
|
+
*
|
|
444
|
+
* `createComponent` prepares a template once, then Regor clones/binds it for each
|
|
445
|
+
* component instance in the app.
|
|
446
|
+
*
|
|
447
|
+
* @typeParam TContext - Component context type.
|
|
448
|
+
* @param template - Component template source:
|
|
449
|
+
* - inline HTML string
|
|
450
|
+
* - `Template` object (`template`, `element`, `selector`, or `json`)
|
|
451
|
+
* @param options - Component options (`context`, `props`, `inheritAttrs`, etc.).
|
|
452
|
+
* You can also pass `string[]` as shorthand for `props`.
|
|
453
|
+
*
|
|
454
|
+
* @returns Component definition usable in app/component `components`.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* ```ts
|
|
458
|
+
* const UserCard = createComponent(
|
|
459
|
+
* `<article><h3 r-text="name"></h3></article>`,
|
|
460
|
+
* {
|
|
461
|
+
* props: ['name'],
|
|
462
|
+
* context: (head) => ({
|
|
463
|
+
* name: head.props.name ?? 'Anonymous',
|
|
464
|
+
* }),
|
|
465
|
+
* },
|
|
466
|
+
* )
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```ts
|
|
471
|
+
* // Props shorthand:
|
|
472
|
+
* const CounterLabel = createComponent(
|
|
473
|
+
* `<span r-text="value"></span>`,
|
|
474
|
+
* ['value'],
|
|
475
|
+
* )
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
228
478
|
export declare const createComponent: <TContext extends IRegorContext | object = IRegorContext>(template: Template | string, options?: CreateComponentOptions<TContext> | string[]) => Component<TContext>;
|
|
229
479
|
export declare const toFragment: (json: JSONTemplate | JSONTemplate[], isSVG?: boolean, config?: RegorConfig) => DocumentFragment;
|
|
230
480
|
export declare const toJsonTemplate: (node: Element | Element[]) => JSONTemplate | JSONTemplate[];
|