setupin 2.5.0-beta.1 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/README.zh-CN.md +19 -6
- package/dist/{development/main.js → main.js} +65 -61
- package/dist/{production/main.js → main.prod.js} +63 -61
- package/package.json +5 -14
- package/dist/development/svgs/logo.svg +0 -18
- package/dist/development/svgs/setup.vue.svg +0 -1
- package/dist/development/svgs/setupin.html.svg +0 -1
- package/dist/production/svgs/logo.svg +0 -18
- package/dist/production/svgs/setup.vue.svg +0 -1
- package/dist/production/svgs/setupin.html.svg +0 -1
- package/public/svgs/logo.svg +0 -18
- package/public/svgs/setup.vue.svg +0 -1
- package/public/svgs/setupin.html.svg +0 -1
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
<b>English</b> | <a href="./README.zh-CN.md">简体中文</a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<p align="center"><img src="./
|
|
5
|
+
<p align="center"><img src="./doc/logo.svg"></p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://npmjs.com/package/setupin"><img src="https://img.shields.io/npm/v/setupin?color=orange"></a>
|
|
9
|
-
<a href="https://stackblitz.com/edit/setupin
|
|
9
|
+
<a href="https://stackblitz.com/edit/setupin"><img src="https://img.shields.io/badge/Open%20in%20StackBlitz-blue"></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
## 😏 Why setupin
|
|
@@ -23,26 +23,39 @@
|
|
|
23
23
|
## 🤯 setupin.html _vs_ setup.vue
|
|
24
24
|
|
|
25
25
|
<p align="center">
|
|
26
|
-
<img src="./
|
|
27
|
-
<img src="./
|
|
26
|
+
<img src="./doc/setup.vue.svg" width="49%">
|
|
27
|
+
<img src="./doc/setupin.html.svg" width="49%">
|
|
28
28
|
</p>
|
|
29
29
|
|
|
30
30
|
How about that? Aren't they similar
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## 🤓 Characteristics
|
|
33
|
+
|
|
34
|
+
[x] auto on-demand import
|
|
35
|
+
[x] supports esm syntax
|
|
36
|
+
[x] [top-level await](https://vuejs.org/api/sfc-script-setup.html#top-level-await)
|
|
37
|
+
[ ] [sfc css features](https://vuejs.org/api/sfc-css-features.html)
|
|
38
|
+
[ ] vue3 macro functions
|
|
39
|
+
|
|
40
|
+
## 😝 Playground
|
|
33
41
|
|
|
34
42
|
try it on
|
|
35
43
|
[stackblitz](https://stackblitz.com/edit/setupin?file=index.html)
|
|
36
44
|
!
|
|
37
45
|
|
|
38
|
-
## 🥰
|
|
46
|
+
## 🥰 Usage
|
|
39
47
|
|
|
48
|
+
**The default is the dev version**
|
|
40
49
|
```html
|
|
41
50
|
<script src="https://unpkg.com/setupin"></script>
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
**
|
|
53
|
+
**dev**
|
|
54
|
+
```html
|
|
55
|
+
<script src="https://unpkg.com/setupin/dist/main.js"></script>
|
|
56
|
+
```
|
|
45
57
|
|
|
58
|
+
**prod**
|
|
46
59
|
```html
|
|
47
|
-
<script src="https://
|
|
60
|
+
<script src="https://unpkg.com/setupin/dist/main.prod.js"></script>
|
|
48
61
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
<a href="./README.md">English</a> | <b>简体中文</b>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<p align="center"><img src="./
|
|
5
|
+
<p align="center"><img src="./doc/logo.svg"></p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://npmjs.com/package/setupin"><img src="https://img.shields.io/npm/v/setupin?color=orange"></a>
|
|
9
|
-
<a href="https://stackblitz.com/edit/setupin
|
|
9
|
+
<a href="https://stackblitz.com/edit/setupin"><img src="https://img.shields.io/badge/Open%20in%20StackBlitz-blue"></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
## 😏 为什么选择 setupin
|
|
@@ -23,12 +23,20 @@
|
|
|
23
23
|
## 🤯 setupin.html _vs_ setup.vue
|
|
24
24
|
|
|
25
25
|
<p align="center">
|
|
26
|
-
<img src="./
|
|
27
|
-
<img src="./
|
|
26
|
+
<img src="./doc/setup.vue.svg" width="49%">
|
|
27
|
+
<img src="./doc/setupin.html.svg" width="49%">
|
|
28
28
|
</p>
|
|
29
29
|
|
|
30
30
|
怎么样, 它们很像吧。
|
|
31
31
|
|
|
32
|
+
## 🤓 特性
|
|
33
|
+
|
|
34
|
+
[x] 自动按需导入
|
|
35
|
+
[x] 支持 esm 语法
|
|
36
|
+
[x] [顶层 await](https://cn.vuejs.org/api/sfc-script-setup.html#top-level-await)
|
|
37
|
+
[ ] [CSS 功能](https://cn.vuejs.org/api/sfc-css-features)
|
|
38
|
+
[ ] vue3 宏函数
|
|
39
|
+
|
|
32
40
|
## 😝 演练场
|
|
33
41
|
|
|
34
42
|
在 [stackblitz](https://stackblitz.com/edit/setupin?file=index.html)
|
|
@@ -36,12 +44,17 @@
|
|
|
36
44
|
|
|
37
45
|
## 🥰 CDN
|
|
38
46
|
|
|
47
|
+
**默认为dev版本**
|
|
39
48
|
```html
|
|
40
49
|
<script src="https://unpkg.com/setupin"></script>
|
|
41
50
|
```
|
|
42
51
|
|
|
43
|
-
**
|
|
52
|
+
**dev**
|
|
53
|
+
```html
|
|
54
|
+
<script src="https://unpkg.com/setupin/dist/main.js"></script>
|
|
55
|
+
```
|
|
44
56
|
|
|
57
|
+
**prod**
|
|
45
58
|
```html
|
|
46
|
-
<script src="https://
|
|
59
|
+
<script src="https://unpkg.com/setupin/dist/main.prod.js"></script>
|
|
47
60
|
```
|
|
@@ -1,53 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
function discover(onPrior, onAfter) {
|
|
5
|
-
return new Promise((resolve) => {
|
|
6
|
-
const discovery = /* @__PURE__ */ Object.create(null);
|
|
7
|
-
const observer = new MutationObserver((mutations) => {
|
|
8
|
-
for (const mutation of mutations) {
|
|
9
|
-
mutation.addedNodes.forEach((node) => {
|
|
10
|
-
node instanceof Element && onPrior({ node, discovery, announce });
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
observer.observe(document, {
|
|
15
|
-
childList: true,
|
|
16
|
-
subtree: true
|
|
17
|
-
});
|
|
18
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
19
|
-
onAfter?.({ discovery, announce });
|
|
20
|
-
announce();
|
|
21
|
-
});
|
|
22
|
-
function announce() {
|
|
23
|
-
resolve(discovery);
|
|
24
|
-
observer.disconnect();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function isElMatch(el, targetHtml) {
|
|
30
|
-
try {
|
|
31
|
-
const parse = new DOMParser();
|
|
32
|
-
const aimEl = parse.parseFromString(`<body>${targetHtml}</body>`, "text/html").body.firstElementChild;
|
|
33
|
-
const isTag = aimEl?.tagName === el.tagName;
|
|
34
|
-
const nodeAttrs = el.getAttributeNames();
|
|
35
|
-
const aimAttrs = aimEl?.getAttributeNames() ?? [];
|
|
36
|
-
const hasAttr = new Set(aimAttrs).isSubsetOf(new Set(nodeAttrs));
|
|
37
|
-
return isTag && hasAttr;
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function when(gist, verifyer = gist) {
|
|
44
|
-
return function(classify) {
|
|
45
|
-
const sym = Object.getOwnPropertySymbols(classify).find((sym2) => sym2.description === "default");
|
|
46
|
-
const handler = classify[verifyer] ?? (sym && classify[sym]);
|
|
47
|
-
return handler?.(gist);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
4
|
var lib = {};
|
|
52
5
|
|
|
53
6
|
Object.defineProperty(lib, '__esModule', {
|
|
@@ -14081,6 +14034,53 @@
|
|
|
14081
14034
|
};
|
|
14082
14035
|
}
|
|
14083
14036
|
|
|
14037
|
+
function discover(onPrior, onAfter) {
|
|
14038
|
+
return new Promise((resolve) => {
|
|
14039
|
+
const discovery = /* @__PURE__ */ Object.create(null);
|
|
14040
|
+
const observer = new MutationObserver((mutations) => {
|
|
14041
|
+
for (const mutation of mutations) {
|
|
14042
|
+
mutation.addedNodes.forEach((node) => {
|
|
14043
|
+
node instanceof Element && onPrior({ node, discovery, announce });
|
|
14044
|
+
});
|
|
14045
|
+
}
|
|
14046
|
+
});
|
|
14047
|
+
observer.observe(document, {
|
|
14048
|
+
childList: true,
|
|
14049
|
+
subtree: true
|
|
14050
|
+
});
|
|
14051
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
14052
|
+
onAfter?.({ discovery, announce });
|
|
14053
|
+
announce();
|
|
14054
|
+
});
|
|
14055
|
+
function announce() {
|
|
14056
|
+
resolve(discovery);
|
|
14057
|
+
observer.disconnect();
|
|
14058
|
+
}
|
|
14059
|
+
});
|
|
14060
|
+
}
|
|
14061
|
+
|
|
14062
|
+
function isElMatch(el, targetHtml) {
|
|
14063
|
+
try {
|
|
14064
|
+
const parse = new DOMParser();
|
|
14065
|
+
const aimEl = parse.parseFromString(`<body>${targetHtml}</body>`, "text/html").body.firstElementChild;
|
|
14066
|
+
const isTag = aimEl?.tagName === el.tagName;
|
|
14067
|
+
const nodeAttrs = el.getAttributeNames();
|
|
14068
|
+
const aimAttrs = aimEl?.getAttributeNames() ?? [];
|
|
14069
|
+
const hasAttr = new Set(aimAttrs).isSubsetOf(new Set(nodeAttrs));
|
|
14070
|
+
return isTag && hasAttr;
|
|
14071
|
+
} catch {
|
|
14072
|
+
return false;
|
|
14073
|
+
}
|
|
14074
|
+
}
|
|
14075
|
+
|
|
14076
|
+
function when(gist, verifyer = gist) {
|
|
14077
|
+
return function(classify) {
|
|
14078
|
+
const sym = Object.getOwnPropertySymbols(classify).find((sym2) => sym2.description === "default");
|
|
14079
|
+
const handler = classify[verifyer] ?? (sym && classify[sym]);
|
|
14080
|
+
return handler?.(gist);
|
|
14081
|
+
};
|
|
14082
|
+
}
|
|
14083
|
+
|
|
14084
14084
|
function getGlobalVars(astBody) {
|
|
14085
14085
|
return astBody.flatMap((node) => when(node, node.type)({
|
|
14086
14086
|
FunctionDeclaration: ({ id }) => id ? [id.name] : [],
|
|
@@ -14123,13 +14123,13 @@
|
|
|
14123
14123
|
}
|
|
14124
14124
|
|
|
14125
14125
|
function parseScript(scriptEl) {
|
|
14126
|
-
const scriptContent = scriptEl?.
|
|
14126
|
+
const scriptContent = scriptEl?.innerHTML ?? "";
|
|
14127
14127
|
when(scriptEl?.tagName ?? 0)({
|
|
14128
14128
|
0: () => {
|
|
14129
14129
|
scriptEl = document.createElement("script");
|
|
14130
14130
|
document.head.appendChild(scriptEl);
|
|
14131
14131
|
},
|
|
14132
|
-
SCRIPT: () => scriptEl.
|
|
14132
|
+
SCRIPT: () => scriptEl.innerHTML = ""
|
|
14133
14133
|
});
|
|
14134
14134
|
scriptEl.type = "module";
|
|
14135
14135
|
const { extractImport, getGlobalVars, isAsyncModule } = ast(scriptContent);
|
|
@@ -14188,14 +14188,14 @@
|
|
|
14188
14188
|
[tagTemplate.str]: newCarrier(0, null)
|
|
14189
14189
|
};
|
|
14190
14190
|
|
|
14191
|
-
var state = /* @__PURE__ */ ((state2) => {
|
|
14192
|
-
state2[state2["WITHOUT"] = 0] = "WITHOUT";
|
|
14193
|
-
state2[state2["RELATE"] = 1] = "RELATE";
|
|
14194
|
-
state2[state2["CORRECT"] = 2] = "CORRECT";
|
|
14195
|
-
return state2;
|
|
14196
|
-
})(state || {});
|
|
14197
|
-
const { WITHOUT, RELATE, CORRECT } = state;
|
|
14198
14191
|
const onPrior = ({ node, discovery }) => {
|
|
14192
|
+
let state;
|
|
14193
|
+
((state2) => {
|
|
14194
|
+
state2[state2["WITHOUT"] = 0] = "WITHOUT";
|
|
14195
|
+
state2[state2["RELATE"] = 1] = "RELATE";
|
|
14196
|
+
state2[state2["CORRECT"] = 2] = "CORRECT";
|
|
14197
|
+
})(state || (state = {}));
|
|
14198
|
+
const { WITHOUT, RELATE, CORRECT } = state;
|
|
14199
14199
|
Object.assign(discovery, carrier);
|
|
14200
14200
|
function _getState(tag) {
|
|
14201
14201
|
if (!isElMatch(node, tag)) return WITHOUT;
|
|
@@ -14216,6 +14216,8 @@
|
|
|
14216
14216
|
behavior[tagScript.str].beNoHere(node);
|
|
14217
14217
|
};
|
|
14218
14218
|
|
|
14219
|
+
const asciiLogoRaw = "/***************************************\r\n** _ _ **\r\n** ___ ___| |_ _ _ _ __ (_)_ __ **\r\n** / __|/ _ \\ __| | | | '_ \\| | '_ \\ **\r\n** \\__ \\ __/ |_| |_| | |_) | | | | | **\r\n** |___/\\___|\\__|\\__,_| .__/|_|_| |_| **\r\n** |_| **\r\n****************************************/\r\n";
|
|
14220
|
+
|
|
14219
14221
|
/**
|
|
14220
14222
|
* vue v3.5.12
|
|
14221
14223
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
@@ -32547,21 +32549,23 @@ ${codeFrame}` : message);
|
|
|
32547
32549
|
withScopeId
|
|
32548
32550
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
32549
32551
|
|
|
32550
|
-
function generate(
|
|
32551
|
-
|
|
32552
|
+
function generate(context) {
|
|
32553
|
+
const asciiLogo = asciiLogoRaw ;
|
|
32552
32554
|
const demandRex = new RegExp(`\\b${Object.keys(window.Vue = Vue).join("\\b|\\b")}\\b`, "g");
|
|
32553
|
-
const {
|
|
32555
|
+
const { importsCode, setupCode, retNames, isAsync } = context;
|
|
32554
32556
|
const async = isAsync ? "async" : "";
|
|
32555
32557
|
const appComp = `{template:document.body.innerHTML,${async} setup(){${setupCode}return{${retNames}}}}`;
|
|
32556
32558
|
const suspenseComp = `{components:{c:${appComp}},template:'<Suspense><c/></Suspense>'}`;
|
|
32557
32559
|
const createApp = `createApp(${isAsync ? suspenseComp : appComp}).mount(document.body);`;
|
|
32558
32560
|
const autoImport = `const {createApp,${[...new Set(setupCode.match(demandRex))]}}=Vue;`;
|
|
32559
|
-
|
|
32561
|
+
return asciiLogo + importsCode + autoImport + createApp;
|
|
32560
32562
|
}
|
|
32561
32563
|
|
|
32562
32564
|
(async () => {
|
|
32563
32565
|
const discovery = await discover(onPrior, onAfter);
|
|
32564
|
-
|
|
32566
|
+
document.body.innerHTML = discovery[tagTemplate.str].parsed;
|
|
32567
|
+
const { scriptEl, ...context } = discovery[tagScript.str].parsed;
|
|
32568
|
+
scriptEl.innerHTML = generate(context);
|
|
32565
32569
|
})();
|
|
32566
32570
|
|
|
32567
32571
|
})();
|
|
@@ -1,53 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
function discover(onPrior, onAfter) {
|
|
5
|
-
return new Promise((resolve) => {
|
|
6
|
-
const discovery = /* @__PURE__ */ Object.create(null);
|
|
7
|
-
const observer = new MutationObserver((mutations) => {
|
|
8
|
-
for (const mutation of mutations) {
|
|
9
|
-
mutation.addedNodes.forEach((node) => {
|
|
10
|
-
node instanceof Element && onPrior({ node, discovery, announce });
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
observer.observe(document, {
|
|
15
|
-
childList: true,
|
|
16
|
-
subtree: true
|
|
17
|
-
});
|
|
18
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
19
|
-
onAfter?.({ discovery, announce });
|
|
20
|
-
announce();
|
|
21
|
-
});
|
|
22
|
-
function announce() {
|
|
23
|
-
resolve(discovery);
|
|
24
|
-
observer.disconnect();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function isElMatch(el, targetHtml) {
|
|
30
|
-
try {
|
|
31
|
-
const parse = new DOMParser();
|
|
32
|
-
const aimEl = parse.parseFromString(`<body>${targetHtml}</body>`, "text/html").body.firstElementChild;
|
|
33
|
-
const isTag = aimEl?.tagName === el.tagName;
|
|
34
|
-
const nodeAttrs = el.getAttributeNames();
|
|
35
|
-
const aimAttrs = aimEl?.getAttributeNames() ?? [];
|
|
36
|
-
const hasAttr = new Set(aimAttrs).isSubsetOf(new Set(nodeAttrs));
|
|
37
|
-
return isTag && hasAttr;
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function when(gist, verifyer = gist) {
|
|
44
|
-
return function(classify) {
|
|
45
|
-
const sym = Object.getOwnPropertySymbols(classify).find((sym2) => sym2.description === "default");
|
|
46
|
-
const handler = classify[verifyer] ?? (sym && classify[sym]);
|
|
47
|
-
return handler?.(gist);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
4
|
var lib = {};
|
|
52
5
|
|
|
53
6
|
Object.defineProperty(lib, '__esModule', {
|
|
@@ -14081,6 +14034,53 @@
|
|
|
14081
14034
|
};
|
|
14082
14035
|
}
|
|
14083
14036
|
|
|
14037
|
+
function discover(onPrior, onAfter) {
|
|
14038
|
+
return new Promise((resolve) => {
|
|
14039
|
+
const discovery = /* @__PURE__ */ Object.create(null);
|
|
14040
|
+
const observer = new MutationObserver((mutations) => {
|
|
14041
|
+
for (const mutation of mutations) {
|
|
14042
|
+
mutation.addedNodes.forEach((node) => {
|
|
14043
|
+
node instanceof Element && onPrior({ node, discovery, announce });
|
|
14044
|
+
});
|
|
14045
|
+
}
|
|
14046
|
+
});
|
|
14047
|
+
observer.observe(document, {
|
|
14048
|
+
childList: true,
|
|
14049
|
+
subtree: true
|
|
14050
|
+
});
|
|
14051
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
14052
|
+
onAfter?.({ discovery, announce });
|
|
14053
|
+
announce();
|
|
14054
|
+
});
|
|
14055
|
+
function announce() {
|
|
14056
|
+
resolve(discovery);
|
|
14057
|
+
observer.disconnect();
|
|
14058
|
+
}
|
|
14059
|
+
});
|
|
14060
|
+
}
|
|
14061
|
+
|
|
14062
|
+
function isElMatch(el, targetHtml) {
|
|
14063
|
+
try {
|
|
14064
|
+
const parse = new DOMParser();
|
|
14065
|
+
const aimEl = parse.parseFromString(`<body>${targetHtml}</body>`, "text/html").body.firstElementChild;
|
|
14066
|
+
const isTag = aimEl?.tagName === el.tagName;
|
|
14067
|
+
const nodeAttrs = el.getAttributeNames();
|
|
14068
|
+
const aimAttrs = aimEl?.getAttributeNames() ?? [];
|
|
14069
|
+
const hasAttr = new Set(aimAttrs).isSubsetOf(new Set(nodeAttrs));
|
|
14070
|
+
return isTag && hasAttr;
|
|
14071
|
+
} catch {
|
|
14072
|
+
return false;
|
|
14073
|
+
}
|
|
14074
|
+
}
|
|
14075
|
+
|
|
14076
|
+
function when(gist, verifyer = gist) {
|
|
14077
|
+
return function(classify) {
|
|
14078
|
+
const sym = Object.getOwnPropertySymbols(classify).find((sym2) => sym2.description === "default");
|
|
14079
|
+
const handler = classify[verifyer] ?? (sym && classify[sym]);
|
|
14080
|
+
return handler?.(gist);
|
|
14081
|
+
};
|
|
14082
|
+
}
|
|
14083
|
+
|
|
14084
14084
|
function getGlobalVars(astBody) {
|
|
14085
14085
|
return astBody.flatMap((node) => when(node, node.type)({
|
|
14086
14086
|
FunctionDeclaration: ({ id }) => id ? [id.name] : [],
|
|
@@ -14123,13 +14123,13 @@
|
|
|
14123
14123
|
}
|
|
14124
14124
|
|
|
14125
14125
|
function parseScript(scriptEl) {
|
|
14126
|
-
const scriptContent = scriptEl?.
|
|
14126
|
+
const scriptContent = scriptEl?.innerHTML ?? "";
|
|
14127
14127
|
when(scriptEl?.tagName ?? 0)({
|
|
14128
14128
|
0: () => {
|
|
14129
14129
|
scriptEl = document.createElement("script");
|
|
14130
14130
|
document.head.appendChild(scriptEl);
|
|
14131
14131
|
},
|
|
14132
|
-
SCRIPT: () => scriptEl.
|
|
14132
|
+
SCRIPT: () => scriptEl.innerHTML = ""
|
|
14133
14133
|
});
|
|
14134
14134
|
scriptEl.type = "module";
|
|
14135
14135
|
const { extractImport, getGlobalVars, isAsyncModule } = ast(scriptContent);
|
|
@@ -14188,14 +14188,14 @@
|
|
|
14188
14188
|
[tagTemplate.str]: newCarrier(0, null)
|
|
14189
14189
|
};
|
|
14190
14190
|
|
|
14191
|
-
var state = /* @__PURE__ */ ((state2) => {
|
|
14192
|
-
state2[state2["WITHOUT"] = 0] = "WITHOUT";
|
|
14193
|
-
state2[state2["RELATE"] = 1] = "RELATE";
|
|
14194
|
-
state2[state2["CORRECT"] = 2] = "CORRECT";
|
|
14195
|
-
return state2;
|
|
14196
|
-
})(state || {});
|
|
14197
|
-
const { WITHOUT, RELATE, CORRECT } = state;
|
|
14198
14191
|
const onPrior = ({ node, discovery }) => {
|
|
14192
|
+
let state;
|
|
14193
|
+
((state2) => {
|
|
14194
|
+
state2[state2["WITHOUT"] = 0] = "WITHOUT";
|
|
14195
|
+
state2[state2["RELATE"] = 1] = "RELATE";
|
|
14196
|
+
state2[state2["CORRECT"] = 2] = "CORRECT";
|
|
14197
|
+
})(state || (state = {}));
|
|
14198
|
+
const { WITHOUT, RELATE, CORRECT } = state;
|
|
14199
14199
|
Object.assign(discovery, carrier);
|
|
14200
14200
|
function _getState(tag) {
|
|
14201
14201
|
if (!isElMatch(node, tag)) return WITHOUT;
|
|
@@ -14399,21 +14399,23 @@
|
|
|
14399
14399
|
withScopeId: nm
|
|
14400
14400
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
14401
14401
|
|
|
14402
|
-
function generate(
|
|
14403
|
-
|
|
14402
|
+
function generate(context) {
|
|
14403
|
+
const asciiLogo = "";
|
|
14404
14404
|
const demandRex = new RegExp(`\\b${Object.keys(window.Vue = Vue).join("\\b|\\b")}\\b`, "g");
|
|
14405
|
-
const {
|
|
14405
|
+
const { importsCode, setupCode, retNames, isAsync } = context;
|
|
14406
14406
|
const async = isAsync ? "async" : "";
|
|
14407
14407
|
const appComp = `{template:document.body.innerHTML,${async} setup(){${setupCode}return{${retNames}}}}`;
|
|
14408
14408
|
const suspenseComp = `{components:{c:${appComp}},template:'<Suspense><c/></Suspense>'}`;
|
|
14409
14409
|
const createApp = `createApp(${isAsync ? suspenseComp : appComp}).mount(document.body);`;
|
|
14410
14410
|
const autoImport = `const {createApp,${[...new Set(setupCode.match(demandRex))]}}=Vue;`;
|
|
14411
|
-
|
|
14411
|
+
return asciiLogo + importsCode + autoImport + createApp;
|
|
14412
14412
|
}
|
|
14413
14413
|
|
|
14414
14414
|
(async () => {
|
|
14415
14415
|
const discovery = await discover(onPrior, onAfter);
|
|
14416
|
-
|
|
14416
|
+
document.body.innerHTML = discovery[tagTemplate.str].parsed;
|
|
14417
|
+
const { scriptEl, ...context } = discovery[tagScript.str].parsed;
|
|
14418
|
+
scriptEl.innerHTML = generate(context);
|
|
14417
14419
|
})();
|
|
14418
14420
|
|
|
14419
14421
|
})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "setupin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.1",
|
|
5
5
|
"description": "Vue SFC? HTML! <script setup> in html",
|
|
6
6
|
"author": "tofu-xx <tofu-xx@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -20,14 +20,9 @@
|
|
|
20
20
|
"html",
|
|
21
21
|
"sfc"
|
|
22
22
|
],
|
|
23
|
-
"
|
|
24
|
-
"./main.js": "./dist/development/main.js",
|
|
25
|
-
"./main.prod.js": "./dist/production/main.js"
|
|
26
|
-
},
|
|
27
|
-
"main": "dist/development/main.js",
|
|
23
|
+
"main": "dist/main.js",
|
|
28
24
|
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
"public"
|
|
25
|
+
"dist"
|
|
31
26
|
],
|
|
32
27
|
"publishConfig": {
|
|
33
28
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -38,21 +33,17 @@
|
|
|
38
33
|
"@antfu/ni": "^0.23.0",
|
|
39
34
|
"@babel/parser": "^7.26.2",
|
|
40
35
|
"@babel/types": "^7.26.0",
|
|
41
|
-
"@types/node": "^22.
|
|
36
|
+
"@types/node": "^22.9.0",
|
|
42
37
|
"bumpp": "^9.8.1",
|
|
43
38
|
"eslint": "^9.14.0",
|
|
44
39
|
"eslint-plugin-format": "^0.1.2",
|
|
45
40
|
"taze": "^0.18.0",
|
|
46
41
|
"vite": "^5.4.10",
|
|
47
|
-
"vite-plugin-babel": "^1.2.0",
|
|
48
42
|
"vue": "^3.5.12"
|
|
49
43
|
},
|
|
50
44
|
"scripts": {
|
|
51
|
-
"build
|
|
52
|
-
"build:prod": "vite build --mode production",
|
|
53
|
-
"build": "nr build:dev && nr build:prod",
|
|
45
|
+
"build": "zsh ./script/build.zsh",
|
|
54
46
|
"watch": "vite build --watch",
|
|
55
|
-
"dev": "vite dev",
|
|
56
47
|
"release": "bumpp --no-push && nr build && pnpm publish",
|
|
57
48
|
"iv": "zsh ./script/install_vue.zsh",
|
|
58
49
|
"up": "taze major -I",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="231" height="137.66">
|
|
2
|
-
<path
|
|
3
|
-
style="fill: #2b3d4f; stroke: none"
|
|
4
|
-
d="M25 41L25 99L58 99C62.5954 99 68.6309 97.9925 73 99.6034C78.1157 101.49 82.2455 107.245 86 111C95.2825 120.282 106.436 129.262 114 140L117 140C124.564 129.262 135.718 120.282 145 111C148.755 107.245 152.884 101.49 158 99.6034C162.369 97.9925 168.405 99 173 99L206 99L206 41L171 41C166.035 41 159.383 42.1639 155 39.3966C144.593 32.8268 135.694 20.6941 127 12C124.177 9.17657 119.429 2.28673 115 2.34567C110.546 2.40495 105.853 9.14688 103 12C94.3055 20.694 85.407 32.8267 75 39.3966C70.8239 42.033 64.7246 41 60 41L25 41z" />
|
|
5
|
-
<text fill="#21b899" x="58" y="80" font-family="'Comic Sans MS'" font-size="34">setupin</text>
|
|
6
|
-
<path
|
|
7
|
-
style="fill: #f2fbf9; stroke: none"
|
|
8
|
-
d="M115 7C104.443 17.557 91.5993 27.7923 83 40C86.4725 40 90.6915 40.6165 94 39.3966C101.585 36.5999 110.439 25.4748 115 19C121.119 25.1192 128.774 36.3637 137 39.3966C140.309 40.6165 144.528 40 148 40C143.546 33.6776 137.46 28.4599 132 23C126.54 17.5401 121.322 11.4536 115 7z" />
|
|
9
|
-
<path
|
|
10
|
-
style="fill: #21b899; stroke: none"
|
|
11
|
-
d="M97 40L134 40C131.415 34.4563 126.392 30.2125 122 26.0193C120.359 24.453 118.407 22.2053 116 21.9213C113.163 21.5866 110.838 24.2646 109 26.0193C104.608 30.2125 99.5852 34.4563 97 40z" />
|
|
12
|
-
<path
|
|
13
|
-
style="fill: #21b899; stroke: none"
|
|
14
|
-
d="M97 100C99.5852 105.544 104.608 109.787 109 113.981C110.838 115.735 113.163 118.413 116 118.079C118.804 117.748 121.125 114.834 123 112.995C127.208 108.869 131.603 104.822 135 100L97 100z" />
|
|
15
|
-
<path
|
|
16
|
-
style="fill: #f2fbf9; stroke: none"
|
|
17
|
-
d="M84 101C92.3411 112.841 104.761 122.761 115 133C120.952 128.807 125.86 123.14 131 118C136.46 112.54 142.546 107.322 147 101C143.527 101 139.309 100.384 136 101.603C128.696 104.296 120.386 114.773 116 121C110.137 115.137 102.89 104.512 95 101.603C91.6915 100.384 87.4725 101 84 101z" />
|
|
18
|
-
</svg>
|