diff --git a/Makefile b/Makefile
index 4257b5c..de7f316 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,33 @@
NAME = holo_hosting_comb
+build/index.js: src/index.ts
+ npx tsc --esModuleInterop --lib es2015,dom --outDir ./build ./src/index.ts
+
dist/$(NAME).js: src/index.js
npx webpack --mode production --output-filename $(NAME).js ./src/index.js
+docs/index.html: build/index.js
+ npx jsdoc --verbose -c ./docs/.jsdoc.json --destination ./docs build/index.js
+
+
.PHONY: src build dist docs watch-docs
build: dist/$(NAME).js
dist: dist/$(NAME).js
+docs: docs/index.html
test:
npx mocha --recursive ./tests
test-debug:
LOG_LEVEL=silly npx mocha --recursive ./tests
-
test-unit:
LOG_LEVEL=silly npx mocha ./tests/unit/
+test-integration:
+ LOG_LEVEL=silly npx mocha ./tests/integration/
+
+watch-docs:
+ npx chokidar -d 3000 'src/**/*.ts' -c "make --no-print-directory docs" 2> /dev/null
+
+clean-docs:
+ git clean -df ./docs
diff --git a/README.md b/README.md
index 840b274..1d48cd3 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,31 @@ COMB is a library that facilitates the calls between the parent window (hApp UI)
Used by `Holo Chaperone` and `Holo Hosting Web SDK`.
+## Architecture
+
+We use `Postmate` to set up a message tunnel between the parent and child frames.
+
+### API
+
+```javascript
+const child = await comb.connect( url );
+
+await child.set("mode", mode );
+await child.run("signIn");
+```
+
+```javascript
+const parent = comb.listen({
+ "signIn": async function ( ...args ) {
+ if ( this.mode === DEVELOP )
+ ...
+ else
+ ...
+ return response;
+ },
+});
+```
+
## Features
- Parent/Child communication line
diff --git a/html/chaperon/index.html b/html/chaperon/index.html
index 10e62e7..a2479a3 100644
--- a/html/chaperon/index.html
+++ b/html/chaperon/index.html
@@ -1,2 +1,20 @@
+
+
Chaperon!
+
+
diff --git a/html/happ/index.html b/html/happ/index.html
index f7db6c3..bca0559 100644
--- a/html/happ/index.html
+++ b/html/happ/index.html
@@ -1,14 +1,49 @@
+
+
hApp!
Hello World
diff --git a/package-lock.json b/package-lock.json
index 224d23f..a693f94 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,18 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+ "@babel/parser": {
+ "version": "7.6.4",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.4.tgz",
+ "integrity": "sha512-D8RHPW5qd0Vbyo3qb+YjO5nvUVRTXFLQ/FsDxJU2Nqz4uB5EnUN0ZQSEYpvTIbRuttig1XbHWU5oMeQwQSAA+A==",
+ "dev": true
+ },
+ "@types/node": {
+ "version": "12.11.1",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.11.1.tgz",
+ "integrity": "sha512-TJtwsqZ39pqcljJpajeoofYRfeZ7/I/OMUQ5pR4q5wOKf2ocrUvBAZUMhWsOvKx3dVc/aaV5GluBivt0sWqA5A==",
+ "dev": true
+ },
"@webassemblyjs/ast": {
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
@@ -555,6 +567,12 @@
}
}
},
+ "braintree-jsdoc-template": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/braintree-jsdoc-template/-/braintree-jsdoc-template-3.3.0.tgz",
+ "integrity": "sha512-sjkq3w1Dt1HO/yKa2WzFpsi+cuO5qv0kD2kHl6T0amdrnQX9T7sQBBde56iYR1dzXFYMXyh7ti/662v9/00bGw==",
+ "dev": true
+ },
"brorand": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
@@ -713,6 +731,15 @@
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"dev": true
},
+ "catharsis": {
+ "version": "0.8.11",
+ "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.11.tgz",
+ "integrity": "sha512-a+xUyMV7hD1BrDQA/3iPV7oc+6W26BgVJO05PGEoatMyIuPScQKsde6i3YorWX1qs+AZjnJ18NqdKoCtKiNh1g==",
+ "dev": true,
+ "requires": {
+ "lodash": "^4.17.14"
+ }
+ },
"chai": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",
@@ -775,6 +802,143 @@
"upath": "^1.1.1"
}
},
+ "chokidar-cli": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/chokidar-cli/-/chokidar-cli-2.0.0.tgz",
+ "integrity": "sha512-E3N0WlV1L4c60cs9owdGQpZXY5obZya5Xds7+sF6GTVWWZKwqlq9QG7c2ESPNtjS+5QusAg8VmUEnOnAtZYNcg==",
+ "dev": true,
+ "requires": {
+ "bluebird": "3.5.5",
+ "chokidar": "3.0.2",
+ "lodash": "4.17.15",
+ "yargs": "13.3.0"
+ },
+ "dependencies": {
+ "anymatch": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
+ "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
+ "dev": true,
+ "requires": {
+ "normalize-path": "^3.0.0",
+ "picomatch": "^2.0.4"
+ }
+ },
+ "binary-extensions": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz",
+ "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==",
+ "dev": true
+ },
+ "bluebird": {
+ "version": "3.5.5",
+ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz",
+ "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==",
+ "dev": true
+ },
+ "braces": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
+ "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
+ "dev": true,
+ "requires": {
+ "fill-range": "^7.0.1"
+ }
+ },
+ "chokidar": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.0.2.tgz",
+ "integrity": "sha512-c4PR2egjNjI1um6bamCQ6bUNPDiyofNQruHvKgHQ4gDUP/ITSVSzNsiI5OWtHOsX323i5ha/kk4YmOZ1Ktg7KA==",
+ "dev": true,
+ "requires": {
+ "anymatch": "^3.0.1",
+ "braces": "^3.0.2",
+ "fsevents": "^2.0.6",
+ "glob-parent": "^5.0.0",
+ "is-binary-path": "^2.1.0",
+ "is-glob": "^4.0.1",
+ "normalize-path": "^3.0.0",
+ "readdirp": "^3.1.1"
+ }
+ },
+ "fill-range": {
+ "version": "7.0.1",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
+ "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
+ "dev": true,
+ "requires": {
+ "to-regex-range": "^5.0.1"
+ }
+ },
+ "fsevents": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.1.tgz",
+ "integrity": "sha512-4FRPXWETxtigtJW/gxzEDsX1LVbPAM93VleB83kZB+ellqbHMkyt2aJfuzNLRvFPnGi6bcE5SvfxgbXPeKteJw==",
+ "dev": true,
+ "optional": true
+ },
+ "glob-parent": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz",
+ "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==",
+ "dev": true,
+ "requires": {
+ "is-glob": "^4.0.1"
+ }
+ },
+ "is-binary-path": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
+ "dev": true,
+ "requires": {
+ "binary-extensions": "^2.0.0"
+ }
+ },
+ "is-number": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
+ "dev": true
+ },
+ "readdirp": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz",
+ "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==",
+ "dev": true,
+ "requires": {
+ "picomatch": "^2.0.4"
+ }
+ },
+ "to-regex-range": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+ "dev": true,
+ "requires": {
+ "is-number": "^7.0.0"
+ }
+ },
+ "yargs": {
+ "version": "13.3.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz",
+ "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==",
+ "dev": true,
+ "requires": {
+ "cliui": "^5.0.0",
+ "find-up": "^3.0.0",
+ "get-caller-file": "^2.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^2.0.0",
+ "set-blocking": "^2.0.0",
+ "string-width": "^3.0.0",
+ "which-module": "^2.0.0",
+ "y18n": "^4.0.0",
+ "yargs-parser": "^13.1.1"
+ }
+ }
+ }
+ },
"chownr": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz",
@@ -1269,6 +1433,12 @@
}
}
},
+ "entities": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz",
+ "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==",
+ "dev": true
+ },
"env-variable": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz",
@@ -2799,6 +2969,51 @@
}
}
},
+ "js2xmlparser": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.0.tgz",
+ "integrity": "sha512-WuNgdZOXVmBk5kUPMcTcVUpbGRzLfNkv7+7APq7WiDihpXVKrgxo6wwRpRl9OQeEBgKCVk9mR7RbzrnNWC8oBw==",
+ "dev": true,
+ "requires": {
+ "xmlcreate": "^2.0.0"
+ }
+ },
+ "jsdoc": {
+ "version": "3.6.3",
+ "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.3.tgz",
+ "integrity": "sha512-Yf1ZKA3r9nvtMWHO1kEuMZTlHOF8uoQ0vyo5eH7SQy5YeIiHM+B0DgKnn+X6y6KDYZcF7G2SPkKF+JORCXWE/A==",
+ "dev": true,
+ "requires": {
+ "@babel/parser": "^7.4.4",
+ "bluebird": "^3.5.4",
+ "catharsis": "^0.8.11",
+ "escape-string-regexp": "^2.0.0",
+ "js2xmlparser": "^4.0.0",
+ "klaw": "^3.0.0",
+ "markdown-it": "^8.4.2",
+ "markdown-it-anchor": "^5.0.2",
+ "marked": "^0.7.0",
+ "mkdirp": "^0.5.1",
+ "requizzle": "^0.2.3",
+ "strip-json-comments": "^3.0.1",
+ "taffydb": "2.6.2",
+ "underscore": "~1.9.1"
+ },
+ "dependencies": {
+ "escape-string-regexp": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
+ "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",
+ "dev": true
+ },
+ "strip-json-comments": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz",
+ "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==",
+ "dev": true
+ }
+ }
+ },
"json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
@@ -2826,6 +3041,15 @@
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
"dev": true
},
+ "klaw": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz",
+ "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "^4.1.9"
+ }
+ },
"kuler": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz",
@@ -2844,6 +3068,15 @@
"invert-kv": "^2.0.0"
}
},
+ "linkify-it": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz",
+ "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==",
+ "dev": true,
+ "requires": {
+ "uc.micro": "^1.0.1"
+ }
+ },
"loader-runner": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz",
@@ -2956,6 +3189,31 @@
"object-visit": "^1.0.0"
}
},
+ "markdown-it": {
+ "version": "8.4.2",
+ "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz",
+ "integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==",
+ "dev": true,
+ "requires": {
+ "argparse": "^1.0.7",
+ "entities": "~1.1.1",
+ "linkify-it": "^2.0.0",
+ "mdurl": "^1.0.1",
+ "uc.micro": "^1.0.5"
+ }
+ },
+ "markdown-it-anchor": {
+ "version": "5.2.5",
+ "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.2.5.tgz",
+ "integrity": "sha512-xLIjLQmtym3QpoY9llBgApknl7pxAcN3WDRc2d3rwpl+/YvDZHPmKscGs+L6E05xf2KrCXPBvosWt7MZukwSpQ==",
+ "dev": true
+ },
+ "marked": {
+ "version": "0.7.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz",
+ "integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==",
+ "dev": true
+ },
"md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@@ -2967,6 +3225,12 @@
"safe-buffer": "^5.1.2"
}
},
+ "mdurl": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
+ "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=",
+ "dev": true
+ },
"mem": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz",
@@ -3592,6 +3856,12 @@
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=",
"dev": true
},
+ "picomatch": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz",
+ "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==",
+ "dev": true
+ },
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
@@ -3837,6 +4107,15 @@
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true
},
+ "requizzle": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz",
+ "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==",
+ "dev": true,
+ "requires": {
+ "lodash": "^4.17.14"
+ }
+ },
"resolve-cwd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz",
@@ -4344,6 +4623,12 @@
"has-flag": "^3.0.0"
}
},
+ "taffydb": {
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz",
+ "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=",
+ "dev": true
+ },
"tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
@@ -4497,6 +4782,24 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
+ "typescript": {
+ "version": "3.6.4",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz",
+ "integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==",
+ "dev": true
+ },
+ "uc.micro": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
+ "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==",
+ "dev": true
+ },
+ "underscore": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
+ "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==",
+ "dev": true
+ },
"union-value": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
@@ -4865,6 +5168,12 @@
"async-limiter": "~1.0.0"
}
},
+ "xmlcreate": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.1.tgz",
+ "integrity": "sha512-MjGsXhKG8YjTKrDCXseFo3ClbMGvUD4en29H2Cev1dv4P/chlpw6KdYmlCWDkhosBVKRDjM836+3e3pm1cBNJA==",
+ "dev": true
+ },
"xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
diff --git a/package.json b/package.json
index 1d792e4..d0355c5 100644
--- a/package.json
+++ b/package.json
@@ -9,19 +9,24 @@
"author": "Holo Inc.",
"license": "ISC",
"repository": {
- "type" : "git",
- "url" : "https://github.com/Holo-Host/chaperon/"
+ "type": "git",
+ "url": "https://github.com/Holo-Host/chaperon/"
},
"dependencies": {
"postmate": "^1.5.1"
},
"devDependencies": {
+ "@types/node": "^12.11.1",
"@whi/stdlog": "^0.3.0",
"axios": "^0.19.0",
+ "braintree-jsdoc-template": "^3.3.0",
"chai": "^4.2.0",
+ "chokidar-cli": "^2.0.0",
+ "jsdoc": "^3.6.3",
"mocha": "^6.2.1",
"node-fetch": "^2.6.0",
"puppeteer": "^1.20.0",
+ "typescript": "^3.6.4",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9"
}
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 0000000..1d22b73
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,81 @@
+
+import Postmate from 'postmate';
+
+class Child {
+
+ msg_count : number;
+ responses : object;
+ msg_bus : any;
+
+ constructor ( url ) {
+
+ // if ( debug )
+ // Postmate.debug = true;
+ this.msg_count = 0;
+ this.responses = {};
+
+ this.init();
+ }
+
+ async init () {
+ const chaperon = await new Postmate({
+ "container": document.body,
+ "url": "http://localhost:4532/index.html",
+ "classListArray": ["chaperon-frame"],
+ });
+
+ chaperon.on('response', ( data ) => {
+ let [k,v] = data;
+ this.responses[ k ]( v );
+ });
+
+ this.msg_bus = chaperon;
+
+ return chaperon;
+ }
+
+ set ( key, value ) {
+ null;
+ }
+
+ run ( method, data ) {
+ let msg_id = this.msg_count++;
+
+ this.msg_bus.call( method, [ msg_id, data ] );
+
+ return new Promise((f,r) => {
+ this.responses[msg_id] = f;
+
+ // TODO: make a timout that calls r
+ });
+ }
+}
+
+
+class Parent {
+
+ constructor ( methods ) {
+ null;
+
+ // if ( debug )
+ // Postmate.debug = true;
+ }
+
+ async init () {
+ const parent = await new Postmate.Model({
+ "init": async function ( data ) {
+ const [msg_id, mode] = data;
+
+ console.log( mode );
+
+ parent.emit("response", [ msg_id, true ]);
+ }
+ })
+ }
+
+}
+
+
+// const initialized = await request("init", "development");
+
+// console.log( initialized );
diff --git a/tests/integration/test_comb.js b/tests/integration/test_comb.js
new file mode 100644
index 0000000..89b71f4
--- /dev/null
+++ b/tests/integration/test_comb.js
@@ -0,0 +1,50 @@
+const path = require('path');
+const log = require('@whi/stdlog')(path.basename( __filename ), {
+ level: process.env.LOG_LEVEL || 'fatal',
+});
+
+const fs = require('fs');
+const assert = require('assert');
+const axios = require('axios');
+const expect = require('chai').expect;
+const puppeteer = require('puppeteer');
+
+const http_servers = require('../setup.js');
+
+
+describe("Testing COMB", function() {
+
+ it('should insert Chaperon iframe into hApp window', async function () {
+ const setup = http_servers();
+ log.debug("Setup config: %s", setup.ports );
+ const browser = await puppeteer.launch();
+
+ try {
+ const happ_url = `http://localhost:${setup.ports.happ}/index.html`;
+ const chap_url = `http://localhost:${setup.ports.chaperon}/index.html`;
+
+ const page = await browser.newPage();
+
+ page.on("console", async ( msg ) => {
+ log.debug("From puppeteer: console.log( %s )", msg.text() );
+ });
+
+ log.info("Go to: %s", happ_url );
+ await page.goto( happ_url, { "waitUntil": "networkidle0" } );
+
+ const parent = page.mainFrame();
+ const frames = parent.childFrames();
+ log.debug("Frames: %s", frames.length );
+
+ expect( frames.length ).to.equal( 1 );
+
+ const chap_frame = frames[0];
+
+ expect( frames[0].url() ).to.equal( chap_url );
+ } finally {
+ await browser.close();
+ await setup.close();
+ }
+ });
+
+});
diff --git a/tests/unit/test_puppeteer.js b/tests/integration/test_puppeteer.js
similarity index 100%
rename from tests/unit/test_puppeteer.js
rename to tests/integration/test_puppeteer.js
diff --git a/tests/unit/test_setup.js b/tests/integration/test_setup.js
similarity index 100%
rename from tests/unit/test_setup.js
rename to tests/integration/test_setup.js
diff --git a/tests/unit/test_comb.js b/tests/unit/test_comb.js
index 7a3a13b..170af2b 100644
--- a/tests/unit/test_comb.js
+++ b/tests/unit/test_comb.js
@@ -7,70 +7,13 @@ const fs = require('fs');
const assert = require('assert');
const axios = require('axios');
const expect = require('chai').expect;
-const puppeteer = require('puppeteer');
-const http_servers = require('../setup.js');
+const comb = require('../../build/index.js');
-describe("Testing COMB", function() {
+describe("Testing COMB", () => {
- it('should insert Chaperon iframe into hApp window', async function () {
- // const setup = http_servers();
- // log.debug("Setup config: %s", setup );
-
- // try {
- // const happ_url = `http://localhost:${setup.ports.happ}/index.html`;
- // log.info("Fetch: %s", happ_url );
- // const happ_resp = await axios.get( happ_url );
-
- // expect( happ_resp.status ).to.equal( 200 );
-
- // const chap_url = `http://localhost:${setup.ports.chaperon}/index.html`;
- // log.info("Fetch: %s", chap_url );
- // const chap_resp = await axios.get( chap_url );
-
- // expect( chap_resp.status ).to.equal( 200 );
- // } finally {
- // await setup.close();
- // }
-
- const setup = http_servers();
- log.debug("Setup config: %s", setup.ports );
- const browser = await puppeteer.launch();
-
- try {
- const happ_url = `http://localhost:${setup.ports.happ}/index.html`;
- const chap_url = `http://localhost:${setup.ports.chaperon}/index.html`;
-
- const page = await browser.newPage();
-
- log.info("Go to: %s", happ_url );
- await page.goto( happ_url );
-
- log.info("Add Chaperon iFrame: %s", chap_url );
- await page.evaluate(( url ) => {
- const container = document.createElement("div");
- container.innerHTML = ``;
-
- document.body.appendChild( container );
- }, chap_url );
-
- const parent = page.mainFrame();
- const frames = parent.childFrames();
- log.debug("Frames: %s", frames.length );
-
- expect( frames.length ).to.equal( 1 );
-
- const chap_frame = frames[0];
-
- await chap_frame.waitForNavigation();
-
- expect( frames[0].url() ).to.equal( chap_url );
-
- } finally {
- await browser.close();
- await setup.close();
- }
+ it('should insert Chaperon iframe into hApp window', async () => {
});
});
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 0000000..f8a96e4
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,9 @@
+
+module.exports = {
+ target: 'web',
+
+ // Assign 'module.exports' to the window variable
+ output: {
+ libraryTarget: 'window',
+ },
+};