@esportsplus/reactivity 0.30.2 → 0.30.3

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.
@@ -1,87 +0,0 @@
1
- import { reactive } from '@esportsplus/reactivity';
2
-
3
-
4
- // Signal creation
5
- let count = reactive(0);
6
- let name = reactive('test');
7
- let flag = reactive(true);
8
- let nullable = reactive<string | null>(null);
9
-
10
- // Computed creation
11
- let doubled = reactive(() => count * 2);
12
- let greeting = reactive(() => `Hello ${name}!`);
13
- let complex = reactive(() => flag ? count : 0);
14
-
15
- // Read access
16
- console.log(count);
17
- console.log(name);
18
- console.log(doubled);
19
-
20
- // Write access - simple assignment
21
- count = 10;
22
- name = 'world';
23
- flag = false;
24
-
25
- // Compound assignment operators
26
- count += 5;
27
- count -= 2;
28
- count *= 3;
29
- count /= 2;
30
- count %= 7;
31
- count **= 2;
32
- count &= 0xFF;
33
- count |= 0x0F;
34
- count ^= 0xAA;
35
- count <<= 2;
36
- count >>= 1;
37
- count >>>= 1;
38
- count &&= 1;
39
- count ||= 0;
40
- count ??= 42;
41
-
42
- // Increment/decrement - statement context
43
- count++;
44
- count--;
45
- ++count;
46
- --count;
47
-
48
- // Increment/decrement - expression context (prefix)
49
- let a = ++count;
50
- let b = --count;
51
- console.log(a, b);
52
-
53
- // Increment/decrement - expression context (postfix)
54
- let c = count++;
55
- let d = count--;
56
- console.log(c, d);
57
-
58
- // Nested reads in computed
59
- let x = reactive(1);
60
- let y = reactive(2);
61
- let sum = reactive(() => x + y);
62
- let product = reactive(() => x * y);
63
- let nested = reactive(() => sum + product);
64
-
65
- // Conditional reads
66
- let conditional = reactive(() => {
67
- if (flag) {
68
- return x + y;
69
- }
70
- return 0;
71
- });
72
-
73
- // Function with reactive reads
74
- function calculate() {
75
- return count + x + y;
76
- }
77
-
78
- // Arrow function with reactive reads
79
- const calc = () => count * 2;
80
-
81
- // Reactive in loop
82
- for (let i = 0; i < 10; i++) {
83
- count += i;
84
- }
85
-
86
- // Reassignment with new reactive
87
- count = reactive(100);
package/test/range.ts DELETED
@@ -1,45 +0,0 @@
1
- import { reactive, root } from '@esportsplus/reactivity';
2
- // import { html, type Attributes } from '@esportsplus/template';
3
- // import form from '~/components/form';
4
- import './scss/index.scss';
5
-
6
-
7
- export default function(
8
- this: { attributes?: Record<PropertyKey, unknown> } | any,
9
- attributes: Record<PropertyKey, unknown> & { max: number, min: number, state?: { active: boolean, error: string, value: number } }
10
- ) {
11
- let { max, min } = attributes,
12
- state = attributes.state || reactive({
13
- active: false,
14
- error: '',
15
- value: 0
16
- });
17
-
18
- if (attributes?.value) {
19
- state.value = Number( attributes.value );
20
- }
21
-
22
- // @ts-ignore
23
- return html`
24
- <input
25
- class='range --border-state --border-black'
26
- style='${() => `--thumb-position: ${((state.value - min) / (max - min)) * 100}%`}'
27
- type='range'
28
- ${this?.attributes}
29
- ${attributes}
30
- ${{
31
- class: () => state.active && '--active',
32
- onfocusin: () => {
33
- state.active = true;
34
- },
35
- onfocusout: () => {
36
- state.active = false;
37
- },
38
- oninput: (e: any) => {
39
- state.value = Number((e.target as HTMLInputElement).value);
40
- },
41
- value: root(() => (attributes?.value as number) || state.value || 0)
42
- }}
43
- />
44
- `;
45
- };
@@ -1,41 +0,0 @@
1
- import { resolve } from 'path';
2
- import { defineConfig } from 'vite';
3
- import reactivity from '../build/compiler/plugins/vite.js';
4
-
5
-
6
- export default defineConfig({
7
- build: {
8
- lib: {
9
- entry: {
10
- arrays: resolve(__dirname, 'arrays.ts'),
11
- debug: resolve(__dirname, 'debug.ts'),
12
- effects: resolve(__dirname, 'effects.ts'),
13
- index: resolve(__dirname, 'index.ts'),
14
- nested: resolve(__dirname, 'nested.ts'),
15
- objects: resolve(__dirname, 'objects.ts'),
16
- primitives: resolve(__dirname, 'primitives.ts')
17
- },
18
- formats: ['es']
19
- },
20
- minify: false,
21
- outDir: resolve(__dirname, 'build'),
22
- rollupOptions: {
23
- external: ['@esportsplus/utilities'],
24
- output: {
25
- entryFileNames: '[name].js'
26
- }
27
- },
28
- target: 'esnext'
29
- },
30
- plugins: [
31
- reactivity()
32
- ],
33
- resolve: {
34
- alias: {
35
- '@esportsplus/reactivity/constants': resolve(__dirname, '../src/constants'),
36
- '@esportsplus/reactivity/reactive/array': resolve(__dirname, '../src/reactive/array'),
37
- '@esportsplus/reactivity': resolve(__dirname, '../src'),
38
- '~': resolve(__dirname, '../src')
39
- }
40
- }
41
- });