Skip to content

Commit e7120e3

Browse files
authored
Merge pull request #2 from stackb/goog_module
Refactor into cycle-free core module
2 parents 25d45ff + 2cde9eb commit e7120e3

17 files changed

Lines changed: 1063 additions & 185 deletions

css/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package(default_visibility = ["//visibility:public"])
22

33
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_library", "closure_css_binary")
44

5-
65
closure_css_library(
76
name = "style",
87
srcs = [

js/ui/BUILD renamed to js/ui/BUILD.bazel

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,26 @@ package(default_visibility = ["//visibility:public"])
33
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library", "closure_js_test")
44

55
closure_js_library(
6-
name = "component",
6+
name = "core",
77
srcs = [
8-
"app.js",
9-
"component.js",
10-
"route.js",
11-
"route/event.js",
12-
"router.js",
8+
"core.js",
139
],
1410
deps = [
1511
":history",
16-
":keyboard",
1712
":injector",
13+
":keyboard",
1814
"@io_bazel_rules_closure//closure/library/asserts",
1915
"@io_bazel_rules_closure//closure/library/dom",
20-
"@io_bazel_rules_closure//closure/library/events:event",
16+
"@io_bazel_rules_closure//closure/library/events",
2117
"@io_bazel_rules_closure//closure/library/events:eventhandler",
2218
"@io_bazel_rules_closure//closure/library/events:eventtarget",
2319
"@io_bazel_rules_closure//closure/library/fx:dom",
2420
"@io_bazel_rules_closure//closure/library/fx:easing",
21+
"@io_bazel_rules_closure//closure/library/history:event",
2522
"@io_bazel_rules_closure//closure/library/history:eventtype",
2623
"@io_bazel_rules_closure//closure/library/object",
2724
"@io_bazel_rules_closure//closure/library/promise",
25+
"@io_bazel_rules_closure//closure/library/promise:resolver",
2826
"@io_bazel_rules_closure//closure/library/string",
2927
"@io_bazel_rules_closure//closure/library/style",
3028
"@io_bazel_rules_closure//closure/library/ui:component",
@@ -46,6 +44,7 @@ closure_js_library(
4644
"@io_bazel_rules_closure//closure/library/events:event",
4745
"@io_bazel_rules_closure//closure/library/events:eventtarget",
4846
"@io_bazel_rules_closure//closure/library/events:eventtype",
47+
"@io_bazel_rules_closure//closure/library/history:event",
4948
"@io_bazel_rules_closure//closure/library/history:eventtype",
5049
"@io_bazel_rules_closure//closure/library/history:html5history",
5150
"@io_bazel_rules_closure//closure/library/string",
@@ -71,7 +70,8 @@ closure_js_library(
7170
"template.js",
7271
],
7372
deps = [
74-
":component",
73+
":core",
74+
"@io_bazel_rules_closure//closure/library/dom",
7575
"@io_bazel_rules_closure//closure/library/soy",
7676
],
7777
)
@@ -85,7 +85,7 @@ closure_js_library(
8585
"tabs.js",
8686
],
8787
deps = [
88-
":component",
88+
":core",
8989
"@io_bazel_rules_closure//closure/library/asserts",
9090
"@io_bazel_rules_closure//closure/library/dom",
9191
"@io_bazel_rules_closure//closure/library/dom:classlist",
@@ -103,9 +103,11 @@ closure_js_library(
103103
deps = [
104104
"@io_bazel_rules_closure//closure/library/asserts",
105105
"@io_bazel_rules_closure//closure/library/dom",
106+
"@io_bazel_rules_closure//closure/library/events",
106107
"@io_bazel_rules_closure//closure/library/math:coordinate",
107108
"@io_bazel_rules_closure//closure/library/style",
108109
"@io_bazel_rules_closure//closure/library/ui:component",
110+
"@io_bazel_rules_closure//closure/library/ui:container",
109111
"@io_bazel_rules_closure//closure/library/ui:menu",
110112
"@io_bazel_rules_closure//closure/library/ui:menubutton",
111113
"@io_bazel_rules_closure//closure/library/ui:submenu",
@@ -119,39 +121,28 @@ closure_js_library(
119121
"syntax.js",
120122
],
121123
deps = [
122-
":component",
124+
":core",
123125
"@io_bazel_rules_closure//closure/library/asserts",
124126
"@io_bazel_rules_closure//closure/library/dom",
125127
],
126128
)
127129

128-
# closure_js_library(
129-
# name = "app",
130-
# srcs = [
131-
# ],
132-
# deps = [
133-
# ":component",
134-
# ],
135-
# )
136-
137130
closure_js_library(
138131
name = "injector",
139132
srcs = [
140133
"injector.js",
141134
],
142135
deps = [
143-
# ":component",
136+
# ":core",
144137
],
145138
)
146139

147140
closure_js_library(
148141
name = "ui",
149-
# srcs = [
150-
# ],
151142
exports = [
152-
":injector",
153-
":component",
143+
":core",
154144
":history",
145+
":injector",
155146
":keyboard",
156147
":menushield",
157148
":select",
@@ -185,7 +176,7 @@ closure_js_test(
185176
],
186177
entry_points = ["goog:stack.ui.RouteTest"],
187178
deps = [
188-
":component",
179+
":core",
189180
":select",
190181
":app",
191182
# "@io_bazel_rules_closure//closure/library",
@@ -201,10 +192,10 @@ closure_js_test(
201192
entry_points = ["goog:stack.ui.HistoryTest"],
202193
deps = [
203194
":history",
195+
"@io_bazel_rules_closure//closure/library:testing",
204196
"@io_bazel_rules_closure//closure/library/dom",
205197
"@io_bazel_rules_closure//closure/library/dom:tagname",
206198
"@io_bazel_rules_closure//closure/library/events",
207199
"@io_bazel_rules_closure//closure/library/string",
208-
"@io_bazel_rules_closure//closure/library:testing",
209200
],
210201
)

js/ui/app.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ goog.module('stack.ui.App');
22

33
const BzlHistory = goog.require('stack.ui.History');
44
const Component = goog.require('stack.ui.Component');
5-
const HEventType = goog.require('goog.history.EventType');
6-
const Injector = goog.require('stack.ui.Injector');
5+
const HistoryEvent = goog.require('goog.history.Event');
6+
const HistoryEventType = goog.require('goog.history.EventType');
7+
const Injector = goog.require('stack.ui.Injector');
78
const Keyboard = goog.require('stack.ui.Keyboard');
8-
const Promise_ = goog.require('goog.Promise');
9-
const Router = goog.require('stack.ui.Router');
10-
const asserts = goog.require('goog.asserts');
11-
const dom = goog.require('goog.dom');
12-
const objects = goog.require('goog.object');
9+
const Promise_ = goog.require('goog.Promise');
10+
const Route = goog.require('stack.ui.Route');
11+
const Router = goog.require('stack.ui.Router');
12+
const asserts = goog.require('goog.asserts');
13+
const dom = goog.require('goog.dom');
14+
const objects = goog.require('goog.object');
1315

1416

1517
class App extends Component {
@@ -25,7 +27,7 @@ class App extends Component {
2527
* @type {!Injector}
2628
*/
2729
this.injector_ = new Injector();
28-
30+
2931
/**
3032
* A registry of components that can be accessed by a common name.
3133
* @const @private
@@ -35,7 +37,7 @@ class App extends Component {
3537

3638
/** @const @private @type {!BzlHistory} */
3739
this.history_ = new BzlHistory();
38-
this.getHandler().listen(this.history_, HEventType.NAVIGATE, this.handleHistoryNavigate);
40+
this.getHandler().listen(this.history_, HistoryEventType.NAVIGATE, this.handleHistoryNavigate);
3941
this.registerDisposable(this.history_);
4042

4143
/** @const @private @type {!Keyboard} */
@@ -50,16 +52,16 @@ class App extends Component {
5052
start() {
5153
this.history_.setEnabled(true);
5254
}
53-
55+
5456
/**
55-
* @param {!goog.history.Event} e
57+
* @param {!HistoryEvent} e
5658
*/
5759
handleHistoryNavigate(e) {
5860
this.router_.go(e.token).thenCatch(err => {
5961
console.warn(`Routing failure while nagivating to ${e.token}`);
6062
});
6163
}
62-
64+
6365
/**
6466
* @param {!Component} c
6567
* @param {!boolean} b
@@ -71,14 +73,14 @@ class App extends Component {
7173
console.warn("Stop Loaded " + c.getPathUrl());
7274
}
7375
}
74-
76+
7577
/**
7678
* @return {!Keyboard}
7779
*/
7880
getKbd() {
7981
return this.kbd_;
8082
}
81-
83+
8284
/**
8385
* @return {!Router}
8486
*/
@@ -92,7 +94,7 @@ class App extends Component {
9294
getInjector() {
9395
return this.injector_;
9496
}
95-
97+
9698
/**
9799
* @param {string} msg
98100
*/
@@ -138,8 +140,8 @@ class App extends Component {
138140
//route.touch(this);
139141
super.go(route);
140142
}
141-
142-
/** @param {!stack.ui.Route} route */
143+
144+
/** @param {!Route} route */
143145
handle404(route) {
144146
this.notifyError("404 (Not Found): " + route.getPath());
145147
}
@@ -157,7 +159,7 @@ class App extends Component {
157159
* will loopback on this object to the go() method.
158160
*
159161
* @param {string} path
160-
* @return {!Promise_<!stack.ui.Route>}
162+
* @return {!Promise_<!Route>}
161163
*/
162164
route(path) {
163165
return this.router_.go(path).thenCatch(err => {

js/ui/body.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const soy = goog.require('goog.soy');
1010
class Body extends Select {
1111

1212
/**
13-
* @param {?goog.dom.DomHelper=} opt_domHelper
13+
* @param {?dom.DomHelper=} opt_domHelper
1414
*/
1515
constructor(opt_domHelper) {
1616
super(opt_domHelper);
1717
this.addTab('home', new Home());
1818
this.addTab('search', new List());
1919
}
20-
20+
2121
/**
2222
* Modifies behavior to use touch rather than progress to
2323
* not advance the path pointer.
@@ -38,7 +38,7 @@ class Body extends Select {
3838
goHere(route) {
3939
this.select('home', route.add('home'));
4040
}
41-
41+
4242
/**
4343
* @override
4444
*/
@@ -55,7 +55,7 @@ class Body extends Select {
5555
super.enterDocument();
5656
this.addChild(new Menu(this.getTabStrict('search'), this.getDomHelper()), true);
5757
}
58-
58+
5959
}
6060

6161
exports = Body;

0 commit comments

Comments
 (0)