Skip to content

Commit 2ad703a

Browse files
committed
first-commit
0 parents  commit 2ad703a

File tree

6 files changed

+4069
-0
lines changed

6 files changed

+4069
-0
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
globals: {
3+
globalThis: true,
4+
},
5+
extends: "eslint-config-75team",
6+
rules: {
7+
"semi": [2, "always"],
8+
"complexity": ["warn", 25],
9+
"no-unused-vars": 'warn',
10+
'no-restricted-globals': 'off',
11+
"no-console": 'off',
12+
"max-params": ["warn", 7],
13+
},
14+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
npm-debug.log*
3+
.nyc_*/
4+
.dir-locals.el
5+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 稀土掘金
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

index.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const cache = {};
2+
export default async function inlineImport(moduleID) {
3+
let blobURL = null;
4+
if(moduleID in cache) blobURL = cache[moduleID];
5+
else {
6+
const module = document.querySelector(`script#${moduleID}[type="inline-module"]`);
7+
if(module) {
8+
const jsCode = module.innerHTML;
9+
const blob = new Blob([jsCode], {type: 'text/javascript'});
10+
const script = document.createElement('script');
11+
script.setAttribute('type', 'module');
12+
document.body.appendChild(script);
13+
blobURL = URL.createObjectURL(blob);
14+
script.src = blobURL;
15+
cache[moduleID] = blobURL;
16+
}
17+
}
18+
if(blobURL) {
19+
const result = await import(blobURL);
20+
return result;
21+
}
22+
return null;
23+
}

0 commit comments

Comments
 (0)