Skip to content
Ukjin Yang edited this page Jan 19, 2016 · 67 revisions

모든 앱 패키지에는 반드시 package.json 라는 파일이 들어가 있어야 합니다. 이는 nw.js가 앱을 어떻게 컨트롤 하고 브라우징을 처리하는지 전달하는 요소가 됩니다.

빠른 시작

{
  "main": "index.html",
  "name": "nw-demo",
  "description": "demo app of node-webkit",
  "version": "0.1.0",
  "keywords": [ "demo", "node-webkit" ],
  "window": {
    "title": "node-webkit demo",
    "icon": "link.png",
    "toolbar": true,
    "frame": false,
    "width": 800,
    "height": 500,
    "position": "mouse",
    "min_width": 400,
    "min_height": 200,
    "max_width": 800,
    "max_height": 600
  },
  "webkit": {
    "plugin": true
  }
}

기본 형식

package.json 파일의 형식은 JSON 형식을 따라야 합니다.

필수 항목

각 패키지에는 아래 항목에 패키지 설명 파일에 반드시 들어가야 합니다.

main

(string) nw.js가 시작시 먼저 표시할 페이지를 정의합니다.

여기에 URL 주소를 입력하거나 그냥 파일 이름(index.html 등)을 입력하거나, 아니면 경로를 입력하면 됩니다. (상대 경로 지정 시 기준은 package.json 파일입니다.)

반드시 참고해야 할 사항이 있다면, 파일이름 이후에 파라미터가 들어가면(index.html?foo=bar 등) 안됩니다. 이유는 URL 방식이 아닐 경우 순수 파일 경로로 지정하게 되기 때문입니다. (예를 들면, index.html?foo=bar/baz 경로는 named index.html?foo=bar 디렉터리의 baz 파일로 간주됩니다.) 이로 인해 뜻하지 않은 경로 설정이 될 수도 있습니다. 만약 내부 경로에 파라미터를 보내고 싶다면, [앱 프로토콜](App protocol) 을 이용한 URL 방식으로 정의하세요.

name

(string) 패키지를 식별할 이름입니다. 반드시 유일해야 하며, 소문자와 숫자로 공백이 없어야 합니다. ".", "_", "-" 문자도 들어갈 수 있으며 이 외 문자는 무시됩니다.

name 항목은 반드시 nw.js 로부터 전역으로 유일해야 앱 데이터가 name 항목 폴더로 중복 없이 저장됩니다.

기능 조정 항목

해당 항목들은 nw.js 에서 메인 윈도우를 제어하는 방법을 제공하는 항목들입니다.

nodejs

(boolean) nodejs 항목을 false 로 지정 시 앱 내에 node.js 기능을 제거합니다.

node-main

v0.3.1 부터 지원

(string) node.js 스크립트 파일을 지정합니다. 이는 Node 컨텍스트 상에서 최초로 실행됩니다. 이 스크립트는 보통 node.js 바이너리와 같은 런타임 환경에서 동작되는데, v0.3.3 부터는 윈도우 초기화 전에 스크립트가 실행됩니다. 자세한 내용은 여기를 참고하세요.

single-instance

기본적으로 nw.js 앱은 패키지당 한 인스턴스만 허용합니다. 즉, 중복 실행을 허용하지 않습니다([앱을 패키징하고 배포하기](How to package and distribute your apps) 화면을 참고하세요.). 만약 패키지 하나에 중복 실행을 허용하고자 한다면 이 항목을 false로 지정하면 됩니다. v0.10.0-rc1 버전부터는 패키지가 풀린 폴더를 통해 실행하여도 적용됩니다.

window

(object) 윈도우 화면을 제어하는 방법을 정의합니다. Window 하위항목 을 참고하세요.

webkit

(object) 웹킷 엔진의 기능을 키거나 끄는 방법을 정의합니다. WebKit 하위항목 을 참고하세요.

user-agent

since v0.3.7

(string) HTTP 요청에 사용하는 User-Agent 항목을 지정한 값으로 덮습니다. 아래 치환자를 사용할 수 있습니다.

  • %name: 매니페스트 name 항목을 나타냅니다.
  • %ver: 매니페스트의 가능한 version 항목을 나타냅니다.
  • %nwver: nw.js 버전을 명시합니다.
  • %webkit_ver: 웹킷 엔진 버전을 명시합니다.
  • %osinfo: 브라우저의 사용자 에이전트에 나타나는 OS와 CPU 종류를 열거하는 방식과 동일하게 명시합니다.

node-remote

since v0.3.7

(string) 원격상의 페이지에서 node 기능을 허용할 항목을 정의하는 하목입니다. 반드시 해당 항목에 사이트가 포함되어야 해당 페이지 안의 node 기능이 작동됩니다. 이 형식은 "프록시 건너뛰기 규칙" 형식과 동일합니다.

이 규칙 세트는 , 또는 ; 문자로 복수를 구분합니다. 아래와 같은 규칙 정의가 가능합니다.

  // (1) [ URL_SCHEME "://" ] HOSTNAME_PATTERN [ ":" <port> ]
  //
  //   HOSTNAME_PATTERN 에 일치하는 모든 호스트 이름.
  //
  //   예제:
  //     "foobar.com", "*foobar.com", "*.foobar.com", "*foobar.com:99",
  //     "https://x.*.y.com:99"
  //
  // (2) "." HOSTNAME_SUFFIX_PATTERN [ ":" PORT ]
  //
  //   도메인 접미사와 매칭
  //
  //   Examples:
  //     ".google.com", ".com", "http://.google.com"
  //
  // (3) [ SCHEME "://" ] IP_LITERAL [ ":" PORT ]
  //
  //   URL 주소에 IP 주소 매칭
  //
  //   실질적으로 (1)의 방법과 비슷하지만,
  //   IP 주소 구조를 표준화하여 검사한다는 점에서 다릅니다. 예를 들면,
  //   "[0:0:0::1]" 이라고 입력 시 IPv6 표준화에 의해
  //   "[::1]" 이 들어와도 내부적으로 수용해 줍니다.
  //
  //   Examples:
  //     "127.0.1", "[0:0::1]", "[::1]", "http://[::1]:99"
  //
  // (4)  IP_LITERAL "/" PREFIX_LENGHT_IN_BITS
  //
  //   IP 주소와 지정된 범위를 검사하는 식입니다.
  //   IP 주소는 CIDR 범위 표준에 의해 검사됩니다.
  //
  //   Examples:
  //     "192.168.1.1/16", "fefe:13::abc/33".
  //
  // (5)  "<local>"
  //
  //   내부 주소인지 검사합니다. "<local>" 이라 함은,
  //   다음과 같은 주소가 모두 매칭됩니다: "127.0.0.1", "::1", "localhost".

chromium-args

since v0.4.0

(문자열) 크로미움(컨텐트 쉘)의 명령 인자를 지정합니다. Specify chromium (content shell) command line arguments. It will be useful if you want to distribute the app with some custom chromium args. For example, if you want to disable the GPU accelerated video display, just add "chromium-args" : "--disable-accelerated-video". If you want to add multiple arguments, separate each two arguments by space. This field can take a number of flags in one argument as well, via enclosing them in single quotation marks.

A list of Chromium's command line arguments is available at http://peter.sh/experiments/chromium-command-line-switches/

js-flags

since v0.4.1

(string) Specify the flags passed to JS engine(v8). e.g. turn on Harmony Proxies and Collections feature:

{
  "name": "nw-demo",
  "main": "index.html",
  "js-flags": "--harmony_proxies --harmony_collections"
}

inject-js-start / inject-js-end

since v0.9.0 and v0.8.5

(string) a local filename, relative to the application path, used to specify a JavaScript file to inject to the window. inject-js-start: The injecting JavaScript code is to be executed after any files from css, but before any other DOM is constructed or any other script is run; inject-js-end: The injecting JavaScript code is to be executed after the document object is loaded, before onload event is fired. This is mainly to be used as an option of Window.open() to inject JS in a new window.

additional_trust_anchors

since v0.11.1

containing a list of PEM-encoded certificates (i.e. "-----BEGIN CERTIFICATE-----\n...certificate data...\n-----END CERTIFICATE-----\n").
These certificates are used as additional root certificates for validation, to allow connecting to services using a self-signed certificate or certificates issued by custom CAs.

snapshot

since v0.4.2

(string) Specify the path to the snapshot file to be loaded with the application. The snapshot file contains compiled code of your application. See Protect JavaScript source code with v8 snapshot.

dom_storage_quota

since v0.6.1

(int) Number of mega bytes for the quota of the DOM storage. The suggestion is to put double the value you want.

no-edit-menu

since v0.7.3

(boolean) whether the default Edit menu should be disabled on Mac OS X. The default value is false. Only effective on Mac OS X. This is a workaround for a feature request and is expected to be replaced by something else soon

Window Subfields

title

(string) the default title of window created by node-webkit, it's very useful if you want to show your own title when the app is starting.

width/height

(int) the initial width/height of the main window.

toolbar

(boolean) should the navigation toolbar be showed.

icon

(string) path to window's icon

position

(string) be null or center or mouse, controls where window will be put

min_width/min_height

(int) minimum width/height of window

max_width/max_height

(int) maximum width/height of window

as_desktop

(boolean) show as desktop background window under X11 environment

resizable

(boolean) whether window is resizable (available after node-webkit v0.3.0)

always-on-top

since v0.3.4

(boolean) whether the window should always stay on top of other windows.

visible-on-all-workspaces

since v0.11.3

(boolean) whether the window should be visible on all workspaces simultaneously (on platforms that support multiple workspaces, currently Mac OS X and Linux).

fullscreen

since v0.3.0

(boolean) whether window is fullscreen

show_in_taskbar

since v0.9.2

(boolean) whether the window is shown in taskbar or dock. The default is true.

frame

since v0.3.0

(boolean) specify it to false to make the window frameless

show

since v0.3.0

(boolean) specify it to false if you want your app to be hidden on startup

kiosk

since v0.3.1

(boolean) whether to use Kiosk mode. In Kiosk mode, the app will be fullscreen and try to prevent users from leaving the app, so you should remember to provide a way in app to leave Kiosk mode. This mode is mainly used for presentation on public displays

transparent

since v0.11.2

(boolean) whether to turn on transparent window mode. The default is false.

_control the transparency with rgba background value in CSS. Use command line argument --disable-transparency to disable this feature completely. There is experimental support for "click-through" on the transparent region: add --disable-gpu argument to the command line. See the discussion here: https://github.com/rogerwang/node-webkit/issues/132 _

WebKit Subfields

The following fields require node-webkit >= v0.3.0.

plugin

(boolean) whether to load external browser plugins like Flash, default to false.

java

(boolean) whether to load Java applets, default to false.

page-cache

(boolean) whether to enable page cache, default to false.

Other Fields

The Packages/1.0 standard specifies many other fields package.json should provide. currently we don't make use of them, but you provide them still.

description

a brief description of the package. By convention, the first sentence (up to the first ". ") should be usable as a package title in listings.

version

a version string conforming to the Semantic Versioning requirements.

keywords

an Array of string keywords to assist users searching for the package in catalogs.

maintainers

Array of maintainers of the package. Each maintainer is a hash which must have a "name" property and may optionally provide "email" and "web" properties. For example:

"maintainers":[ {
   "name": "Bill Bloggs",
   "email": "billblogs@bblogmedia.com",
   "web": "http://www.bblogmedia.com",
}]

contributors

an Array of hashes each containing the details of a contributor. Format is the same as for author. By convention, the first contributor is the original author of the package.

bugs

URL for submitting bugs. Can be mailto or http.

licenses

array of licenses under which the package is provided. Each license is a hash with a "type" property specifying the type of license and a url property linking to the actual text. If the license is one of the official open source licenses the official license name or its abbreviation may be explicated with the "type" property. If an abbreviation is provided (in parentheses), the abbreviation must be used.

"licenses": [
   {
       "type": "GPLv2",
       "url": "http://www.example.com/licenses/gpl.html",
   }
]

repositories

Array of repositories where the package can be located. Each repository is a hash with properties for the "type" and "url" location of the repository to clone/checkout the package. A "path" property may also be specified to locate the package in the repository if it does not reside at the root. For example:

"repositories": [
       {
            "type": "git", 
            "url": "http://github.com/example.git",
            "path": "packages/mypackage"
       }
]
Clone this wiki locally