rumious 2.1.4 → 2.1.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/dist/component/component.d.ts +2 -0
- package/dist/index.js +107 -89
- package/dist/state/state.d.ts +1 -0
- package/package.json +2 -2
- package/dist/app/app.js +0 -20
- package/dist/app/index.js +0 -1
- package/dist/component/component.js +0 -38
- package/dist/component/element.js +0 -50
- package/dist/component/index.js +0 -2
- package/dist/global.js +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx/component.js +0 -6
- package/dist/jsx/dynamic.js +0 -65
- package/dist/jsx/element.js +0 -50
- package/dist/jsx/index.js +0 -4
- package/dist/jsx/template.js +0 -281
- package/dist/module/index.js +0 -2
- package/dist/ref/index.js +0 -1
- package/dist/ref/ref.js +0 -147
- package/dist/render/context.js +0 -9
- package/dist/render/index.js +0 -4
- package/dist/render/list.js +0 -96
- package/dist/render/render.js +0 -17
- package/dist/render/view.js +0 -76
- package/dist/state/index.js +0 -3
- package/dist/state/list.js +0 -79
- package/dist/state/reactor.js +0 -53
- package/dist/state/state.js +0 -53
- package/dist/state/store.js +0 -17
- package/dist/types/component.js +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/jsx.d.ts +0 -17
- package/dist/types/state.js +0 -1
- package/dist/types/template.js +0 -1
- package/dist/utils/checker.js +0 -3
package/dist/state/list.js
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
import { RumiousState } from './state.js';
|
2
|
-
export class RumiousListState extends RumiousState {
|
3
|
-
constructor(value = [], reactor) {
|
4
|
-
super(value, reactor);
|
5
|
-
}
|
6
|
-
append(value) {
|
7
|
-
this.value.push(value);
|
8
|
-
this.reactor?.notify({
|
9
|
-
type: 'append',
|
10
|
-
state: this,
|
11
|
-
key: this.value.length - 1,
|
12
|
-
value
|
13
|
-
});
|
14
|
-
}
|
15
|
-
prepend(value) {
|
16
|
-
this.value.unshift(value);
|
17
|
-
this.reactor?.notify({
|
18
|
-
type: 'prepend',
|
19
|
-
state: this,
|
20
|
-
key: 0,
|
21
|
-
value
|
22
|
-
});
|
23
|
-
}
|
24
|
-
insert(pos, value) {
|
25
|
-
this.value.splice(pos, 0, value);
|
26
|
-
this.reactor?.notify({
|
27
|
-
type: 'insert',
|
28
|
-
state: this,
|
29
|
-
value,
|
30
|
-
key: pos
|
31
|
-
});
|
32
|
-
}
|
33
|
-
updateAt(pos, value) {
|
34
|
-
this.value[pos] = value;
|
35
|
-
this.reactor?.notify({
|
36
|
-
type: 'update',
|
37
|
-
state: this,
|
38
|
-
value,
|
39
|
-
key: pos
|
40
|
-
});
|
41
|
-
}
|
42
|
-
remove(pos) {
|
43
|
-
let currentValue = this.value[pos];
|
44
|
-
this.value.splice(pos, 1);
|
45
|
-
this.reactor?.notify({
|
46
|
-
type: 'remove',
|
47
|
-
state: this,
|
48
|
-
value: currentValue,
|
49
|
-
key: pos
|
50
|
-
});
|
51
|
-
}
|
52
|
-
clear() {
|
53
|
-
this.value.length = 0;
|
54
|
-
this.reactor?.notify({
|
55
|
-
type: 'set',
|
56
|
-
state: this,
|
57
|
-
value: []
|
58
|
-
});
|
59
|
-
}
|
60
|
-
reverse() {
|
61
|
-
this.value.reverse();
|
62
|
-
this.reactor?.notify({
|
63
|
-
type: 'set',
|
64
|
-
state: this,
|
65
|
-
value: this.value
|
66
|
-
});
|
67
|
-
}
|
68
|
-
filter(predicate) {
|
69
|
-
this.value = this.value.filter(predicate);
|
70
|
-
this.reactor?.notify({
|
71
|
-
type: 'set',
|
72
|
-
state: this,
|
73
|
-
value: this.value
|
74
|
-
});
|
75
|
-
}
|
76
|
-
}
|
77
|
-
export function createListState(values) {
|
78
|
-
return new RumiousListState(values);
|
79
|
-
}
|
package/dist/state/reactor.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
export class RumiousReactor {
|
2
|
-
target;
|
3
|
-
bindings = [];
|
4
|
-
internal = [];
|
5
|
-
isUIBatch = true;
|
6
|
-
scheduled = false;
|
7
|
-
queuedCommits = [];
|
8
|
-
constructor(target) {
|
9
|
-
this.target = target;
|
10
|
-
}
|
11
|
-
addBinding(binding) {
|
12
|
-
this.bindings.push(binding);
|
13
|
-
}
|
14
|
-
removeBinding(binding) {
|
15
|
-
this.bindings = this.bindings.filter(b => b !== binding);
|
16
|
-
}
|
17
|
-
addInternalBinding(binding) {
|
18
|
-
this.internal.push(binding);
|
19
|
-
}
|
20
|
-
removeInternalBinding(binding) {
|
21
|
-
this.internal = this.internal.filter(b => b !== binding);
|
22
|
-
}
|
23
|
-
notify(commit) {
|
24
|
-
for (const binding of this.bindings) {
|
25
|
-
binding(commit);
|
26
|
-
}
|
27
|
-
if (this.isUIBatch) {
|
28
|
-
this.scheduleInternalUpdate(commit);
|
29
|
-
}
|
30
|
-
else {
|
31
|
-
for (const binding of this.internal) {
|
32
|
-
binding(commit);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
scheduleInternalUpdate(commit) {
|
37
|
-
this.queuedCommits.push(commit);
|
38
|
-
if (!this.scheduled) {
|
39
|
-
this.scheduled = true;
|
40
|
-
queueMicrotask(() => {
|
41
|
-
this.flushInternal();
|
42
|
-
});
|
43
|
-
}
|
44
|
-
}
|
45
|
-
flushInternal() {
|
46
|
-
const lastCommit = this.queuedCommits[this.queuedCommits.length - 1];
|
47
|
-
for (const binding of this.internal) {
|
48
|
-
binding(lastCommit); // chỉ gửi commit cuối cùng
|
49
|
-
}
|
50
|
-
this.queuedCommits = [];
|
51
|
-
this.scheduled = false;
|
52
|
-
}
|
53
|
-
}
|
package/dist/state/state.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
import { RumiousReactor } from './reactor.js';
|
2
|
-
export class RumiousState {
|
3
|
-
value;
|
4
|
-
reactor;
|
5
|
-
constructor(value, reactor) {
|
6
|
-
this.value = value;
|
7
|
-
this.reactor = reactor;
|
8
|
-
if (!this.reactor) {
|
9
|
-
this.reactor = new RumiousReactor(this);
|
10
|
-
}
|
11
|
-
}
|
12
|
-
set(value) {
|
13
|
-
this.value = value;
|
14
|
-
this.reactor?.notify({
|
15
|
-
type: 'set',
|
16
|
-
value: value,
|
17
|
-
state: this
|
18
|
-
});
|
19
|
-
}
|
20
|
-
get() {
|
21
|
-
return this.value;
|
22
|
-
}
|
23
|
-
slientUpdate(value) {
|
24
|
-
this.value = value;
|
25
|
-
}
|
26
|
-
update(updater) {
|
27
|
-
this.set(updater(this.value));
|
28
|
-
}
|
29
|
-
toJSON() {
|
30
|
-
return JSON.stringify(this.value);
|
31
|
-
}
|
32
|
-
equal(value) {
|
33
|
-
return value === this.value;
|
34
|
-
}
|
35
|
-
trigger() {
|
36
|
-
this.reactor?.notify({
|
37
|
-
type: 'set',
|
38
|
-
value: this.value,
|
39
|
-
state: this
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
export function createState(value) {
|
44
|
-
return new RumiousState(value);
|
45
|
-
}
|
46
|
-
export function watch(state, callback) {
|
47
|
-
if (state.reactor)
|
48
|
-
state.reactor.addBinding(callback);
|
49
|
-
}
|
50
|
-
export function unwatch(state, callback) {
|
51
|
-
if (state.reactor)
|
52
|
-
state.reactor.removeBinding(callback);
|
53
|
-
}
|
package/dist/state/store.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import { RumiousState, createState } from './state.js';
|
2
|
-
T;
|
3
|
-
RumiousState;
|
4
|
-
;
|
5
|
-
export class RumiousStore {
|
6
|
-
value;
|
7
|
-
map = {};
|
8
|
-
constructor(value) {
|
9
|
-
this.value = value;
|
10
|
-
for (const key in value) {
|
11
|
-
this.map[key] = createState(value[key]);
|
12
|
-
}
|
13
|
-
}
|
14
|
-
}
|
15
|
-
export function createStore(value) {
|
16
|
-
return new RumiousStore(value);
|
17
|
-
}
|
package/dist/types/component.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/types/index.js
DELETED
package/dist/types/jsx.d.ts
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import type { RumiousRenderContext } from '../render/index.js';
|
2
|
-
export interface RumiousTemplate {
|
3
|
-
(root: HTMLElement | DocumentFragment, context: RumiousRenderContext): HTMLElement;
|
4
|
-
__isTemplate: true;
|
5
|
-
}
|
6
|
-
|
7
|
-
declare global {
|
8
|
-
namespace JSX {
|
9
|
-
type Element = RumiousTemplate;
|
10
|
-
interface IntrinsicElements {
|
11
|
-
[tagName: string]: any;
|
12
|
-
}
|
13
|
-
interface ElementChildrenAttribute {
|
14
|
-
children: {};
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
package/dist/types/state.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/types/template.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/utils/checker.js
DELETED