Commit 79795fce authored by rbpotter's avatar rbpotter Committed by Commit Bot

Web UI: Autogenerate JS module version of cr.ui.Store

Autogenerate a JS module version of cr/ui/store.js and add typechecking.
This is a prerequesite for migrating pages that depend on cr.ui.Store
to Polymer 3, e.g. Bookmarks.

Bug: 1022213
Change-Id: I81634347188232468e851b63859b553c7e33c6a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1912693
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714847}
parent 7ebb2906
......@@ -272,12 +272,17 @@ js_modulizer("modulize") {
"focus_row.js",
"focus_row_behavior.js",
"focus_without_ink.js",
"store.js",
"store_client.js",
]
namespace_rewrites = [
"cr.ui.Action|Action",
"cr.ui.DeferredAction|DeferredAction",
"cr.ui.DragWrapperDelegate|DragWrapperDelegate",
"cr.ui.FocusRowDelegate|FocusRowDelegate",
"cr.ui.FocusRow|FocusRow",
"cr.ui.focusWithoutInk|focusWithoutInk",
"cr.ui.StoreObserver|StoreObserver",
]
}
......@@ -289,6 +294,8 @@ js_type_check("ui_resources_modules") {
":focus_row.m",
":focus_row_behavior.m",
":focus_without_ink.m",
":store.m",
":store_client.m",
]
}
......@@ -341,3 +348,21 @@ js_library("focus_without_ink.m") {
]
extra_deps = [ ":modulize" ]
}
js_library("store.m") {
sources = [
"$root_gen_dir/ui/webui/resources/js/cr/ui/store.m.js",
]
extra_deps = [ ":modulize" ]
}
js_library("store_client.m") {
deps = [
":store.m",
"../..:assert.m",
]
sources = [
"$root_gen_dir/ui/webui/resources/js/cr/ui/store_client.m.js",
]
extra_deps = [ ":modulize" ]
}
......@@ -4,16 +4,16 @@
cr.define('cr.ui', function() {
/** @typedef {{name: string}} */
let Action;
/* #export */ let Action;
/** @typedef {function(function(?cr.ui.Action))} */
let DeferredAction;
/* #export */ let DeferredAction;
/**
* @interface
* @template T
*/
class StoreObserver {
/* #export */ class StoreObserver {
/** @param {!T} newState */
onStateChanged(newState) {}
}
......@@ -25,7 +25,7 @@ cr.define('cr.ui', function() {
* associated with the store.
* @template T
*/
class Store {
/* #export */ class Store {
/**
* @param {T} emptyState
* @param {function(T, cr.ui.Action):T} reducer
......@@ -158,6 +158,7 @@ cr.define('cr.ui', function() {
}
}
// #cr_define_end
return {
Action: Action,
DeferredAction: DeferredAction,
......
......@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import {assertNotReached} from '../../assert.m.js';
// #import {Action, DeferredAction} from './store.m.js';
cr.define('cr.ui', function() {
/**
* StoreClient is a Polymer behavior which ties front-end elements to
......@@ -22,7 +25,7 @@ cr.define('cr.ui', function() {
*
* @polymerBehavior
*/
const StoreClient = {
/* #export */ const StoreClient = {
created: function() {
/**
* @type {!Array<{
......@@ -131,6 +134,7 @@ cr.define('cr.ui', function() {
},
};
// #cr_define_end
return {
StoreClient: StoreClient,
};
......
......@@ -103,6 +103,12 @@ without changes to the corresponding grd file. -->
<include name="IDR_WEBUI_JS_CR_UI_FOCUS_WITHOUT_INK_M_JS"
file="${root_gen_dir}/ui/webui/resources/js/cr/ui/focus_without_ink.m.js"
use_base_dir="false" type="BINDATA" compress="gzip" />
<include name="IDR_WEBUI_JS_CR_UI_STORE_M_JS"
file="${root_gen_dir}/ui/webui/resources/js/cr/ui/store.m.js"
use_base_dir="false" type="BINDATA" compress="gzip" />
<include name="IDR_WEBUI_JS_CR_UI_STORE_CLIENT_M_JS"
file="${root_gen_dir}/ui/webui/resources/js/cr/ui/store_client.m.js"
use_base_dir="false" type="BINDATA" compress="gzip" />
<include name="IDR_WEBUI_JS_EVENT_TRACKER_M_JS"
file="${root_gen_dir}/ui/webui/resources/js/event_tracker.m.js"
use_base_dir="false" type="BINDATA" compress="gzip" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment