regor 1.0.8 → 1.1.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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Ahmed Yasin Koculu
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ahmed Yasin Koculu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,239 +1,244 @@
1
- ![img](https://raw.githubusercontent.com/koculu/regor/main/docs/images/logo1.png)
2
-
3
- # Regor
4
-
5
- Regor is a powerful UI framework designed to streamline the development of HTML5-based applications for both web and desktop environments. With a template syntax that closely follows Vue.js, transitioning from VueJS to Regor is seamless for developers familiar with Vue.
6
-
7
- ### [![Published on npm](https://img.shields.io/npm/v/regor.svg)](https://www.npmjs.com/package/regor)
8
-
9
- [**`Try Regor Online`**](https://stackblitz.com/edit/regor-sample-1?file=index.ts)
10
-
11
- ## Key Features
12
-
13
- - **Simplicity:** Develop UIs without a Virtual DOM for a more straightforward implementation and easier debugging.
14
- - **TypeScript:** Enjoy native TypeScript support without workarounds.
15
- - **No Build Step Required:** Define components in TypeScript using tagged string templates, no build step needed.
16
- - **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
-
18
- ```html
19
- <meta
20
- http-equiv="Content-Security-Policy"
21
- content="require-trusted-types-for 'script';"
22
- />
23
- ```
24
-
25
- - **Flexible Reactivity:** Empowering developers with a highly flexible reactivity system.
26
- - **Non-JS SSR:** Bind to the existing DOM without removing already mounted HTML elements, suitable for non-JavaScript server-side rendering.
27
- - **Reentrance:** Regor supports multiple mountings in the previously mounted area using the same or different app contexts. This enables creating and mounting new directives dynamically.
28
- - **Compatibility:** Rendered pages are designed for seamless integration with other libraries manipulating the DOM.
29
-
30
- ## Documentation
31
-
32
- Discover the capabilities of Regor by diving into our comprehensive documentation. Whether you're new to Regor or an experienced user, our documentation provides in-depth insights into its features, API, directives, and more.
33
-
34
- Start exploring the [Regor Documentation](docs/index.md) now to harness the full potential of this powerful UI framework.
35
-
36
- ## Getting started
37
-
38
- Click and count sample source:
39
-
40
- ```ts
41
- import { createApp, ref } from 'regor'
42
-
43
- createApp({
44
- count: ref(0),
45
- })
46
- ```
47
-
48
- HTML:
49
-
50
- ```html
51
- <div id="app">
52
- <button @click="count++">Count is: {{ count }}</button>
53
- </div>
54
- ```
55
-
56
- Defining component:
57
-
58
- ```ts
59
- import { createApp, createComponent, ref, html, type Ref } from 'regor'
60
-
61
- interface MyComponent {
62
- message: Ref<string>
63
- }
64
-
65
- const template = html`<button @click="count++">
66
- {{ message }} {{ count }}
67
- </button>`
68
-
69
- const props = ['message']
70
-
71
- const myComponent = createComponent<MyComponent>(
72
- (head) => ({
73
- message: head.props.message,
74
- count: ref(0),
75
- }),
76
- template,
77
- props,
78
- )
79
-
80
- createApp({
81
- components: { myComponent },
82
- message: ref('Count is:'),
83
- })
84
- ```
85
-
86
- HTML:
87
-
88
- ```html
89
- <div id="app">
90
- <MyComponent :message="message"></MyComponent>
91
- </div>
92
- ```
93
-
94
- Define composables:
95
-
96
- ```ts
97
- import { ref, onMounted, onUnmounted, type Ref } from 'regor'
98
-
99
- export const useMouse = (): { x: Ref<number>; y: Ref<number> } => {
100
- const x = ref(0)
101
- const y = ref(0)
102
-
103
- const update = (event: MouseEvent): void => {
104
- x(event.pageX)
105
- y(event.pageY)
106
- }
107
-
108
- onMounted(() => window.addEventListener('mousemove', update))
109
- onUnmounted(() => window.removeEventListener('mousemove', update))
110
-
111
- return { x, y }
112
- }
113
- ```
114
-
115
- ## Installation
116
-
117
- `yarn add regor`
118
-
119
- or
120
-
121
- `npm install regor`
122
-
123
- ## Comparison with VueJs
124
-
125
- Regor shares core functionality with VueJs but differs in implementation, TypeScript support, template evaluation, reactivity, server-side rendering support, compatibility.
126
-
127
- ## Supported Directives
128
-
129
- Regor provides a set of directives that allow you to enhance the behavior and appearance of your applications. Similar to Vue's directives, Regor's directives start with the "r-" prefix.
130
-
131
- > **Note:** The directive prefix "r-" can be customized using `RegorConfig.getDefault().setDirectives('v-')` to align with a different naming convention, such as Vue's "v-" prefix.
132
-
133
- - **`r-bind`** Binds an element's attribute to a component's data, allowing dynamic updates.
134
- - **`r-model`** Enables two-way data binding between form inputs.
135
- - **`r-text`** Sets the element's text content to the result of an expression.
136
- - **`r-html`** Renders the result of an expression as HTML content within the element.
137
- - **`r-on`** Attaches event listeners to the element and invokes specified component methods.
138
- - **`r-show`** Conditionally displays the element based on the truthiness of an expression.
139
- - **`r-for`** Renders a set of elements based on an array and a template.
140
- - **`r-if`** Conditionally renders the element based on the truthiness of an expression.
141
- - **`r-else`** Provides an alternative rendering when used in conjunction with r-if.
142
- - **`r-else-if`** Conditionally renders the element as an alternative to r-if.
143
- - **`r-pre`** Excludes HTML element from Regor bindings.
144
- - **`:class`** Binds one or more class names to an element based on expressions.
145
- - **`:style`** Binds one or more inline styles to an element based on expressions.
146
- - **`:ref`** Provides a reference to an element in the template, allowing you to interact with it programmatically.
147
- - **`:key`** Provides a unique identifier for each item in a list, aiding efficient updates and rendering.
148
- - **`:is`** Specifies the component to dynamically render based on a value or expression.
149
- - **`r-teleport`** Teleports the element to anywhere in the DOM. Unlike Vue, teleport is a directive to avoid component overhead.
150
- - **`:props`** Vue uses v-bind for component property passing. However, this can conflict with v-bind's attribute fall-through logic. Hence, Regor defines a dedicated directive to pass properties using object syntax. It enables passing properties without defining them in the component's props contract.
151
- - **`:props-once`** Similar to :props but it doesn't observe entire reactive tree of the template expression. Tail reactivity still works.
152
- - **`@`** Shorthand for `r-on` to bind event listeners.
153
- - **`:`** Shorthand for `r-bind` to bind element attributes.
154
- - **`.`** Shorthand for `r-bind.prop` to set properties.
155
-
156
- These directives empower you to create dynamic and interactive user interfaces, enhancing the user experience of your Regor-powered applications.
157
-
158
- ## Regor API
159
-
160
- **App / Component Template Functions**
161
-
162
- - **`createApp`** Similar to Vue's `createApp`, it initializes a Regor application instance.
163
- - **`createComponent`** Creates a Regor component instance.
164
- - **`toFragment`** Converts a JSON template to a document fragment.
165
- - **`toJsonTemplate`** Converts a DOM element to a JSON template.
166
-
167
- **Cleanup Functions**
168
-
169
- - **`addUnbinder`** Adds an unbinder to a DOM element.
170
- - **`getBindData`** Retrieves bind data associated with a DOM element.
171
- - **`removeNode`** Removes a node while properly disposing of associated bind data and observers.
172
- - **`unbind`** Unbinds a node, disposing of observers and bind data.
173
-
174
- **Compute Functions**
175
-
176
- - **`computed`** Similar to Vue's `computed`, it creates a computed property.
177
- - **`computed`** Computes the value observing a single ref, more efficient than observing any.
178
- - **`computeMany`** Computes the value observing given refs, more efficient than observing any.
179
- - **`watchEffect`** Similar to Vue's `watchEffect`, it watches for reactive changes.
180
- - **`collectRefs`** Like `watchEffect`, but runs once and returns all refs used in the evaluated action.
181
- - **`silence`** Silences the ref collection in a `watchEffect` or `collectRefs`.
182
-
183
- **Misc Functions**
184
-
185
- - **`flatten`** Flattens a given ref object into a raw object recursively.
186
- - **`isRaw`** Checks if a given ref is marked as raw.
187
- - **`markRaw`** Marks a ref as raw.
188
- - **`persist`** Persists a given ref in local storage reactively.
189
- - **`html`** A tag to produce HTML string using template literals. Recommended to use with the VS-Code [`lit-html`](https://marketplace.visualstudio.com/items?itemName=bierner.lit-html) extension for formatting and highlighting.
190
- - **`raw`** A tag to produce HTML string, similar to `html`, but it is excluded from formatting when [`lit-html`](https://marketplace.visualstudio.com/items?itemName=bierner.lit-html) extension is installed.
191
-
192
- **Observe Functions**
193
-
194
- - **`observe`** Observes changes in a single ref.
195
- - **`observeMany`** Observes changes in multiple refs.
196
- - **`observerCount`** Retrieves the active observer count of a ref.
197
- - **`batch`** Performs batch updates, triggering changes at the end. Use with caution due to possible dirty reads.
198
- - **`startBatch`** Starts a batch update.
199
- - **`endBatch`** Ends a started batch update and triggers affected refs.
200
-
201
- **Reactivity Functions**
202
-
203
- - **`ref`** Creates a deep ref object recursively, modifying the source object in place.
204
- - **`sref`** Creates a simple ref object from a given value, without nested ref creation.
205
- - **`isDeepRef`** Returns true if a given ref is created with `ref()` function.
206
- - **`isRef`** Returns true for any ref, false for non-refs.
207
- - **`pause`** Pauses a ref's auto-trigger on value change.
208
- - **`resume`** Resumes a ref's auto-trigger on value change.
209
- - **`trigger`** Manually triggers a ref to inform its observers.
210
- - **`unref`** Unwraps a ref, returning the raw value.
211
- - **`entangle`** Entangles two refs to sync their value changes.
212
-
213
- **Composition Functions**
214
-
215
- - **`useScope`** In a scope, you can use `onMounted` and `onUnmounted` functions. Components are always created in scope. Use the useScope for apps created by createApp. Similar to Vue's `effectScope`, useScope provides efficient cleanup of watchEffects, computed refs, observers and enables the `onMounted` and `onUnmounted` calls in the scope.
216
- - **`onMounted`** Similar to Vue's `onMounted`, it executes when the component is mounted.
217
- - **`onUnmounted`** Similar to Vue's `onUnmounted`, it executes when the component is unmounted.
218
-
219
- **Log Configuration**
220
-
221
- - **`warningHandler`** Customize or turn off console warnings.
222
-
223
- ## Contributing
224
-
225
- This project welcomes contributions and suggestions. Please follow [CONTRIBUTING.md](.github/CONTRIBUTING.md) instructions.
226
-
227
- ## Acknowledgments
228
-
229
- Regor is built upon the shoulders of giants, drawing inspiration from Vue and its vibrant community of contributors. The well-defined concepts and principles from Vue have played a pivotal role in shaping Regor's foundation. We extend our heartfelt gratitude to the Vue project and its dedicated contributors for their pioneering work in the realm of UI frameworks.
230
-
231
- Special thanks to the Vue team and its community for creating a thriving ecosystem that continues to inspire innovation in the field of web development.
232
-
233
- Regor also utilizes [**Jsep**](https://github.com/EricSmekens/jsep), a fast and lightweight JavaScript expression parser. Jsep's contribution to Regor's functionality is greatly appreciated.
234
-
235
- Additionally, we would like to acknowledge the [**happy-dom**](https://github.com/capricorn86/happy-dom) library, which played a significant role in our testing process.
236
-
237
- We also extend a warm welcome to any future contributors who join the Regor project. Your contributions will play a vital role in shaping the framework's growth and evolution.
238
-
239
- Thank you to everyone who has contributed, inspired, and supported Regor's development journey. Your dedication and passion are invaluable.
1
+ ![img](https://raw.githubusercontent.com/koculu/regor/main/docs/images/logo1.png)
2
+
3
+ # Regor
4
+
5
+ Regor is a powerful UI framework designed to streamline the development of HTML5-based applications for both web and desktop environments. With a template syntax that closely follows Vue.js, transitioning from VueJS to Regor is seamless for developers familiar with Vue.
6
+
7
+ ### [![Published on npm](https://img.shields.io/npm/v/regor.svg)](https://www.npmjs.com/package/regor)
8
+
9
+ [**`Try Regor Online`**](https://stackblitz.com/edit/regor-sample-1?file=index.ts)
10
+
11
+ ## Key Features
12
+
13
+ - **Simplicity:** Develop UIs without a Virtual DOM for a more straightforward implementation and easier debugging.
14
+ - **TypeScript:** Enjoy native TypeScript support without workarounds.
15
+ - **No Build Step Required:** Define components in TypeScript using tagged string templates, no build step needed.
16
+ - **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
+
18
+ ```html
19
+ <meta
20
+ http-equiv="Content-Security-Policy"
21
+ content="require-trusted-types-for 'script';"
22
+ />
23
+ ```
24
+
25
+ - **Flexible Reactivity:** Empowering developers with a highly flexible reactivity system.
26
+ - **Non-JS SSR:** Bind to the existing DOM without removing already mounted HTML elements, suitable for non-JavaScript server-side rendering.
27
+ - **Reentrance:** Regor supports multiple mountings in the previously mounted area using the same or different app contexts. This enables creating and mounting new directives dynamically.
28
+ - **Compatibility:** Rendered pages are designed for seamless integration with other libraries manipulating the DOM.
29
+
30
+ ## Documentation
31
+
32
+ Discover the capabilities of Regor by diving into our comprehensive documentation. Whether you're new to Regor or an experienced user, our documentation provides in-depth insights into its features, API, directives, and more.
33
+
34
+
35
+ Start exploring the [Regor Documentation](https://tenray.io/projects/regor) now to harness the full potential of this powerful UI framework. The documentation sources are located in [docs-site](docs-site/).
36
+
37
+ ## Requirements
38
+
39
+ Regor is developed using Node.js 18 and Yarn. Ensure you have Node.js 18 or newer installed before running the examples or the documentation site.
40
+
41
+ ## Getting started
42
+
43
+ Click and count sample source:
44
+
45
+ ```ts
46
+ import { createApp, ref } from 'regor'
47
+
48
+ createApp({
49
+ count: ref(0),
50
+ })
51
+ ```
52
+
53
+ HTML:
54
+
55
+ ```html
56
+ <div id="app">
57
+ <button @click="count++">Count is: {{ count }}</button>
58
+ </div>
59
+ ```
60
+
61
+ Defining component:
62
+
63
+ ```ts
64
+ import { createApp, createComponent, ref, html, type Ref } from 'regor'
65
+
66
+ interface MyComponent {
67
+ message: Ref<string>
68
+ }
69
+
70
+ const template = html`<button @click="count++">
71
+ {{ message }} {{ count }}
72
+ </button>`
73
+
74
+ const props = ['message']
75
+
76
+ const myComponent = createComponent<MyComponent>(
77
+ (head) => ({
78
+ message: head.props.message,
79
+ count: ref(0),
80
+ }),
81
+ template,
82
+ props,
83
+ )
84
+
85
+ createApp({
86
+ components: { myComponent },
87
+ message: ref('Count is:'),
88
+ })
89
+ ```
90
+
91
+ HTML:
92
+
93
+ ```html
94
+ <div id="app">
95
+ <MyComponent :message="message"></MyComponent>
96
+ </div>
97
+ ```
98
+
99
+ Define composables:
100
+
101
+ ```ts
102
+ import { ref, onMounted, onUnmounted, type Ref } from 'regor'
103
+
104
+ export const useMouse = (): { x: Ref<number>; y: Ref<number> } => {
105
+ const x = ref(0)
106
+ const y = ref(0)
107
+
108
+ const update = (event: MouseEvent): void => {
109
+ x(event.pageX)
110
+ y(event.pageY)
111
+ }
112
+
113
+ onMounted(() => window.addEventListener('mousemove', update))
114
+ onUnmounted(() => window.removeEventListener('mousemove', update))
115
+
116
+ return { x, y }
117
+ }
118
+ ```
119
+
120
+ ## Installation
121
+
122
+ `yarn add regor`
123
+
124
+ or
125
+
126
+ `npm install regor`
127
+
128
+ ## Comparison with VueJs
129
+
130
+ Regor shares core functionality with VueJs but differs in implementation, TypeScript support, template evaluation, reactivity, server-side rendering support, compatibility.
131
+
132
+ ## Supported Directives
133
+
134
+ Regor provides a set of directives that allow you to enhance the behavior and appearance of your applications. Similar to Vue's directives, Regor's directives start with the "r-" prefix.
135
+
136
+ > **Note:** The directive prefix "r-" can be customized using `RegorConfig.getDefault().setDirectives('v-')` to align with a different naming convention, such as Vue's "v-" prefix.
137
+
138
+ - **`r-bind`** Binds an element's attribute to a component's data, allowing dynamic updates.
139
+ - **`r-model`** Enables two-way data binding between form inputs.
140
+ - **`r-text`** Sets the element's text content to the result of an expression.
141
+ - **`r-html`** Renders the result of an expression as HTML content within the element.
142
+ - **`r-on`** Attaches event listeners to the element and invokes specified component methods.
143
+ - **`r-show`** Conditionally displays the element based on the truthiness of an expression.
144
+ - **`r-for`** Renders a set of elements based on an array and a template.
145
+ - **`r-if`** Conditionally renders the element based on the truthiness of an expression.
146
+ - **`r-else`** Provides an alternative rendering when used in conjunction with r-if.
147
+ - **`r-else-if`** Conditionally renders the element as an alternative to r-if.
148
+ - **`r-pre`** Excludes HTML element from Regor bindings.
149
+ - **`:class`** Binds one or more class names to an element based on expressions.
150
+ - **`:style`** Binds one or more inline styles to an element based on expressions.
151
+ - **`:ref`** Provides a reference to an element in the template, allowing you to interact with it programmatically.
152
+ - **`:key`** Provides a unique identifier for each item in a list, aiding efficient updates and rendering.
153
+ - **`:is`** Specifies the component to dynamically render based on a value or expression.
154
+ - **`r-teleport`** Teleports the element to anywhere in the DOM. Unlike Vue, teleport is a directive to avoid component overhead.
155
+ - **`:props`** Vue uses v-bind for component property passing. However, this can conflict with v-bind's attribute fall-through logic. Hence, Regor defines a dedicated directive to pass properties using object syntax. It enables passing properties without defining them in the component's props contract.
156
+ - **`:props-once`** Similar to :props but it doesn't observe entire reactive tree of the template expression. Tail reactivity still works.
157
+ - **`@`** Shorthand for `r-on` to bind event listeners.
158
+ - **`:`** Shorthand for `r-bind` to bind element attributes.
159
+ - **`.`** Shorthand for `r-bind.prop` to set properties.
160
+
161
+ These directives empower you to create dynamic and interactive user interfaces, enhancing the user experience of your Regor-powered applications.
162
+
163
+ ## Regor API
164
+
165
+ **App / Component Template Functions**
166
+
167
+ - **`createApp`** Similar to Vue's `createApp`, it initializes a Regor application instance.
168
+ - **`createComponent`** Creates a Regor component instance.
169
+ - **`toFragment`** Converts a JSON template to a document fragment.
170
+ - **`toJsonTemplate`** Converts a DOM element to a JSON template.
171
+
172
+ **Cleanup Functions**
173
+
174
+ - **`addUnbinder`** Adds an unbinder to a DOM element.
175
+ - **`getBindData`** Retrieves bind data associated with a DOM element.
176
+ - **`removeNode`** Removes a node while properly disposing of associated bind data and observers.
177
+ - **`unbind`** Unbinds a node, disposing of observers and bind data.
178
+
179
+ **Compute Functions**
180
+
181
+ - **`computed`** Similar to Vue's `computed`, it creates a computed property.
182
+ - **`computed`** Computes the value observing a single ref, more efficient than observing any.
183
+ - **`computeMany`** Computes the value observing given refs, more efficient than observing any.
184
+ - **`watchEffect`** Similar to Vue's `watchEffect`, it watches for reactive changes.
185
+ - **`collectRefs`** Like `watchEffect`, but runs once and returns all refs used in the evaluated action.
186
+ - **`silence`** Silences the ref collection in a `watchEffect` or `collectRefs`.
187
+
188
+ **Misc Functions**
189
+
190
+ - **`flatten`** Flattens a given ref object into a raw object recursively.
191
+ - **`isRaw`** Checks if a given ref is marked as raw.
192
+ - **`markRaw`** Marks a ref as raw.
193
+ - **`persist`** Persists a given ref in local storage reactively.
194
+ - **`html`** A tag to produce HTML string using template literals. Recommended to use with the VS-Code [`lit-html`](https://marketplace.visualstudio.com/items?itemName=bierner.lit-html) extension for formatting and highlighting.
195
+ - **`raw`** A tag to produce HTML string, similar to `html`, but it is excluded from formatting when [`lit-html`](https://marketplace.visualstudio.com/items?itemName=bierner.lit-html) extension is installed.
196
+
197
+ **Observe Functions**
198
+
199
+ - **`observe`** Observes changes in a single ref.
200
+ - **`observeMany`** Observes changes in multiple refs.
201
+ - **`observerCount`** Retrieves the active observer count of a ref.
202
+ - **`batch`** Performs batch updates, triggering changes at the end. Use with caution due to possible dirty reads.
203
+ - **`startBatch`** Starts a batch update.
204
+ - **`endBatch`** Ends a started batch update and triggers affected refs.
205
+
206
+ **Reactivity Functions**
207
+
208
+ - **`ref`** Creates a deep ref object recursively, modifying the source object in place.
209
+ - **`sref`** Creates a simple ref object from a given value, without nested ref creation.
210
+ - **`isDeepRef`** Returns true if a given ref is created with `ref()` function.
211
+ - **`isRef`** Returns true for any ref, false for non-refs.
212
+ - **`pause`** Pauses a ref's auto-trigger on value change.
213
+ - **`resume`** Resumes a ref's auto-trigger on value change.
214
+ - **`trigger`** Manually triggers a ref to inform its observers.
215
+ - **`unref`** Unwraps a ref, returning the raw value.
216
+ - **`entangle`** Entangles two refs to sync their value changes.
217
+
218
+ **Composition Functions**
219
+
220
+ - **`useScope`** In a scope, you can use `onMounted` and `onUnmounted` functions. Components are always created in scope. Use the useScope for apps created by createApp. Similar to Vue's `effectScope`, useScope provides efficient cleanup of watchEffects, computed refs, observers and enables the `onMounted` and `onUnmounted` calls in the scope.
221
+ - **`onMounted`** Similar to Vue's `onMounted`, it executes when the component is mounted.
222
+ - **`onUnmounted`** Similar to Vue's `onUnmounted`, it executes when the component is unmounted.
223
+
224
+ **Log Configuration**
225
+
226
+ - **`warningHandler`** Customize or turn off console warnings.
227
+
228
+ ## Contributing
229
+
230
+ This project welcomes contributions and suggestions. Please follow [CONTRIBUTING.md](.github/CONTRIBUTING.md) instructions.
231
+
232
+ ## Acknowledgments
233
+
234
+ Regor is built upon the shoulders of giants, drawing inspiration from Vue and its vibrant community of contributors. The well-defined concepts and principles from Vue have played a pivotal role in shaping Regor's foundation. We extend our heartfelt gratitude to the Vue project and its dedicated contributors for their pioneering work in the realm of UI frameworks.
235
+
236
+ Special thanks to the Vue team and its community for creating a thriving ecosystem that continues to inspire innovation in the field of web development.
237
+
238
+ Regor also utilizes [**Jsep**](https://github.com/EricSmekens/jsep), a fast and lightweight JavaScript expression parser. Jsep's contribution to Regor's functionality is greatly appreciated.
239
+
240
+ Additionally, we would like to acknowledge the [**happy-dom**](https://github.com/capricorn86/happy-dom) library, which played a significant role in our testing process.
241
+
242
+ We also extend a warm welcome to any future contributors who join the Regor project. Your contributions will play a vital role in shaping the framework's growth and evolution.
243
+
244
+ Thank you to everyone who has contributed, inspired, and supported Regor's development journey. Your dedication and passion are invaluable.
package/dist/regor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by dts-bundle-generator v8.0.1
1
+ // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  export declare class ComponentHead<TProps = Record<any, any>> {
4
4
  props: TProps;
@@ -44,13 +44,13 @@ export type RawTypes = string | Function | number | boolean | symbol | undefined
44
44
  declare const RefSymbol: unique symbol;
45
45
  declare const RawSymbol: unique symbol;
46
46
  declare const ScopeSymbol: unique symbol;
47
- export type AnyRef = (newValue?: unknown, eventSource?: unknown) => any & {
47
+ export type AnyRef = (newValue?: any, eventSource?: any) => any & {
48
48
  [RefSymbol]: true;
49
49
  };
50
- export type Ref<TValueType> = ((newValue?: RefContent<TValueType> | Ref<RefParam<TValueType>> | SRef<RefContent<TValueType>>, eventSource?: any) => RefContent<TValueType>) & AnyRef & {
50
+ export type Ref<TValueType> = ((newValue?: RefContent<TValueType> | Ref<RefParam<TValueType>> | SRef<RefContent<TValueType>>, eventSource?: any) => RefContent<TValueType>) & {
51
51
  value: RefContent<TValueType>;
52
52
  };
53
- export type SRef<TValueType> = ((newValue?: TValueType | SRef<TValueType>, eventSource?: any) => SRefContent<TValueType>) & AnyRef & {
53
+ export type SRef<TValueType> = ((newValue?: TValueType | SRef<TValueType>, eventSource?: any) => SRefContent<TValueType>) & {
54
54
  value: SRefContent<TValueType>;
55
55
  };
56
56
  export type ComputedRef<TValueType> = SRef<TValueType> & {
@@ -118,7 +118,16 @@ export interface JSONTemplate {
118
118
  /** node type if node is COMMENT_NODE */
119
119
  n?: number;
120
120
  }
121
- interface TemplateOptions {
121
+ /**
122
+ * Represents a template configuration for rendering a component or an app.
123
+ * If used with 'createApp':
124
+ * - Define either 'selector' or 'element' to specify the mounting point.
125
+ * - Optionally, 'html' or 'json' can be defined to override the inner HTML of the mounting point.
126
+ * - If neither 'html' nor 'json' template is defined, the mounting point's inner HTML remains unchanged.
127
+ * If used with 'createComponent':
128
+ * - Define only one option: 'selector', 'element', 'html', or 'json'. The single option defines the component's HTML template.
129
+ */
130
+ export interface Template {
122
131
  /**
123
132
  * If used with 'createApp', specifies the target root element for mounting the application.
124
133
  * If used with 'createComponent', identifies the component template using a selector.
@@ -171,7 +180,7 @@ export interface Component<TProps = Record<any, any>> {
171
180
  */
172
181
  template: Node;
173
182
  /**
174
- * Indicates whether the component'^s content should inherit attributes from its parent.
183
+ * Indicates whether the component's content should inherit attributes from its parent.
175
184
  */
176
185
  inheritAttrs?: boolean;
177
186
  /**
@@ -208,8 +217,8 @@ export interface Scope<TRegorContext> {
208
217
  unmount: () => void;
209
218
  [ScopeSymbol]: true;
210
219
  }
211
- export declare const createApp: <TRegorContext extends IRegorContext>(context: TRegorContext | Scope<TRegorContext>, templateOptions?: TemplateOptions | string, config?: RegorConfig) => App<TRegorContext>;
212
- export declare const createComponent: <TProps = Record<any, any>>(context: (head: ComponentHead<TProps>) => IRegorContext, templateOptions: TemplateOptions | string, options?: CreateComponentOptions | string[]) => Component<TProps>;
220
+ export declare const createApp: <TRegorContext extends IRegorContext>(context: TRegorContext | Scope<TRegorContext>, template?: Template | string, config?: RegorConfig) => App<TRegorContext>;
221
+ export declare const createComponent: <TProps = Record<any, any>>(context: (head: ComponentHead<TProps>) => IRegorContext, template: Template | string, options?: CreateComponentOptions | string[]) => Component<TProps>;
213
222
  export declare const toFragment: (json: JSONTemplate | JSONTemplate[], isSVG?: boolean, config?: RegorConfig) => DocumentFragment;
214
223
  export declare const toJsonTemplate: (node: Element | Element[]) => JSONTemplate | JSONTemplate[];
215
224
  export declare const addUnbinder: (node: Node, unbinder: Unbinder) => void;
@@ -295,8 +304,4 @@ export declare const warningHandler: {
295
304
  };
296
305
  };
297
306
 
298
- export {
299
- TemplateOptions as Template,
300
- };
301
-
302
307
  export {};