-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88e40bd
commit 80ebbf1
Showing
12 changed files
with
559 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/postmate.min.js" | ||
integrity="sha256-QiOvVDY/8Oq7LftHYbaeDge2G+Jc2czsr19CtviluZw=" | ||
crossorigin="anonymous"></script> | ||
|
||
<h1>Chaperon!</h1> | ||
|
||
<script type="text/javascript"> | ||
(async function () { | ||
Postmate.debug = true; | ||
const parent = await new Postmate.Model({ | ||
"init": async function ( data ) { | ||
const [msg_id, mode] = data; | ||
console.log( mode ); | ||
|
||
parent.emit("response", [ msg_id, true ]); | ||
} | ||
}); | ||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,49 @@ | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/postmate.min.js" | ||
integrity="sha256-QiOvVDY/8Oq7LftHYbaeDge2G+Jc2czsr19CtviluZw=" | ||
crossorigin="anonymous"></script> | ||
|
||
<h1>hApp!</h1> | ||
|
||
<div id="main-content">Hello World</div> | ||
|
||
<script type="text/javascript"> | ||
window.addEventListener( "message", function ( event ) { | ||
console.log( event ); | ||
console.log( event.origin ); | ||
console.log( event.source ); | ||
console.log( event.data ); | ||
}); | ||
(async function () { | ||
|
||
Postmate.debug = true; | ||
const chaperon = await new Postmate({ | ||
"container": document.body, | ||
"url": "http://localhost:4532/index.html", | ||
"classListArray": ["chaperon-frame"], | ||
}); | ||
|
||
const responses = {}; | ||
|
||
chaperon.on('response', function ( data ) { | ||
let [k,v] = data; | ||
responses[ k ]( v ); | ||
}); | ||
|
||
let count = 0; | ||
function request ( method, data ) { | ||
let msg_id = count++; | ||
|
||
chaperon.call( method, [ msg_id, data ] ); | ||
|
||
return new Promise((f,r) => { | ||
responses[msg_id] = f; | ||
|
||
// TODO: make a timout that calls r | ||
}); | ||
} | ||
|
||
try { | ||
const initialized = await request("init", "development"); | ||
|
||
console.log( initialized ); | ||
} catch ( err ) { | ||
console.error( err ); | ||
} | ||
})(); | ||
</script> | ||
|
Oops, something went wrong.