nattoppet 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ [package]
2
+ name = "nattoppet_native"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ web-view = { version = "0.7", features = ["edge"] }
8
+
9
+ [target.'cfg(windows)'.build-dependencies]
10
+ winres = "0.1"
11
+
12
+ [package.metadata.winres]
13
+ ProductName = "A nattoppet native app"
@@ -0,0 +1,12 @@
1
+ #[cfg(windows)]
2
+ extern crate winres;
3
+
4
+ #[cfg(windows)]
5
+ fn main() {
6
+ let mut res = winres::WindowsResource::new();
7
+ res.set_icon("../icon.ico");
8
+ res.compile().unwrap();
9
+ }
10
+
11
+ #[cfg(not(windows))]
12
+ fn main() {}
@@ -0,0 +1,22 @@
1
+ #![windows_subsystem = "windows"]
2
+
3
+ use web_view::*;
4
+
5
+ fn main() {
6
+ static HTML_CONTENT: &str = include_str!("../target/bundle.html");
7
+
8
+ web_view::builder()
9
+ .title("Nattoppet Native")
10
+ .content(Content::Html(HTML_CONTENT))
11
+ .size(600, 480)
12
+ .resizable(false)
13
+ .debug(cfg!(debug_assertions))
14
+ .user_data(())
15
+ .invoke_handler(handler)
16
+ .run()
17
+ .unwrap();
18
+ }
19
+
20
+ fn handler(webview: &mut WebView<()>, arg: &str) -> WVResult {
21
+ Ok(())
22
+ }
package/nattoppet-dev.js CHANGED
@@ -22,7 +22,7 @@ const done = () => {
22
22
  }
23
23
 
24
24
  const start = (init=false) => {
25
- const child = cp.spawn(__dirname + '/nattoppet.js', [file])
25
+ const child = cp.spawn(__dirname + '/nattoppet.js', [file, '--dev'])
26
26
  let buffer = ''
27
27
  child.stdout.on('data', chunk => buffer += chunk)
28
28
  child.on('close', code => {
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict'
4
+
5
+ const fs = require('fs')
6
+ const cp = require('child_process')
7
+ const path = require('path')
8
+
9
+ const init = () => {
10
+ fs.mkdirSync('native')
11
+ fs.mkdirSync('native/src')
12
+ fs.mkdirSync('native/target')
13
+ fs.copyFileSync(path.join(__dirname, 'native', 'src', 'main.rs'), 'native/src/main.rs')
14
+ fs.copyFileSync(path.join(__dirname, 'native', 'build.rs'), 'native/build.rs')
15
+ fs.copyFileSync(path.join(__dirname, 'native', 'Cargo.toml'), 'native/Cargo.toml')
16
+ }
17
+
18
+ const bundle = () => {
19
+ const child = cp.spawnSync(__dirname + '/nattoppet.js', [process.argv[3]])
20
+ if (child.stderr.length) {
21
+ console.error(child.stderr.toString())
22
+ }
23
+ fs.writeFileSync('native/target/bundle.html', child.stdout)
24
+ }
25
+
26
+ const build = () => {
27
+ bundle()
28
+ const child = cp.spawn('cargo', ['build', '--release'], { cwd: 'native' })
29
+ child.stdout.pipe(process.stdout)
30
+ child.stderr.pipe(process.stderr)
31
+ child.on('exit', (code) => {
32
+ if (code != 0) {
33
+ console.error("Cargo exit with code: " + code)
34
+ } else {
35
+ console.log("building finished. Check native/target/release/")
36
+ }
37
+ })
38
+ }
39
+
40
+ const help = () => {
41
+ console.log("Usage: nattoppet-native [init|bundle|build]")
42
+ }
43
+
44
+ switch (process.argv[2]) {
45
+ case 'init': return init()
46
+ case 'bundle': return bundle()
47
+ case 'build': return build()
48
+ default: return help()
49
+ }
package/nattoppet.js CHANGED
@@ -12,7 +12,8 @@ const file = process.argv[2] || 0
12
12
  const dir = file ? path.dirname(path.resolve(file)) : process.cwd()
13
13
  const str = fs.readFileSync(file, 'utf8')
14
14
  const env = { ...stdlib, base_dir: dir }
15
- const out = minifier.minify(compiler.compile(str, env), {
15
+ const raw = compiler.compile(str, env)
16
+ const out = process.argv.includes('--dev', 1) ? raw : minifier.minify(raw, {
16
17
  collapseWhitespace: true,
17
18
  removeAttributeQuotes: true,
18
19
  removeComments: true,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "nattoppet",
3
3
  "description": "A tiny macro-based markup language for blogging",
4
4
  "author": "Shiwei Zhang <ylxdzsw@gmail.com>",
5
- "version": "2.0.3",
5
+ "version": "2.1.0",
6
6
  "dependencies": {
7
7
  "coffeescript": "^2.5.1",
8
8
  "html-minifier": "^4.0.0",
@@ -12,7 +12,8 @@
12
12
  },
13
13
  "bin": {
14
14
  "nattoppet": "./nattoppet.js",
15
- "nattoppet-dev": "./nattoppet-dev.js"
15
+ "nattoppet-dev": "./nattoppet-dev.js",
16
+ "nattoppet-native": "./nattoppet-native.js"
16
17
  },
17
18
  "license": "MIT",
18
19
  "repository": "https://github.com/ylxdzsw/nattoppet.git"