StaticContentProvider.js 928 B

12345678
  1. import{ContentProvider,SearchMatch}from'./ContentProvider.js';import{ResourceType}from'./ResourceType.js';export class StaticContentProvider{constructor(contentURL,contentType,lazyContent){this._contentURL=contentURL;this._contentType=contentType;this._lazyContent=lazyContent;}
  2. static fromString(contentURL,contentType,content){const lazyContent=()=>Promise.resolve({content,isEncoded:false});return new StaticContentProvider(contentURL,contentType,lazyContent);}
  3. contentURL(){return this._contentURL;}
  4. contentType(){return this._contentType;}
  5. contentEncoded(){return Promise.resolve(false);}
  6. requestContent(){return this._lazyContent();}
  7. async searchInContent(query,caseSensitive,isRegex){const{content}=(await this._lazyContent());return content?ContentProvider.performSearchInContent(content,query,caseSensitive,isRegex):[];}}
  8. self.Common=self.Common||{};Common=Common||{};Common.StaticContentProvider=StaticContentProvider;