Skip to content

Commit

Permalink
Merge pull request #2 from minh-rakuten/feature/MiniAppInterface_Uniq…
Browse files Browse the repository at this point in the history
…ueId

Feature/interface_uniqueID
  • Loading branch information
Climbatize authored Apr 21, 2020
2 parents 5778148 + c856d0e commit cc6e3fd
Show file tree
Hide file tree
Showing 9 changed files with 1,174 additions and 31 deletions.
1 change: 0 additions & 1 deletion js-miniapp-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@
},
"homepage": "https://github.com/rakutentech/js-miniapp#readme"
}

2 changes: 1 addition & 1 deletion js-miniapp-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"clean": "gts clean",
"compile": "tsc -p .",
"prebuild": "npm run clean && npm run lint",
"build": "npm run clean && npm run lint && tsc -p . && npm run test",
"buildSdk": "gts check && tsc -p . && npm run test",
"fix": "gts fix",
"test": "mocha -r ts-node/register tests/**/*.spec.ts --reporter mocha-junit-reporter --reporter-options mochaFile=./test-results/mocha/results.xml",
"coverage": "nyc npm test",
Expand Down
10 changes: 6 additions & 4 deletions js-miniapp-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** This is a description of the foo function. */
function foo() {
console.log('foo');
}
import { MiniApp } from './miniapp';

const miniAppInstance = new MiniApp();

// tslint:disable-next-line:no-default-export
export default miniAppInstance;
17 changes: 17 additions & 0 deletions js-miniapp-sdk/src/miniapp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* A module layer for webapps and mobile native interaction.
*/
interface MiniAppInterface {
/** @returns The Promise of provided id of mini app from injected side. */
getUniqueId(): Promise<string>;
}

/* tslint:disable:no-any */
export class MiniApp implements MiniAppInterface {
getUniqueId(): Promise<string> {
return (window as any).MiniAppBridge.getUniqueId();
}
}

// tslint:disable-next-line:no-default-export
export default MiniApp;
14 changes: 7 additions & 7 deletions js-miniapp-sdk/tests/test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

describe('sample test', () => {
it('sample add', () => {
expect(2 + 2).to.equal(4);
});
});
// import { expect } from 'chai';
//
// describe('sample test', () => {
// it('sample add', () => {
// expect(2 + 2).to.equal(4);
// });
// });
5 changes: 3 additions & 2 deletions js-miniapp-sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build"
"outDir": "build",
"module": "es2015",
"declaration": true
},
"include": [
"src/**/*.ts",
"tests/**/*.ts"
]
}

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"private": true,
"workspaces": ["js-miniapp-sdk", "js-miniapp-sample", "js-miniapp-bridge"],
"workspaces": [
"js-miniapp-sdk",
"js-miniapp-sample",
"js-miniapp-bridge"
],
"scripts": {
"sdk": "yarn workspace js-miniapp-sdk",
"sample": "yarn workspace js-miniapp-sample",
"bridge": "yarn workspace js-miniapp-bridge"
}
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"strict": false,
"target": "ES5",
"lib": ["dom"],
"esModuleInterop": true
}
}
Loading

0 comments on commit cc6e3fd

Please sign in to comment.