clapton 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/app/helpers/clapton/clapton_helper.rb +16 -1
  4. data/lib/clapton/engine.rb +20 -10
  5. data/lib/clapton/javascripts/dist/client.js +38 -27
  6. data/lib/clapton/javascripts/dist/components-for-test.js +439 -0
  7. data/lib/clapton/javascripts/dist/components.js +356 -382
  8. data/lib/clapton/javascripts/node_modules/diff-dom/LICENSE.txt +165 -0
  9. data/lib/clapton/javascripts/node_modules/diff-dom/README.md +224 -0
  10. data/lib/clapton/javascripts/node_modules/diff-dom/browser/diffDOM.js +2 -0
  11. data/lib/clapton/javascripts/node_modules/diff-dom/browser/diffDOM.js.map +1 -0
  12. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/TraceLogger.d.ts +28 -0
  13. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/apply.d.ts +4 -0
  14. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/fromVirtual.d.ts +2 -0
  15. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/index.d.ts +2 -0
  16. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/undo.d.ts +3 -0
  17. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/helpers.d.ts +11 -0
  18. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/index.d.ts +10 -0
  19. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/types.d.ts +104 -0
  20. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/apply.d.ts +3 -0
  21. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/diff.d.ts +22 -0
  22. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/fromDOM.d.ts +2 -0
  23. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/fromString.d.ts +2 -0
  24. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/helpers.d.ts +40 -0
  25. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/index.d.ts +3 -0
  26. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/index.d.ts +2 -0
  27. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.d.ts +136 -0
  28. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.js +1996 -0
  29. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.js.map +1 -0
  30. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.min.js +2 -0
  31. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.min.js.map +1 -0
  32. data/lib/clapton/javascripts/node_modules/diff-dom/dist/module.js +1991 -0
  33. data/lib/clapton/javascripts/node_modules/diff-dom/dist/module.js.map +1 -0
  34. data/lib/clapton/javascripts/node_modules/diff-dom/index.html +62 -0
  35. data/lib/clapton/javascripts/node_modules/diff-dom/package.json +54 -0
  36. data/lib/clapton/javascripts/node_modules/diff-dom/rollup.config.mjs +67 -0
  37. data/lib/clapton/javascripts/node_modules/diff-dom/src/TraceLogger.ts +143 -0
  38. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/apply.ts +227 -0
  39. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/fromVirtual.ts +83 -0
  40. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/index.ts +2 -0
  41. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/undo.ts +90 -0
  42. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/helpers.ts +40 -0
  43. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/index.ts +121 -0
  44. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/types.ts +154 -0
  45. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/apply.ts +349 -0
  46. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/diff.ts +855 -0
  47. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/fromDOM.ts +74 -0
  48. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/fromString.ts +239 -0
  49. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/helpers.ts +461 -0
  50. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/index.ts +3 -0
  51. data/lib/clapton/javascripts/node_modules/diff-dom/src/index.ts +2 -0
  52. data/lib/clapton/javascripts/node_modules/diff-dom/tsconfig.json +103 -0
  53. data/lib/clapton/javascripts/rollup.config.mjs +17 -2
  54. data/lib/clapton/javascripts/src/actions/handle-action.ts +6 -6
  55. data/lib/clapton/javascripts/src/actions/initialize-actions.ts +6 -3
  56. data/lib/clapton/javascripts/src/channel/clapton-channel.js +6 -3
  57. data/lib/clapton/javascripts/src/client.ts +15 -15
  58. data/lib/clapton/javascripts/src/components-for-test.ts +29 -0
  59. data/lib/clapton/javascripts/src/components.ts +4 -1
  60. data/lib/clapton/javascripts/src/dom/update-component.ts +4 -4
  61. data/lib/clapton/javascripts/src/inputs/initialize-inputs.ts +2 -2
  62. data/lib/clapton/test_helper/base.rb +1 -1
  63. data/lib/clapton/version.rb +1 -2
  64. metadata +49 -3
  65. 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,3 @@
1
+ export { DiffFinder } from "./diff";
2
+ export { nodeToObj } from "./fromDOM";
3
+ export { stringToObj } from "./fromString";
@@ -0,0 +1,2 @@
1
+ export { DiffDOM, nodeToObj, stringToObj } from "./diffDOM/index";
2
+ export { TraceLogger } from "./TraceLogger";
@@ -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 };