bare-native 0.1.0 → 0.1.2

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.
package/README.md CHANGED
@@ -1,11 +1,31 @@
1
1
  # bare-native
2
2
 
3
- Native application development framework for Bare.
3
+ Native application development framework for Bare. It provides a common set of UI primitives backed by the native platform UI toolkits, built on top of the Bare native addon system. This means that all native code is neatly tucked away and delivered to developers as prebuilt binaries, [no compilation required](https://xkcd.com/303/).
4
4
 
5
5
  ```
6
6
  npm i bare-native
7
7
  ```
8
8
 
9
+ ## Usage
10
+
11
+ ```js
12
+ const { Window } = require('bare-native')
13
+
14
+ const window = new Window(400, 250)
15
+ ```
16
+
17
+ <https://github.com/holepunchto/bare-build> is used to package your application code alongside a Bare runtime suitable for the target platform. Either install the tool globally or as a development dependency of your project:
18
+
19
+ ```
20
+ npm i [-g|-D] bare-build
21
+ ```
22
+
23
+ Next, build your application for the target platform, telling `bare-build` to use the `bare-native` runtime:
24
+
25
+ ```
26
+ bare-build --out <dir> --target <platform>-<arch> --runtime bare-native/runtime app.js
27
+ ```
28
+
9
29
  ## License
10
30
 
11
31
  Apache-2.0
@@ -0,0 +1,37 @@
1
+ const EventEmitter = require('bare-events')
2
+ const NDK = require('bare-ndk')
3
+
4
+ module.exports = class NativeWebView extends EventEmitter {
5
+ constructor() {
6
+ super()
7
+
8
+ this._native = new NDK.WebView()
9
+
10
+ this._native.javaScriptEnabled(true)
11
+ }
12
+
13
+ get native() {
14
+ return this._native
15
+ }
16
+
17
+ loadURL(url) {
18
+ this._native.loadURL(url)
19
+ return this
20
+ }
21
+
22
+ loadHTML(html) {
23
+ this._native.loadData(html)
24
+ return this
25
+ }
26
+
27
+ inspectable(enabled) {
28
+ NDK.WebView.debuggingEnabled(enabled)
29
+ return this
30
+ }
31
+
32
+ [Symbol.for('bare.inspect')]() {
33
+ return {
34
+ __proto__: { constructor: NativeWebView }
35
+ }
36
+ }
37
+ }
@@ -22,6 +22,11 @@ module.exports = class NativeWebView extends EventEmitter {
22
22
  return this
23
23
  }
24
24
 
25
+ inspectable(enabled) {
26
+ this._native.inspectable = enabled
27
+ return this
28
+ }
29
+
25
30
  [Symbol.for('bare.inspect')]() {
26
31
  return {
27
32
  __proto__: { constructor: NativeWebView }
@@ -24,6 +24,10 @@ module.exports = class NativeWebView extends EventEmitter {
24
24
  return this
25
25
  }
26
26
 
27
+ inspectable(enabled) {
28
+ return this
29
+ }
30
+
27
31
  [Symbol.for('bare.inspect')]() {
28
32
  return {
29
33
  __proto__: { constructor: NativeWebView }
@@ -22,6 +22,10 @@ module.exports = class NativeWebView extends EventEmitter {
22
22
  return this
23
23
  }
24
24
 
25
+ inspectable(enabled) {
26
+ return this
27
+ }
28
+
25
29
  [Symbol.for('bare.inspect')]() {
26
30
  return {
27
31
  __proto__: { constructor: NativeWebView }
@@ -0,0 +1,25 @@
1
+ const EventEmitter = require('bare-events')
2
+ const NDK = require('bare-ndk')
3
+
4
+ module.exports = class NativeWindow extends EventEmitter {
5
+ constructor() {
6
+ super()
7
+
8
+ this._native = NDK.Activity
9
+ }
10
+
11
+ get native() {
12
+ return this._native
13
+ }
14
+
15
+ content(view) {
16
+ this._native.contentView(view._native)
17
+ return this
18
+ }
19
+
20
+ [Symbol.for('bare.inspect')]() {
21
+ return {
22
+ __proto__: { constructor: NativeWindow }
23
+ }
24
+ }
25
+ }
@@ -17,18 +17,13 @@ module.exports = class NativeWindow extends EventEmitter {
17
17
  styleMask: DEFAULT_STYLE_MASK
18
18
  })
19
19
 
20
- this._native.center()
20
+ this._native.makeKeyWindow().orderFront().center()
21
21
  }
22
22
 
23
23
  get native() {
24
24
  return this._native
25
25
  }
26
26
 
27
- show() {
28
- this._native.makeKeyWindow().orderFront()
29
- return this
30
- }
31
-
32
27
  content(view) {
33
28
  this._native.contentView = view._native
34
29
  return this
@@ -0,0 +1,31 @@
1
+ const EventEmitter = require('bare-events')
2
+ const UIKit = require('bare-ui-kit')
3
+
4
+ module.exports = class NativeWindow extends EventEmitter {
5
+ constructor() {
6
+ super()
7
+
8
+ this._native = new UIKit.Window()
9
+
10
+ this._native.hidden = false
11
+ this._native.makeKeyWindow()
12
+ }
13
+
14
+ get native() {
15
+ return this._native
16
+ }
17
+
18
+ content(view) {
19
+ const viewController = new UIKit.ViewController()
20
+ viewController.view = view._native
21
+
22
+ this._native.rootViewController = viewController
23
+ return this
24
+ }
25
+
26
+ [Symbol.for('bare.inspect')]() {
27
+ return {
28
+ __proto__: { constructor: NativeWindow }
29
+ }
30
+ }
31
+ }
@@ -7,6 +7,7 @@ module.exports = class NativeWindow extends EventEmitter {
7
7
 
8
8
  this._native = new GTK.Window()
9
9
 
10
+ this._native.visible = true
10
11
  this._native.defaultSize = [width, height]
11
12
  }
12
13
 
@@ -14,11 +15,6 @@ module.exports = class NativeWindow extends EventEmitter {
14
15
  return this._native
15
16
  }
16
17
 
17
- show() {
18
- this._native.visible = true
19
- return this
20
- }
21
-
22
18
  content(view) {
23
19
  this._native.child = view._native
24
20
  return this
@@ -7,18 +7,13 @@ module.exports = class NativeWindow extends EventEmitter {
7
7
 
8
8
  this._native = new WinUI.Window()
9
9
 
10
- this._native.resize(width, height)
10
+ this._native.resize(width, height).activate()
11
11
  }
12
12
 
13
13
  get native() {
14
14
  return this._native
15
15
  }
16
16
 
17
- show() {
18
- this._native.activate()
19
- return this
20
- }
21
-
22
17
  content(view) {
23
18
  this._native.content = view._native
24
19
  return this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-native",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Native application development framework for Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -10,13 +10,16 @@
10
10
  "imports": {
11
11
  "#window": {
12
12
  "darwin": "./lib/window/darwin.js",
13
+ "ios": "./lib/window/ios.js",
13
14
  "linux": "./lib/window/linux.js",
15
+ "android": "./lib/window/android.js",
14
16
  "win32": "./lib/window/win32.js"
15
17
  },
16
18
  "#web-view": {
17
19
  "darwin": "./lib/web-view/apple.js",
18
20
  "ios": "./lib/web-view/apple.js",
19
21
  "linux": "./lib/web-view/linux.js",
22
+ "android": "./lib/web-view/android.js",
20
23
  "win32": "./lib/web-view/win32.js"
21
24
  }
22
25
  },
@@ -42,7 +45,8 @@
42
45
  "bare-app-kit": "^0.1.0",
43
46
  "bare-events": "^2.8.2",
44
47
  "bare-gtk": "^0.1.0",
45
- "bare-ui-kit": "^0.1.0",
48
+ "bare-ndk": "^0.1.2",
49
+ "bare-ui-kit": "^0.1.1",
46
50
  "bare-web-kit": "^0.1.0",
47
51
  "bare-web-kit-gtk": "^0.1.0",
48
52
  "bare-win-ui": "^0.1.0"
package/runtime.js CHANGED
@@ -1,9 +1,13 @@
1
1
  const AppKit = require('bare-app-kit/runtime')
2
+ const UIKit = require('bare-ui-kit/runtime')
2
3
  const GTK = require('bare-gtk/runtime')
4
+ const NDK = require('bare-ndk/runtime')
3
5
  const WinUI = require('bare-win-ui/runtime')
4
6
 
5
7
  exports.prebuilds = {
6
8
  ...AppKit.prebuilds,
9
+ ...UIKit.prebuilds,
7
10
  ...GTK.prebuilds,
11
+ ...NDK.prebuilds,
8
12
  ...WinUI.prebuilds
9
13
  }