forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseServer.js
More file actions
1 lines (1 loc) · 1.89 KB
/
BaseServer.js
File metadata and controls
1 lines (1 loc) · 1.89 KB
1
define(function(require,exports,module){function BaseServer(config){this._root=config.root,this._pathResolver=config.pathResolver,this._liveDocuments={},this._virtualServingDocuments={}}BaseServer.prototype.getProjectRoot=function(){return this._root},BaseServer.prototype._setDocInfo=function(liveDocument){var parentUrl,matches,doc=liveDocument.doc;(matches=/^(.*\/)(.+\.([^.]+))$/.exec(doc.file.fullPath))&&(doc.extension=matches[3],parentUrl=this.pathToUrl(matches[1]),doc.url=parentUrl+encodeURI(matches[2]),doc.root={url:doc.url},doc.isDirty&&liveDocument._updateBrowser&&liveDocument._updateBrowser())},BaseServer.prototype.readyToServe=function(){return $.Deferred().resolve().promise()},BaseServer.prototype.canServe=function(localPath){return!0},BaseServer.prototype._documentKey=function(absolutePath){return"/"+encodeURI(this._pathResolver(absolutePath))},BaseServer.prototype.add=function(liveDocument){if(liveDocument){var key=this._documentKey(liveDocument.doc.file.fullPath);this._setDocInfo(liveDocument),this._liveDocuments[key]=liveDocument}},BaseServer.prototype.addVirtualContentAtPath=function(fullPath,docText){let key=this._documentKey(fullPath);this._virtualServingDocuments[key]=docText},BaseServer.prototype.remove=function(liveDocument){if(!liveDocument)return;const key=this._documentKey(liveDocument.doc.file.fullPath);this._liveDocuments[key]&&delete this._liveDocuments[key]},BaseServer.prototype.removeVirtualContentAtPath=function(fullPath){let key=this._documentKey(fullPath);this._virtualServingDocuments[key]&&delete this._virtualServingDocuments[key]},BaseServer.prototype.get=function(path){return this._liveDocuments[this._documentKey(path)]},BaseServer.prototype.clear=function(){this._liveDocuments={},this._virtualServingDocuments={}},BaseServer.prototype.start=function(){},BaseServer.prototype.isActive=function(){return!1},BaseServer.prototype.stop=function(){},exports.BaseServer=BaseServer});