From 8a2d56048256ed2b4025ed8784959b1f1335c975 Mon Sep 17 00:00:00 2001 From: Cherie Williams Date: Wed, 8 Jun 2016 17:36:14 -0700 Subject: [PATCH 1/2] Update README for loader.js changes in SDK 3.13 --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 26d5f93..7d9949f 100755 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Clay will by default automatically handle the 'showConfiguration' and 'webviewcl **Clay is still in early development and may be missing some features. We would love your feedback! Pease submit any ideas or features via GitHub Issues.** +> NOTE: Prior to SDK 3.13, require paths were handled in a non-standard way. When requiring modules, the name of the module was sufficient (ie. `require('clay')`). However, with the release of SDK 3.13, the require paths changed so that you now have to require the module by using its path relative to the file it's being required in. This means requiring the Clay module now is done in app.js by using `require('./clay')`. + # Getting Started (SDK) Clay will eventually be built into the Pebble SDK. However, while it is still in beta you will need to follow the steps shown below: @@ -16,8 +18,8 @@ Clay will eventually be built into the Pebble SDK. However, while it is still in 5. Your `app.js` file needs to `require` clay and your config file, then be initialized. Clay will by default automatically handle the 'showConfiguration' and 'webviewclosed' events. Copy and paste the following into the top of your `app.js` file: ```javascript - var Clay = require('clay'); - var clayConfig = require('config.json'); + var Clay = require('./clay'); + var clayConfig = require('./config.json'); var clay = new Clay(clayConfig); ``` 6. Add `configurable` to the `capabilities` array in your `appinfo.json`. @@ -38,8 +40,8 @@ NOTE these are similar to using the SDK but instead of a data file called config 4. Your `app.js` file needs to `require` clay and your config file, then be initialized. Clay will by default automatically handle the 'showConfiguration' and 'webviewclosed' events. Copy and paste the following into the top of your `app.js` file: ```javascript - var Clay = require('clay'); - var clayConfig = require('config'); + var Clay = require('./clay'); + var clayConfig = require('./config'); var clay = new Clay(clayConfig); ``` 5. Next is the fun part - creating your config page. Edit your `config.js` file to build a layout of elements as described in the sections below. @@ -1058,8 +1060,8 @@ Components are simple objects with the following properties. Components must be registered before the config page is built. The easiest way to do this is in your `app.js` after you have initialized Clay: ```javascript -var Clay = require('clay'); -var clayConfig = require('config.json'); +var Clay = require('./clay'); +var clayConfig = require('./config.json'); var clay = new Clay(clayConfig); clay.registerComponent(require('./my-custom-component')); From ecac278f63065289ad89ff31514c0703ff141569 Mon Sep 17 00:00:00 2001 From: Cherie Williams Date: Thu, 9 Jun 2016 14:19:54 -0700 Subject: [PATCH 2/2] Make SDK 3.13 notice a header & add error sample --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d9949f..a986082 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,17 @@ Clay will by default automatically handle the 'showConfiguration' and 'webviewcl **Clay is still in early development and may be missing some features. We would love your feedback! Pease submit any ideas or features via GitHub Issues.** -> NOTE: Prior to SDK 3.13, require paths were handled in a non-standard way. When requiring modules, the name of the module was sufficient (ie. `require('clay')`). However, with the release of SDK 3.13, the require paths changed so that you now have to require the module by using its path relative to the file it's being required in. This means requiring the Clay module now is done in app.js by using `require('./clay')`. +# SDK 3.13 Changes +Prior to SDK 3.13, `require` paths were handled in a non-standard way. When requiring modules, the name of the module was sufficient (ie. `require('clay')`). However, with the release of SDK 3.13, the require paths changed so that you now have to require the module by using its path relative to the file it's being required in. This means requiring the Clay module now is done in app.js by using `require('./clay')`. An incorrect path would result in an error similar to this: + ``` + [14:16:03] javascript> JavaScript Error: + Error: Cannot find module 'clay' + at Object.loader.require (loader.js:66:11) + at _require.require (loader.js:54:48) + at Object.loader (src/js/app.js:1:1) + at _require (loader.js:57:10) + at Object.loader.require (loader.js:69:10) + ``` # Getting Started (SDK)