diff --git a/_docs/asyncapi/css/main.css b/_docs/asyncapi/css/main.css new file mode 100644 index 00000000..e290f898 --- /dev/null +++ b/_docs/asyncapi/css/main.css @@ -0,0 +1,294 @@ +* { + box-sizing: border-box; +} + +html, body { + margin: 0; + padding: 0; + font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; + font-size: 14px; + line-height: 20px; + font-weight: 400; + -webkit-font-smoothing: antialiased; + font-smoothing: antialiased; +} + +.navigation { + position: fixed; + left: 0; + top: 0; + bottom: 0; + width: 300px; + background: #263238; + overflow: auto; + padding-bottom: 60px; +} + +.navigation__logo { + padding: 20px 10px; + margin-bottom: 10px; + background-color: #263238; + color: #fff; + text-align: center; + border-bottom: #212b31 2px solid; +} +.navigation__logo__image { + max-height: 100px; +} +.navigation__logo__name { + font-size: 18px; +} + +.navigation__header { + display: block; + color: #fff; + margin-top: 50px; + margin-bottom: 20px; + font-weight: bold; + font-size: 18px; + padding-left: 20px; +} + +.navigation__list { + list-style: none; + padding-left: 0; +} + +.navigation__list__item-text { + display: block; + color: #ccc; + text-decoration: none; + padding: 7px 7px 7px 20px; + font-size: 14px; +} + +.navigation__list__item-text--link:hover { + background-color: #3e515b; +} + +.navigation__list__item-text--link--active { + background-color: #3e515b; +} + +.navigation__list__item__topic-indicator { + display: inline-block; + width: 10px; + height: 10px; + border-radius: 3px; +} +.navigation__list__item__topic-indicator--publish { + background: #d4e157; +} +.navigation__list__item__topic-indicator--subscribe { + background: #039be5; +} +.navigation__list__item__topic-indicator--deprecated { + background: #ffa726; +} + +.documentation { + position: absolute; + left: 300px; + top: 0; + right: 0; + padding: 20px 40px; +} + +.info__terms-of-service__header { + font-size: 20px; +} + +.info__server__enum-list { + padding-left: 1em; + margin: 0; +} + +.security__header { + font-size: 20px; +} + +.section-header { + border-bottom: #333 2px solid; + padding-bottom: 10px; + margin: 40px 0; +} + +.topic { + margin-bottom: 60px; +} +.topic__header { + font-size: 20px; +} +.topic__header__operation-badge { + display: block; + float: left; + margin-top: -2px; + margin-right: 10px; +} + +.operation--indented { + padding-left: 15px; + border-left: #263238 2px solid; +} + +.operation-badge { + display: inline-block; + font-size: 12px; + border-radius: 5px; + padding: 3px 10px; + text-align: center; + text-transform: uppercase; +} + +.operation-badge--publish { + background: #d4e157; + color: #333; +} +.operation-badge--subscribe { + background: #039be5; + color: white; +} +.operation-badge--deprecated { + background: #ffa726; + color: white; +} + +.required-badge { + display: inline-block; + font-weight: bold; + font-size: 12px; + background-color: #666; + color: white; + border-radius: 3px; + padding: 0 5px; + margin-left: 5px; + float: right; +} + +.table { + margin: 0 0 40px 0; + width: 100%; + box-shadow: 0 1px 3px rgba(0,0,0,0.2); + border-spacing: 0; +} +.table__head__row { + font-weight: 900; + color: #ffffff; + background: #00796b; +} +.table__head__cell { + padding: 6px 12px; + text-align: left; +} +.table__body__row { + background: #f6f6f6; +} +.table__body__row:nth-of-type(odd) { + background: #e9e9e9; +} +.table__body__cell { + padding: 6px 12px; + vertical-align: top; +} +.table__body__cell p { + margin-top: 0; +} +.table__expand { + display: inline-block; + width: 0; + height: 0; + border-top: 5px solid transparent; + border-bottom: 5px solid transparent; + border-left: 7px solid black; + margin-right: 10px; + transition: .5s ease; + cursor: pointer; +} +.table__expand--open { + transform: rotate(90deg); +} +.table__body__row--with-nested .table--nested { + display: block; + max-height: 0; + overflow: hidden; + transition: max-height 1s ease; +} +.table__body__row--with-nested--expanded .table--nested { + max-height: 300px; +} +.table--nested { + margin: 0; + width: 100%; + box-shadow: none; + border-spacing: 0; + font-size: 13px; +} +.table--nested__header { + background-color: #37474f; + color: #eee; + font-weight: bold; + text-align: center; + padding: 5px 0; +} +.table--nested__head__row { + background-color: #455a64; + color: #eee; +} +.table--nested__head__cell { + width: 20%; +} +.table--nested__body__row { + background: #78909c; + color: #333; +} +.table--nested__body__row:nth-of-type(odd) { + background: #90a4ae; +} + +.tree-space { + display: inline-block; + width: 15px; +} +.tree-leaf { + display: inline-block; + position: relative; + width: 25px; +} +.tree-leaf::before { + content: ' '; + position: absolute; + top: -15px; + width: 10px; + height: 10px; + border-left: #aaa 1px solid; + border-bottom: #aaa 1px solid; + border-radius: 0 0 0 3px; +} + +.tags__tag { + display: inline-block; + background-color: #607d8b; + padding: 3px 7px; + border-radius: 5px; +} +.tags__no-tags { + font-style: italic; +} + +.message { + margin-bottom: 60px; +} + +.schema { + margin-bottom: 30px; +} + +code { + padding: 3px 5px; + background-color: #eee; + word-break: break-all; +} + +pre code { + display: block; +} diff --git a/asyncapi-todoc.txt b/asyncapi-todoc.txt new file mode 100644 index 00000000..455dec5a --- /dev/null +++ b/asyncapi-todoc.txt @@ -0,0 +1,33 @@ + + 187: user.direct.emit('$.invite', { + 188 channel: this.channel + 189 }); + + + + 485: this.emit('$.system.leave', { subject: this.objectify() }); + + 117: this.sync.emit('$.session.notify.chat.join', { subject: chat.objectify() }); + + 127: this.sync.emit('$.session.notify.chat.leave', { subject: chat.objectify() }); + + chat.emit('custom-event', {value: true}); + +chat.on('custom-event', (payload) => { + + // subscribe to the events on our sync chat and forward them + this.sync.on('$.session.notify.chat.join', (payload) => { + this.onJoin(payload.data.subject); + }); + + this.sync.on('$.session.notify.chat.leave', (payload) => { + this.onleave(payload.data.subject); + }); + + + this.on('$.system.leave', (payload) => { + this.userLeave(payload.sender.uuid); + }); + + +.on('$.invite') diff --git a/asyncapi.yml b/asyncapi.yml new file mode 100644 index 00000000..4405447d --- /dev/null +++ b/asyncapi.yml @@ -0,0 +1,88 @@ +asyncapi: "1.2.0" +info: + title: AsyncAPI Sample + version: "1.0.0" + x-logo: https://avatars0.githubusercontent.com/u/16401334?v=4&s=200 + description: | + This is a simple example of an _AsyncAPI_ document. + termsOfService: https://api.company.com/terms +baseTopic: '$' + +servers: + - url: pubsub.pubub.com + description: The PubNub server host that allows you to publish and subscribe. See https://www.pubnub.com/docs/pubnub-rest-api-documentation#publish-subscribe-publish-v1-via-get-get + scheme: wss + +topics: + invite: + publish: + summary: Invite another user to the chat. + description: Fired when a user invites another user to a chat. Contains the chat channel as the payload. + $ref: "#/components/messages/invite" + subscribe: + summary: This user was invited to a chat. + description: Fired when this client was invited to a chat. Contains the chat channel as the payload. + $ref: "#/components/messages/invite" + system.leave: + publish: + summary: When this user leaves a chat. + description: Fired when this user leaves a chat. Emitting this message lets other users know that you've intentionally left. + payload: + $ref: "#/components/schemas/subject" + subscribe: + summary: When another user leaves the chat. + description: Emits when another user leaves the chat. Keeps list of users in sync. + payload: + $ref: "#/components/schemas/subject" + session.notify.chat.join: + publish: + summary: Alert other subscribers of this session that a chat has been joined. + payload: + $ref: "#/components/schemas/subject" + subscribe: + summary: A new chat has been joined in this session. + payload: + $ref: "#/components/schemas/subject" + session.notify.chat.leave: + publish: + summary: Alert other subscribers of this session that a chat has been left. + payload: + $ref: "#/components/schemas/subject" + subscribe: + summary: A chat has been left in this session. + payload: + $ref: "#/components/schemas/subject" + +components: + messages: + invite: + payload: + type: object + properties: + channel: + title: channel + description: The channel the user is invited to. + type: string + schemas: + subject: + title: subject + description: The chat your client has left. + type: object + properties: + channel: + type: string + description: The PubNub channel for the chat. + group: + description: The PubNub channel group this chat belongs to. + type: string + enum: + - system + - custom + - rooms + private: + description: Does this chat require additional authentication to join? + type: boolean + meta: + description: Extra data to attach to this chat. + type: object + diff --git a/gulpfile.js b/gulpfile.js index 6fb538ab..60a68c9e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,8 @@ const path = require('path'); const uglify = require('gulp-uglify-es').default; const rename = require('gulp-rename'); const surge = require('gulp-surge'); +const asyncdocs = require('asyncapi-docgen'); +const fs = require('fs'); let sourceFiles = ['src/**/*.js']; let testFiles = ['test/unit/**/*.js', 'test/integration/**/*.js']; @@ -96,6 +98,46 @@ gulp.task('compile_docs', (cb) => { .pipe(jsdoc(config, cb)); }); +gulp.task('compile_async', (cb) => { + + const asyncapi = fs.readFileSync(path.resolve(__dirname, 'asyncapi.yml'), 'utf8'); + + asyncdocs + .generateFullHTML(asyncapi) + .catch((err) => { + console.error(`Something went wrong: ${err.message}`); + }) + .then((html) => { + console.log('Done!'); + + let dir = __dirname + '/docs'; + + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + + dir = dir + '/asyncapi'; + + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + + dir = dir + '/css'; + + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + + fs.writeFileSync(__dirname + '/docs/asyncapi/index.html', html) + + fs.createReadStream(__dirname + '/_docs/asyncapi/css/main.css').pipe(fs.createWriteStream(__dirname + '/docs/asyncapi/css/main.css')); + + cb(); + + }); + +}) + gulp.task('watch_docs', () => { gulp.watch(sourceFiles.concat(guideFiles).concat(readme), ['compile_docs']); }); diff --git a/images/logo.png b/images/logo.png deleted file mode 100644 index 052fe5a3..00000000 Binary files a/images/logo.png and /dev/null differ diff --git a/images/markdown.gif b/images/markdown.gif deleted file mode 100644 index b2465d95..00000000 Binary files a/images/markdown.gif and /dev/null differ diff --git a/images/mute.gif b/images/mute.gif deleted file mode 100644 index 0f725909..00000000 Binary files a/images/mute.gif and /dev/null differ diff --git a/images/online.gif b/images/online.gif deleted file mode 100644 index bf52f75a..00000000 Binary files a/images/online.gif and /dev/null differ diff --git a/images/typing.gif b/images/typing.gif deleted file mode 100644 index 2e6ddb52..00000000 Binary files a/images/typing.gif and /dev/null differ diff --git a/images/unread.gif b/images/unread.gif deleted file mode 100644 index 514007a2..00000000 Binary files a/images/unread.gif and /dev/null differ diff --git a/images/upload.gif b/images/upload.gif deleted file mode 100644 index 717a367b..00000000 Binary files a/images/upload.gif and /dev/null differ diff --git a/jsdoc.json b/jsdoc.json index be3407fc..b87bd419 100644 --- a/jsdoc.json +++ b/jsdoc.json @@ -1,7 +1,7 @@ { "opts": { "template": "./_docs/docdash", - "destination": "./docs/", + "destination": "./docs/js", "recurse": true, "tutorials": "./guide/", "readme": "./README.md" diff --git a/package.json b/package.json index b57dda39..32ee0f82 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "homepage": "https://github.com/pubnub/chat-engine#readme", "devDependencies": { + "asyncapi-docgen": "^1.10.6", "babel-loader": "^7.1.4", "babel-preset-es2015": "^6.24.1", "body-parser": "^1.17.2", @@ -58,7 +59,7 @@ "run-sequence": "^2.2.0", "sinon": "^4.0.0", "stats-webpack-plugin": "^0.6.1", - "surge": "^0.19.0", + "surge": "^0.20.5", "uglifyjs-webpack-plugin": "^1.0.1", "webpack": "^3.6.0", "webpack-stream": "^4.0.0" @@ -67,6 +68,7 @@ "async": "2.1.2", "axios": "0.16.2", "eventemitter2": "2.2.1", + "natives": "^1.1.6", "pubnub": "4.20.2" } }