Begin splitting up `index.ts`

This commit is contained in:
Patrick Walton 2017-08-25 20:20:45 -07:00
parent 894226e023
commit 01d1382324
6 changed files with 30 additions and 12 deletions

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="/css/pathfinder.css">
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrap.js"></script>
<script type="text/javascript" src="js/pathfinder.js"></script>
<script type="text/javascript" src="js/pathfinder/svg.js"></script>
</head>
<body>
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse">

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="/css/pathfinder.css">
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrap.js"></script>
<script type="text/javascript" src="js/pathfinder.js"></script>
<script type="text/javascript" src="js/pathfinder/text.js"></script>
</head>
<body>
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse">

9
demo/client/src/svg.ts Normal file
View File

@ -0,0 +1,9 @@
// pathfinder/client/src/svg.ts
//
// Copyright © 2017 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

View File

@ -1,6 +1,12 @@
// pathfinder/demo/src/index.ts
// pathfinder/client/src/text.ts
//
// Copyright © 2017 Mozilla Foundation
// Copyright © 2017 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
import * as _ from 'lodash';
import * as base64js from 'base64-js';

View File

@ -1,6 +1,9 @@
module.exports = {
devtool: 'inline-source-map',
entry: "./src/index.ts",
entry: {
svg: "./src/svg.ts",
text: "./src/text.ts",
},
module: {
rules: [
{
@ -14,7 +17,7 @@ module.exports = {
extensions: [".tsx", ".ts", ".js"],
},
output: {
filename: "pathfinder.js",
filename: "[name].js",
path: __dirname,
},
}

View File

@ -42,7 +42,7 @@ static STATIC_CSS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstr
static STATIC_CSS_PATHFINDER_PATH: &'static str = "../client/css/pathfinder.css";
static STATIC_JS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstrap/dist/js";
static STATIC_JS_JQUERY_PATH: &'static str = "../client/node_modules/jquery/dist";
static STATIC_JS_PATHFINDER_JS_PATH: &'static str = "../client/pathfinder.js";
static STATIC_JS_PATHFINDER_PATH: &'static str = "../client";
static STATIC_GLSL_PATH: &'static str = "../../shaders";
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
@ -328,10 +328,6 @@ fn static_text_demo() -> io::Result<NamedFile> {
fn static_svg_demo() -> io::Result<NamedFile> {
NamedFile::open(STATIC_SVG_DEMO_PATH)
}
#[get("/js/pathfinder.js")]
fn static_js_pathfinder_js() -> io::Result<NamedFile> {
NamedFile::open(STATIC_JS_PATHFINDER_JS_PATH)
}
#[get("/css/bootstrap/<file..>")]
fn static_css_bootstrap(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new(STATIC_CSS_BOOTSTRAP_PATH).join(file)).ok()
@ -348,6 +344,10 @@ fn static_js_bootstrap(file: PathBuf) -> Option<NamedFile> {
fn static_js_jquery(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new(STATIC_JS_JQUERY_PATH).join(file)).ok()
}
#[get("/js/pathfinder/<file..>")]
fn static_js_pathfinder(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new(STATIC_JS_PATHFINDER_PATH).join(file)).ok()
}
#[get("/glsl/<file..>")]
fn static_glsl(file: PathBuf) -> Option<Shader> {
Shader::open(Path::new(STATIC_GLSL_PATH).join(file)).ok()
@ -376,11 +376,11 @@ fn main() {
partition_font,
static_text_demo,
static_svg_demo,
static_js_pathfinder_js,
static_css_bootstrap,
static_css_pathfinder_css,
static_js_bootstrap,
static_js_jquery,
static_js_pathfinder,
static_glsl,
]).launch();
}