From 1dc32dfcecc2abfb548780936696739865dc2794 Mon Sep 17 00:00:00 2001 From: Kiho Date: Sat, 18 Nov 2017 13:52:55 -0800 Subject: [PATCH 1/4] Refactor code to use injected global store --- npm-debug.log.1285439957 | 0 npm-debug.log.2713944281 | 0 package.json | 2 +- public/js/bundle.min.js.map | 1 + src/components/counter/DecrementButton.html | 2 +- src/components/counter/IncrementButton.html | 2 +- src/components/counter/Value.html | 20 ++++++++++---------- src/main.ts | 2 ++ src/store/actions.ts | 10 +++++++--- src/store/bindActions.ts | 11 +++++++++++ src/store/store.ts | 21 +++++++++++++++++++++ src/typings/svelte.d.ts | 2 +- tsconfig.json | 2 +- 13 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 npm-debug.log.1285439957 create mode 100644 npm-debug.log.2713944281 create mode 100644 public/js/bundle.min.js.map create mode 100644 src/store/bindActions.ts diff --git a/npm-debug.log.1285439957 b/npm-debug.log.1285439957 new file mode 100644 index 0000000..e69de29 diff --git a/npm-debug.log.2713944281 b/npm-debug.log.2713944281 new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index acee56c..e24a358 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "rollup-plugin-uglify": "^2.0.1", "rollup-watch": "^4.3.1", "serve": "^6.4.1", - "svelte": "^1.41.2", + "svelte": "file:../../svelte", "typescript": "^2.6.1" } } diff --git a/public/js/bundle.min.js.map b/public/js/bundle.min.js.map new file mode 100644 index 0000000..60dc7a6 --- /dev/null +++ b/public/js/bundle.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bundle.min.js","sources":["../../node_modules/svelte/shared.js","../../node_modules/redux-zero/svelte/index.js","../../src/components/counter/Value.html","../../node_modules/redux-zero/dist/redux-zero.js","../../src/store/store.ts","../../src/store/actions.ts","../../src/components/counter/IncrementButton.html","../../src/components/counter/DecrementButton.html","../../src/components/counter/Counter.html","../../src/main.ts"],"sourcesContent":["function noop() {}\n\nfunction assign(target) {\n\tvar k,\n\t\tsource,\n\t\ti = 1,\n\t\tlen = arguments.length;\n\tfor (; i < len; i++) {\n\t\tsource = arguments[i];\n\t\tfor (k in source) target[k] = source[k];\n\t}\n\n\treturn target;\n}\n\nfunction appendNode(node, target) {\n\ttarget.appendChild(node);\n}\n\nfunction insertNode(node, target, anchor) {\n\ttarget.insertBefore(node, anchor);\n}\n\nfunction detachNode(node) {\n\tnode.parentNode.removeChild(node);\n}\n\nfunction detachBetween(before, after) {\n\twhile (before.nextSibling && before.nextSibling !== after) {\n\t\tbefore.parentNode.removeChild(before.nextSibling);\n\t}\n}\n\nfunction detachBefore(after) {\n\twhile (after.previousSibling) {\n\t\tafter.parentNode.removeChild(after.previousSibling);\n\t}\n}\n\nfunction detachAfter(before) {\n\twhile (before.nextSibling) {\n\t\tbefore.parentNode.removeChild(before.nextSibling);\n\t}\n}\n\nfunction reinsertBetween(before, after, target) {\n\twhile (before.nextSibling && before.nextSibling !== after) {\n\t\ttarget.appendChild(before.parentNode.removeChild(before.nextSibling));\n\t}\n}\n\nfunction reinsertChildren(parent, target) {\n\twhile (parent.firstChild) target.appendChild(parent.firstChild);\n}\n\nfunction reinsertAfter(before, target) {\n\twhile (before.nextSibling) target.appendChild(before.nextSibling);\n}\n\nfunction reinsertBefore(after, target) {\n\tvar parent = after.parentNode;\n\twhile (parent.firstChild !== after) target.appendChild(parent.firstChild);\n}\n\nfunction destroyEach(iterations) {\n\tfor (var i = 0; i < iterations.length; i += 1) {\n\t\tif (iterations[i]) iterations[i].d();\n\t}\n}\n\nfunction createFragment() {\n\treturn document.createDocumentFragment();\n}\n\nfunction createElement(name) {\n\treturn document.createElement(name);\n}\n\nfunction createSvgElement(name) {\n\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n}\n\nfunction createText(data) {\n\treturn document.createTextNode(data);\n}\n\nfunction createComment() {\n\treturn document.createComment('');\n}\n\nfunction addListener(node, event, handler) {\n\tnode.addEventListener(event, handler, false);\n}\n\nfunction removeListener(node, event, handler) {\n\tnode.removeEventListener(event, handler, false);\n}\n\nfunction setAttribute(node, attribute, value) {\n\tnode.setAttribute(attribute, value);\n}\n\nfunction setXlinkAttribute(node, attribute, value) {\n\tnode.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\n\nfunction getBindingGroupValue(group) {\n\tvar value = [];\n\tfor (var i = 0; i < group.length; i += 1) {\n\t\tif (group[i].checked) value.push(group[i].__value);\n\t}\n\treturn value;\n}\n\nfunction toNumber(value) {\n\treturn value === '' ? undefined : +value;\n}\n\nfunction timeRangesToArray(ranges) {\n\tvar array = [];\n\tfor (var i = 0; i < ranges.length; i += 1) {\n\t\tarray.push({ start: ranges.start(i), end: ranges.end(i) });\n\t}\n\treturn array;\n}\n\nfunction children (element) {\n\treturn Array.from(element.childNodes);\n}\n\nfunction claimElement (nodes, name, attributes, svg) {\n\tfor (var i = 0; i < nodes.length; i += 1) {\n\t\tvar node = nodes[i];\n\t\tif (node.nodeName === name) {\n\t\t\tfor (var j = 0; j < node.attributes.length; j += 1) {\n\t\t\t\tvar attribute = node.attributes[j];\n\t\t\t\tif (!attributes[attribute.name]) node.removeAttribute(attribute.name);\n\t\t\t}\n\t\t\treturn nodes.splice(i, 1)[0]; // TODO strip unwanted attributes\n\t\t}\n\t}\n\n\treturn svg ? createSvgElement(name) : createElement(name);\n}\n\nfunction claimText (nodes, data) {\n\tfor (var i = 0; i < nodes.length; i += 1) {\n\t\tvar node = nodes[i];\n\t\tif (node.nodeType === 3) {\n\t\t\tnode.data = data;\n\t\t\treturn nodes.splice(i, 1)[0];\n\t\t}\n\t}\n\n\treturn createText(data);\n}\n\nfunction setInputType(input, type) {\n\ttry {\n\t\tinput.type = type;\n\t} catch (e) {}\n}\n\nfunction setStyle(node, key, value) {\n\tnode.style.setProperty(key, value);\n}\n\nfunction linear(t) {\n\treturn t;\n}\n\nfunction generateRule(\n\ta,\n\tb,\n\tdelta,\n\tduration,\n\tease,\n\tfn\n) {\n\tvar keyframes = '{\\n';\n\n\tfor (var p = 0; p <= 1; p += 16.666 / duration) {\n\t\tvar t = a + delta * ease(p);\n\t\tkeyframes += p * 100 + '%{' + fn(t) + '}\\n';\n\t}\n\n\treturn keyframes + '100% {' + fn(b) + '}\\n}';\n}\n\n// https://github.com/darkskyapp/string-hash/blob/master/index.js\nfunction hash(str) {\n\tvar hash = 5381;\n\tvar i = str.length;\n\n\twhile (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);\n\treturn hash >>> 0;\n}\n\nfunction wrapTransition(component, node, fn, params, intro, outgroup) {\n\tvar obj = fn(node, params);\n\tvar duration = obj.duration || 300;\n\tvar ease = obj.easing || linear;\n\tvar cssText;\n\n\t// TODO share