clapton 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/helpers/clapton/clapton_helper.rb +16 -1
- data/lib/clapton/engine.rb +14 -10
- data/lib/clapton/javascripts/dist/client.js +31 -19
- data/lib/clapton/javascripts/dist/components-for-test.js +439 -0
- data/lib/clapton/javascripts/dist/components.js +356 -382
- data/lib/clapton/javascripts/node_modules/diff-dom/LICENSE.txt +165 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/README.md +224 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/browser/diffDOM.js +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/browser/diffDOM.js.map +1 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/TraceLogger.d.ts +28 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/apply.d.ts +4 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/fromVirtual.d.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/index.d.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/undo.d.ts +3 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/helpers.d.ts +11 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/index.d.ts +10 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/types.d.ts +104 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/apply.d.ts +3 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/diff.d.ts +22 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/fromDOM.d.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/fromString.d.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/helpers.d.ts +40 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/index.d.ts +3 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/index.d.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.d.ts +136 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.js +1996 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.js.map +1 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.min.js +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.min.js.map +1 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/module.js +1991 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/dist/module.js.map +1 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/index.html +62 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/package.json +54 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/rollup.config.mjs +67 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/TraceLogger.ts +143 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/apply.ts +227 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/fromVirtual.ts +83 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/index.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/undo.ts +90 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/helpers.ts +40 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/index.ts +121 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/types.ts +154 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/apply.ts +349 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/diff.ts +855 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/fromDOM.ts +74 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/fromString.ts +239 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/helpers.ts +461 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/index.ts +3 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/src/index.ts +2 -0
- data/lib/clapton/javascripts/node_modules/diff-dom/tsconfig.json +103 -0
- data/lib/clapton/javascripts/rollup.config.mjs +17 -2
- data/lib/clapton/javascripts/src/actions/initialize-actions.ts +6 -3
- data/lib/clapton/javascripts/src/channel/clapton-channel.js +6 -3
- data/lib/clapton/javascripts/src/client.ts +15 -15
- data/lib/clapton/javascripts/src/components-for-test.ts +29 -0
- data/lib/clapton/javascripts/src/components.ts +4 -1
- data/lib/clapton/javascripts/src/dom/update-component.ts +3 -2
- data/lib/clapton/javascripts/src/inputs/initialize-inputs.ts +2 -2
- data/lib/clapton/test_helper/base.rb +1 -1
- data/lib/clapton/version.rb +1 -1
- metadata +49 -3
- data/lib/clapton/javascripts/src/dom/update-component.spec.ts +0 -32
@@ -0,0 +1,40 @@
|
|
1
|
+
import { diffNodeType, elementDiffNodeType, elementNodeType, subsetType, textNodeType } from "../types";
|
2
|
+
import { Diff } from "../helpers";
|
3
|
+
export declare const uniqueInBoth: (l1: diffNodeType[], l2: diffNodeType[]) => {};
|
4
|
+
export declare const removeDone: (tree: elementDiffNodeType) => any;
|
5
|
+
export declare const cleanNode: (diffNode: diffNodeType) => elementNodeType | textNodeType;
|
6
|
+
export declare const isEqual: (e1: diffNodeType, e2: diffNodeType) => boolean;
|
7
|
+
export declare const roughlyEqual: (e1: diffNodeType, e2: diffNodeType, uniqueDescriptors: {
|
8
|
+
[key: string]: boolean;
|
9
|
+
}, sameSiblings: boolean, preventRecursion?: boolean) => any;
|
10
|
+
/**
|
11
|
+
* Generate arrays that indicate which node belongs to which subset,
|
12
|
+
* or whether it's actually an orphan node, existing in only one
|
13
|
+
* of the two trees, rather than somewhere in both.
|
14
|
+
*
|
15
|
+
* So if t1 = <img><canvas><br>, t2 = <canvas><br><img>.
|
16
|
+
* The longest subset is "<canvas><br>" (length 2), so it will group 0.
|
17
|
+
* The second longest is "<img>" (length 1), so it will be group 1.
|
18
|
+
* gaps1 will therefore be [1,0,0] and gaps2 [0,0,1].
|
19
|
+
*
|
20
|
+
* If an element is not part of any group, it will stay being 'true', which
|
21
|
+
* is the initial value. For example:
|
22
|
+
* t1 = <img><p></p><br><canvas>, t2 = <b></b><br><canvas><img>
|
23
|
+
*
|
24
|
+
* The "<p></p>" and "<b></b>" do only show up in one of the two and will
|
25
|
+
* therefore be marked by "true". The remaining parts are parts of the
|
26
|
+
* groups 0 and 1:
|
27
|
+
* gaps1 = [1, true, 0, 0], gaps2 = [true, 0, 0, 1]
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
export declare const getGapInformation: (t1: elementDiffNodeType, t2: elementDiffNodeType, stable: subsetType[]) => {
|
31
|
+
gaps1: (number | true)[];
|
32
|
+
gaps2: (number | true)[];
|
33
|
+
};
|
34
|
+
export declare const markSubTrees: (oldTree: elementDiffNodeType, newTree: elementDiffNodeType) => any[];
|
35
|
+
export declare class DiffTracker {
|
36
|
+
list: Diff[];
|
37
|
+
constructor();
|
38
|
+
add(diffs: Diff[]): void;
|
39
|
+
forEach(fn: (Diff: any) => void): void;
|
40
|
+
}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
declare class Diff {
|
2
|
+
constructor(options?: {});
|
3
|
+
toString(): string;
|
4
|
+
setValue(aKey: string | number, aValue: string | number | boolean | number[] | {
|
5
|
+
[key: string]: string | {
|
6
|
+
[key: string]: string;
|
7
|
+
};
|
8
|
+
} | elementNodeType): this;
|
9
|
+
}
|
10
|
+
|
11
|
+
interface elementNodeType {
|
12
|
+
nodeName: string;
|
13
|
+
attributes?: {
|
14
|
+
[key: string]: string;
|
15
|
+
};
|
16
|
+
childNodes?: nodeType[];
|
17
|
+
checked?: boolean;
|
18
|
+
value?: string | number;
|
19
|
+
selected?: boolean;
|
20
|
+
}
|
21
|
+
interface textNodeType {
|
22
|
+
nodeName: "#text" | "#comment";
|
23
|
+
data: string;
|
24
|
+
childNodes?: never;
|
25
|
+
}
|
26
|
+
type nodeType = elementNodeType | textNodeType;
|
27
|
+
interface Document {
|
28
|
+
createElement: (arg: string) => Element;
|
29
|
+
createElementNS: (namespaceURI: string, qualifiedName: string) => Element;
|
30
|
+
createTextNode: (arg: string) => Text;
|
31
|
+
createComment: (arg: string) => Comment;
|
32
|
+
}
|
33
|
+
type PreDiffApply = (PreDiffApplyOptions: any) => boolean;
|
34
|
+
type PostDiffApply = (PostDiffApplyOptions: any) => void;
|
35
|
+
interface ConstNames {
|
36
|
+
addAttribute: string | number;
|
37
|
+
modifyAttribute: string | number;
|
38
|
+
removeAttribute: string | number;
|
39
|
+
modifyTextElement: string | number;
|
40
|
+
relocateGroup: string | number;
|
41
|
+
removeElement: string | number;
|
42
|
+
addElement: string | number;
|
43
|
+
removeTextElement: string | number;
|
44
|
+
addTextElement: string | number;
|
45
|
+
replaceElement: string | number;
|
46
|
+
modifyValue: string | number;
|
47
|
+
modifyChecked: string | number;
|
48
|
+
modifySelected: string | number;
|
49
|
+
modifyComment: string | number;
|
50
|
+
action: string | number;
|
51
|
+
route: string | number;
|
52
|
+
oldValue: string | number;
|
53
|
+
newValue: string | number;
|
54
|
+
element: string | number;
|
55
|
+
group: string | number;
|
56
|
+
groupLength: string | number;
|
57
|
+
from: string | number;
|
58
|
+
to: string | number;
|
59
|
+
name: string | number;
|
60
|
+
value: string | number;
|
61
|
+
data: string | number;
|
62
|
+
attributes: string | number;
|
63
|
+
nodeName: string | number;
|
64
|
+
childNodes: string | number;
|
65
|
+
checked: string | number;
|
66
|
+
selected: string | number;
|
67
|
+
}
|
68
|
+
interface DiffDOMOptions {
|
69
|
+
debug: boolean;
|
70
|
+
diffcap: number;
|
71
|
+
maxDepth: number | false;
|
72
|
+
maxChildCount: number;
|
73
|
+
valueDiffing: boolean;
|
74
|
+
caseSensitive: boolean;
|
75
|
+
textDiff: (node: textNodeType | Text | Comment, currentValue: string, expectedValue: string, newValue: string) => void;
|
76
|
+
preVirtualDiffApply: PreDiffApply;
|
77
|
+
postVirtualDiffApply: PostDiffApply;
|
78
|
+
preDiffApply: PreDiffApply;
|
79
|
+
postDiffApply: PostDiffApply;
|
80
|
+
filterOuterDiff: null | ((t1: any, t2: any, diffs: Diff[]) => void | Diff[]);
|
81
|
+
compress: boolean;
|
82
|
+
_const: ConstNames;
|
83
|
+
document: Document;
|
84
|
+
components: string[];
|
85
|
+
}
|
86
|
+
type DiffDOMOptionsPartial = Partial<DiffDOMOptions>;
|
87
|
+
type diffType = {
|
88
|
+
[key: string | number]: string | number | boolean | number[] | {
|
89
|
+
[key: string]: string | {
|
90
|
+
[key: string]: string;
|
91
|
+
};
|
92
|
+
} | elementNodeType;
|
93
|
+
};
|
94
|
+
|
95
|
+
declare function nodeToObj(aNode: Element, options?: DiffDOMOptionsPartial): elementNodeType;
|
96
|
+
|
97
|
+
declare const stringToObj: (html: string, options?: DiffDOMOptionsPartial) => nodeType;
|
98
|
+
|
99
|
+
declare class DiffDOM {
|
100
|
+
options: DiffDOMOptions;
|
101
|
+
constructor(options?: DiffDOMOptionsPartial);
|
102
|
+
apply(tree: Element, diffs: (Diff | diffType)[]): boolean;
|
103
|
+
undo(tree: Element, diffs: (Diff | diffType)[]): void;
|
104
|
+
diff(t1Node: string | elementNodeType | Element, t2Node: string | elementNodeType | Element): Diff[];
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Use TraceLogger to figure out function calls inside
|
109
|
+
* JS objects by wrapping an object with a TraceLogger
|
110
|
+
* instance.
|
111
|
+
*
|
112
|
+
* Pretty-prints the call trace (using unicode box code)
|
113
|
+
* when tracelogger.toString() is called.
|
114
|
+
*/
|
115
|
+
/**
|
116
|
+
* Wrap an object by calling new TraceLogger(obj)
|
117
|
+
*
|
118
|
+
* If you're familiar with Python decorators, this
|
119
|
+
* does roughly the same thing, adding pre/post
|
120
|
+
* call hook logging calls so that you can see
|
121
|
+
* what's going on.
|
122
|
+
*/
|
123
|
+
declare class TraceLogger {
|
124
|
+
messages: string[];
|
125
|
+
pad: string;
|
126
|
+
padding: string;
|
127
|
+
tick: number;
|
128
|
+
constructor(obj?: {});
|
129
|
+
fin(fn: string, args: string | HTMLElement | number | boolean | false | (string | HTMLElement | number | boolean | false)[]): void;
|
130
|
+
fout(fn: string, result: string | HTMLElement | number | boolean | false | (string | HTMLElement | number | boolean | false)[]): void;
|
131
|
+
format(s: string, tick: number): string;
|
132
|
+
log(...args: any[]): void;
|
133
|
+
toString(): string;
|
134
|
+
}
|
135
|
+
|
136
|
+
export { DiffDOM, TraceLogger, nodeToObj, stringToObj };
|