MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / _detectScriptFile

Method _detectScriptFile

packages/alphatab/src/Environment.ts:225–258  ·  view source on GitHub ↗

* @target web

()

Source from the content-addressed store, hash-verified

223 * @target web
224 */
225 private static _detectScriptFile(): string | null {
226 // custom global constant
227 if (!Environment.isRunningInWorker && Environment.globalThis.ALPHATAB_ROOT) {
228 let scriptFile = Environment.globalThis.ALPHATAB_ROOT;
229 scriptFile = Environment.ensureFullUrl(scriptFile);
230 scriptFile = Environment._appendScriptName(scriptFile);
231 return scriptFile;
232 }
233
234 // browser include as ES6 import
235 // <script type="module">
236 // import * as alphaTab from 'dist/alphaTab.js';
237 try {
238 const importUrl = import.meta.url;
239 // avoid using file:// urls in case of
240 // bundlers like webpack
241 if (importUrl && importUrl.indexOf('file://') === -1) {
242 return importUrl;
243 }
244 } catch {
245 // ignore potential errors
246 }
247
248 // normal browser include as <script>
249 if (
250 'document' in Environment.globalThis &&
251 document.currentScript &&
252 document.currentScript instanceof HTMLScriptElement
253 ) {
254 return document.currentScript.src;
255 }
256
257 return null;
258 }
259
260 /**
261 * @target web

Callers 1

EnvironmentClass · 0.80

Calls 3

ensureFullUrlMethod · 0.80
_appendScriptNameMethod · 0.80
indexOfMethod · 0.45

Tested by

no test coverage detected