regor 1.3.5 → 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 +30 -12
- package/dist/regor.es2015.cjs.js +738 -387
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +738 -387
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +738 -387
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +738 -387
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +738 -387
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +738 -387
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +729 -375
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +729 -375
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +729 -375
- 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
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Typical usage:
|
|
13
13
|
* ```ts
|
|
14
|
-
* const Card = createComponent(
|
|
15
|
-
*
|
|
14
|
+
* const Card = createComponent(
|
|
15
|
+
* `<article><h3 r-text="title"></h3></article>`,
|
|
16
|
+
* {
|
|
16
17
|
* props: ['title'],
|
|
17
18
|
* context(head) {
|
|
18
19
|
* // read parent values
|
|
@@ -188,17 +189,34 @@ export declare interface IRegorContext extends Record<string, unknown> {
|
|
|
188
189
|
}
|
|
189
190
|
export type IsLazy = (i: number, d: number) => boolean;
|
|
190
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
|
+
}
|
|
191
207
|
export interface Directive {
|
|
192
208
|
isLazy?: IsLazy;
|
|
193
209
|
isLazyKey?: IsLazyKey;
|
|
194
210
|
collectRefObj?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* The refs in parseResult are still reactive. */
|
|
211
|
+
/** If once is enabled, updates are not re-triggered after initial mount. */
|
|
197
212
|
once?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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;
|
|
202
220
|
}
|
|
203
221
|
export interface BindData {
|
|
204
222
|
unbinders: Unbinder[];
|
|
@@ -206,9 +224,9 @@ export interface BindData {
|
|
|
206
224
|
}
|
|
207
225
|
export type Unbinder = () => void;
|
|
208
226
|
export interface ParseResult {
|
|
209
|
-
value:
|
|
227
|
+
value: () => unknown[];
|
|
210
228
|
stop: StopObserving;
|
|
211
|
-
subscribe
|
|
229
|
+
subscribe: (observer: ObserveCallback<unknown[]>, init?: boolean) => StopObserving;
|
|
212
230
|
refs: Array<AnyRef | undefined>;
|
|
213
231
|
context: Record<string, unknown>;
|
|
214
232
|
}
|
|
@@ -427,10 +445,10 @@ export declare const createApp: <TRegorContext extends IRegorContext | object =
|
|
|
427
445
|
* component instance in the app.
|
|
428
446
|
*
|
|
429
447
|
* @typeParam TContext - Component context type.
|
|
430
|
-
* @param template Component template source:
|
|
448
|
+
* @param template - Component template source:
|
|
431
449
|
* - inline HTML string
|
|
432
450
|
* - `Template` object (`template`, `element`, `selector`, or `json`)
|
|
433
|
-
* @param options Component options (`context`, `props`, `inheritAttrs`, etc.).
|
|
451
|
+
* @param options - Component options (`context`, `props`, `inheritAttrs`, etc.).
|
|
434
452
|
* You can also pass `string[]` as shorthand for `props`.
|
|
435
453
|
*
|
|
436
454
|
* @returns Component definition usable in app/component `components`.
|