-
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.
Merge pull request #202 from gaelj/release
🔖 Release 0.8.14
- Loading branch information
Showing
23 changed files
with
323 additions
and
26 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
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
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
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
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
82 changes: 82 additions & 0 deletions
82
CodeMirror6/Resources/GaelJ.BlazorCodeMirror6.lib.module.js
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const pageScriptInfoBySrc = new Map(); | ||
|
||
function registerPageScriptElement(src) { | ||
if (!src) { | ||
throw new Error('Must provide a non-empty value for the "src" attribute.'); | ||
} | ||
|
||
let pageScriptInfo = pageScriptInfoBySrc.get(src); | ||
|
||
if (pageScriptInfo) { | ||
pageScriptInfo.referenceCount++; | ||
} else { | ||
pageScriptInfo = { referenceCount: 1, module: null }; | ||
pageScriptInfoBySrc.set(src, pageScriptInfo); | ||
initializePageScriptModule(src, pageScriptInfo); | ||
} | ||
} | ||
|
||
function unregisterPageScriptElement(src) { | ||
if (!src) { | ||
return; | ||
} | ||
|
||
const pageScriptInfo = pageScriptInfoBySrc.get(src); | ||
|
||
if (!pageScriptInfo) { | ||
return; | ||
} | ||
|
||
pageScriptInfo.referenceCount--; | ||
} | ||
|
||
async function initializePageScriptModule(src, pageScriptInfo) { | ||
if (src.startsWith("./")) { | ||
src = new URL(src.substr(2), document.baseURI).toString(); | ||
} | ||
|
||
const module = await import(src); | ||
|
||
if (pageScriptInfo.referenceCount <= 0) { | ||
return; | ||
} | ||
|
||
pageScriptInfo.module = module; | ||
module.onLoad?.(); | ||
module.onUpdate?.(); | ||
} | ||
|
||
function onEnhancedLoad() { | ||
for (const [src, { module, referenceCount }] of pageScriptInfoBySrc) { | ||
if (referenceCount <= 0) { | ||
module?.onDispose?.(); | ||
pageScriptInfoBySrc.delete(src); | ||
} | ||
} | ||
|
||
for (const { module } of pageScriptInfoBySrc.values()) { | ||
module?.onUpdate?.(); | ||
} | ||
} | ||
|
||
export function afterWebStarted(blazor) { | ||
customElements.define('page-script', class extends HTMLElement { | ||
static observedAttributes = ['src']; | ||
|
||
attributeChangedCallback(name, oldValue, newValue) { | ||
if (name !== 'src') { | ||
return; | ||
} | ||
|
||
this.src = newValue; | ||
unregisterPageScriptElement(oldValue); | ||
registerPageScriptElement(newValue); | ||
} | ||
|
||
disconnectedCallback() { | ||
unregisterPageScriptElement(this.src); | ||
} | ||
}); | ||
|
||
blazor.addEventListener('enhancedload', onEnhancedLoad); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"outputFileName": "wwwroot/GaelJ.BlazorCodeMirror6.lib.module.js", | ||
"inputFiles": [ | ||
"Resources/GaelJ.BlazorCodeMirror6.lib.module.js" | ||
], | ||
"minify": { | ||
"enabled": false, | ||
"renameLocals": false | ||
}, | ||
"sourceMap": true | ||
} | ||
] |
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
Oops, something went wrong.