shelfware 0.0.1 → 0.1.0
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/.output/nitro.json +15 -0
- package/.output/public/_nuxt/6IstVYrV.js +1 -0
- package/.output/public/_nuxt/9C5WUlLE.js +36 -0
- package/.output/public/_nuxt/BDNMzG2s.js +1 -0
- package/.output/public/_nuxt/BW3xJdEx.js +1 -0
- package/.output/public/_nuxt/BXXtFil5.js +1 -0
- package/.output/public/_nuxt/BZuUK3cr.js +1 -0
- package/.output/public/_nuxt/BeLyMmd4.js +1 -0
- package/.output/public/_nuxt/C_VgD9ZI.js +3 -0
- package/.output/public/_nuxt/DB5Vxbte.js +2 -0
- package/.output/public/_nuxt/DMg0j7gv.js +14 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/4c307968-4837-497b-a570-d6ee336accc4.json +1 -0
- package/.output/public/_nuxt/entry.b3_DJTEt.css +2 -0
- package/.output/public/_nuxt/error-404.CHsn7XF-.css +1 -0
- package/.output/public/_nuxt/error-500.Bawx2bLr.css +1 -0
- package/.output/server/chunks/_/api-handler.mjs +44 -0
- package/.output/server/chunks/_/batch.mjs +27 -0
- package/.output/server/chunks/_/catalog.mjs +1115 -0
- package/.output/server/chunks/_/detail.mjs +16 -0
- package/.output/server/chunks/_/error-500.mjs +19 -0
- package/.output/server/chunks/_/quarantine.mjs +159 -0
- package/.output/server/chunks/nitro/nitro.mjs +5399 -0
- package/.output/server/chunks/routes/api/_..._.mjs +16 -0
- package/.output/server/chunks/routes/api/health.get.mjs +13 -0
- package/.output/server/chunks/routes/api/skills/_id/file.get.mjs +25 -0
- package/.output/server/chunks/routes/api/skills/_id_.get.mjs +25 -0
- package/.output/server/chunks/routes/api/skills/_id_.put.mjs +74 -0
- package/.output/server/chunks/routes/api/skills/delete.post.mjs +48 -0
- package/.output/server/chunks/routes/api/skills/quarantine.post.mjs +26 -0
- package/.output/server/chunks/routes/api/skills/restore.post.mjs +26 -0
- package/.output/server/chunks/routes/api/skills.get.mjs +41 -0
- package/.output/server/chunks/routes/renderer.mjs +341 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs +3 -0
- package/.output/server/chunks/virtual/precomputed.mjs +3 -0
- package/.output/server/index.mjs +9 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14611 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6801 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +692 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1903 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6980 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1867 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +904 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +636 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +17 -0
- package/.output/server/node_modules/devalue/package.json +39 -0
- package/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/.output/server/node_modules/devalue/src/operations.js +193 -0
- package/.output/server/node_modules/devalue/src/parse.js +274 -0
- package/.output/server/node_modules/devalue/src/stringify.js +428 -0
- package/.output/server/node_modules/devalue/src/uneval.js +606 -0
- package/.output/server/node_modules/devalue/src/utils.js +185 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/.output/server/node_modules/entities/package.json +120 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/.output/server/node_modules/hookable/package.json +53 -0
- package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
- package/.output/server/node_modules/nostics/dist/index.mjs +187 -0
- package/.output/server/node_modules/nostics/package.json +125 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/.output/server/node_modules/ufo/package.json +48 -0
- package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
- package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
- package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
- package/.output/server/node_modules/unhead/dist/plugins.mjs +720 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.-hZVKou0.mjs +400 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BGFxPGPQ.mjs +47 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BQWSw36o.mjs +192 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bjbp1C8D.mjs +224 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Dssd7L5I.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.jEy9BmRq.mjs +264 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.oZ7pkTV1.mjs +19 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.tQnRaXfX.mjs +240 -0
- package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
- package/.output/server/node_modules/unhead/dist/stream/server.mjs +445 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
- package/.output/server/node_modules/unhead/package.json +179 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +278 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +54 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/.output/server/node_modules/yaml/dist/compose/composer.js +224 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/.output/server/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/.output/server/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/.output/server/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/.output/server/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/.output/server/node_modules/yaml/dist/doc/Document.js +337 -0
- package/.output/server/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/.output/server/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/.output/server/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/.output/server/node_modules/yaml/dist/doc/directives.js +178 -0
- package/.output/server/node_modules/yaml/dist/errors.js +62 -0
- package/.output/server/node_modules/yaml/dist/index.js +50 -0
- package/.output/server/node_modules/yaml/dist/log.js +19 -0
- package/.output/server/node_modules/yaml/dist/nodes/Alias.js +118 -0
- package/.output/server/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/.output/server/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/.output/server/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/.output/server/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/.output/server/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/.output/server/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/.output/server/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/.output/server/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/.output/server/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/.output/server/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/.output/server/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/.output/server/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/.output/server/node_modules/yaml/dist/parse/cst.js +112 -0
- package/.output/server/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/.output/server/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/.output/server/node_modules/yaml/dist/parse/parser.js +980 -0
- package/.output/server/node_modules/yaml/dist/public-api.js +107 -0
- package/.output/server/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/.output/server/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/.output/server/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/.output/server/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/.output/server/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/.output/server/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/.output/server/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/.output/server/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/.output/server/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/.output/server/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/.output/server/node_modules/yaml/dist/schema/tags.js +99 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/.output/server/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/.output/server/node_modules/yaml/dist/visit.js +236 -0
- package/.output/server/node_modules/yaml/package.json +97 -0
- package/.output/server/package.json +28 -0
- package/LICENSE +21 -0
- package/README.md +57 -1
- package/bin/launch.mjs +158 -0
- package/bin/shelfware.mjs +6 -0
- package/package.json +64 -5
- package/cli.mjs +0 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { c as createHead } from './shared/unhead.oZ7pkTV1.mjs';
|
|
2
|
+
export { c as createDomRenderer, r as renderDOMHead } from './shared/unhead.Bjbp1C8D.mjs';
|
|
3
|
+
import './shared/unhead.D7HkBzZn.mjs';
|
|
4
|
+
import './shared/unhead.CGPOfp5O.mjs';
|
|
5
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
6
|
+
import 'hookable';
|
|
7
|
+
import './shared/unhead.C5Bksi2B.mjs';
|
|
8
|
+
import './shared/unhead.-hZVKou0.mjs';
|
|
9
|
+
|
|
10
|
+
function createDebouncedFn(callee, delayer) {
|
|
11
|
+
let ctxId = 0;
|
|
12
|
+
return () => {
|
|
13
|
+
const delayFnCtxId = ++ctxId;
|
|
14
|
+
delayer(() => {
|
|
15
|
+
if (ctxId === delayFnCtxId) {
|
|
16
|
+
callee();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { createDebouncedFn };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.tQnRaXfX.mjs';
|
|
2
|
+
import { c as createUnhead } from './shared/unhead.D7HkBzZn.mjs';
|
|
3
|
+
import { c as createHead$1 } from './shared/unhead.oZ7pkTV1.mjs';
|
|
4
|
+
import { c as createHead$2 } from './shared/unhead.Dssd7L5I.mjs';
|
|
5
|
+
import './shared/unhead.CHEy9ana.mjs';
|
|
6
|
+
import './shared/unhead.BGFxPGPQ.mjs';
|
|
7
|
+
import './shared/unhead.CGPOfp5O.mjs';
|
|
8
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
9
|
+
import 'hookable';
|
|
10
|
+
import './shared/unhead.C5Bksi2B.mjs';
|
|
11
|
+
import './shared/unhead.Bjbp1C8D.mjs';
|
|
12
|
+
import './shared/unhead.-hZVKou0.mjs';
|
|
13
|
+
|
|
14
|
+
const legacyPlugins = [DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin];
|
|
15
|
+
const activeHead = { value: null };
|
|
16
|
+
function getActiveHead() {
|
|
17
|
+
return activeHead.value;
|
|
18
|
+
}
|
|
19
|
+
function createHead(options = {}) {
|
|
20
|
+
return activeHead.value = createHead$1({
|
|
21
|
+
...options,
|
|
22
|
+
plugins: [...legacyPlugins, ...options.plugins || []]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function createServerHead(options = {}) {
|
|
26
|
+
return activeHead.value = createHead$2({
|
|
27
|
+
...options,
|
|
28
|
+
plugins: [...legacyPlugins, ...options.plugins || []]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const createHeadCore = createUnhead;
|
|
32
|
+
|
|
33
|
+
export { DeprecationsPlugin, activeHead, createHead, createHeadCore, createServerHead, getActiveHead, legacyPlugins };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
function minifyCSS(code) {
|
|
2
|
+
if (!/[\s/]|;\}|0\.\d/.test(code))
|
|
3
|
+
return code;
|
|
4
|
+
let result = "";
|
|
5
|
+
let last = "";
|
|
6
|
+
let i = 0;
|
|
7
|
+
let parenDepth = 0;
|
|
8
|
+
const len = code.length;
|
|
9
|
+
const append = (value) => {
|
|
10
|
+
result += value;
|
|
11
|
+
last = value;
|
|
12
|
+
};
|
|
13
|
+
while (i < len) {
|
|
14
|
+
const ch = code[i];
|
|
15
|
+
if (ch === "'" || ch === '"') {
|
|
16
|
+
const quote = ch;
|
|
17
|
+
append(ch);
|
|
18
|
+
i++;
|
|
19
|
+
while (i < len && code[i] !== quote) {
|
|
20
|
+
if (code[i] === "\\" && i + 1 < len)
|
|
21
|
+
append(code[i++]);
|
|
22
|
+
append(code[i++]);
|
|
23
|
+
}
|
|
24
|
+
if (i < len)
|
|
25
|
+
append(code[i++]);
|
|
26
|
+
} else if (ch === "/" && code[i + 1] === "*") {
|
|
27
|
+
i += 2;
|
|
28
|
+
while (i < len && !(code[i] === "*" && code[i + 1] === "/"))
|
|
29
|
+
i++;
|
|
30
|
+
i += 2;
|
|
31
|
+
} else if (ch === "(") {
|
|
32
|
+
parenDepth++;
|
|
33
|
+
append(ch);
|
|
34
|
+
i++;
|
|
35
|
+
} else if (ch === ")") {
|
|
36
|
+
parenDepth = Math.max(0, parenDepth - 1);
|
|
37
|
+
append(ch);
|
|
38
|
+
i++;
|
|
39
|
+
} else if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
|
|
40
|
+
while (i < len && (code[i] === " " || code[i] === " " || code[i] === "\n" || code[i] === "\r"))
|
|
41
|
+
i++;
|
|
42
|
+
const next = code[i];
|
|
43
|
+
if (next === "!")
|
|
44
|
+
continue;
|
|
45
|
+
if (parenDepth > 0) {
|
|
46
|
+
if (last && next && !isCSSCalcPunctuation(last) && !isCSSCalcPunctuation(next))
|
|
47
|
+
append(" ");
|
|
48
|
+
} else if (last && next && !isCSSPunctuation(last) && !isCSSPunctuation(next)) {
|
|
49
|
+
append(" ");
|
|
50
|
+
}
|
|
51
|
+
} else if (ch === ";") {
|
|
52
|
+
let j = i + 1;
|
|
53
|
+
while (j < len && (code[j] === " " || code[j] === " " || code[j] === "\n" || code[j] === "\r"))
|
|
54
|
+
j++;
|
|
55
|
+
if (code[j] === "}") {
|
|
56
|
+
i++;
|
|
57
|
+
} else {
|
|
58
|
+
append(ch);
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
} else if (ch === "0" && code[i + 1] === "." && code[i + 2] >= "0" && code[i + 2] <= "9") {
|
|
62
|
+
if (last && last >= "0" && last <= "9") {
|
|
63
|
+
append(ch);
|
|
64
|
+
i++;
|
|
65
|
+
} else {
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
append(ch);
|
|
70
|
+
i++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result.trim();
|
|
74
|
+
}
|
|
75
|
+
function isCSSPunctuation(ch) {
|
|
76
|
+
return ch === "{" || ch === "}" || ch === ";" || ch === ":" || ch === "," || ch === ">" || ch === "~" || ch === "+" || ch === "(" || ch === ")";
|
|
77
|
+
}
|
|
78
|
+
function isCSSCalcPunctuation(ch) {
|
|
79
|
+
return ch === "*" || ch === "/" || ch === "(" || ch === ")" || ch === ",";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function minifyJS(code) {
|
|
83
|
+
if (!/[\s/]/.test(code))
|
|
84
|
+
return code;
|
|
85
|
+
let result = "";
|
|
86
|
+
let last = "";
|
|
87
|
+
let i = 0;
|
|
88
|
+
const len = code.length;
|
|
89
|
+
const append = (value) => {
|
|
90
|
+
result += value;
|
|
91
|
+
last = value;
|
|
92
|
+
};
|
|
93
|
+
while (i < len) {
|
|
94
|
+
const ch = code[i];
|
|
95
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
96
|
+
const quote = ch;
|
|
97
|
+
append(ch);
|
|
98
|
+
i++;
|
|
99
|
+
while (i < len && code[i] !== quote) {
|
|
100
|
+
if (code[i] === "\\" && i + 1 < len) {
|
|
101
|
+
append(code[i++]);
|
|
102
|
+
}
|
|
103
|
+
append(code[i++]);
|
|
104
|
+
}
|
|
105
|
+
if (i < len)
|
|
106
|
+
append(code[i++]);
|
|
107
|
+
} else if (ch === "/" && code[i + 1] === "/") {
|
|
108
|
+
i += 2;
|
|
109
|
+
while (i < len && code[i] !== "\n")
|
|
110
|
+
i++;
|
|
111
|
+
} else if (ch === "/" && code[i + 1] === "*") {
|
|
112
|
+
i += 2;
|
|
113
|
+
while (i < len && !(code[i] === "*" && code[i + 1] === "/"))
|
|
114
|
+
i++;
|
|
115
|
+
i += 2;
|
|
116
|
+
} else if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
|
|
117
|
+
let hasNewline = false;
|
|
118
|
+
while (i < len && (code[i] === " " || code[i] === " " || code[i] === "\n" || code[i] === "\r")) {
|
|
119
|
+
if (code[i] === "\n")
|
|
120
|
+
hasNewline = true;
|
|
121
|
+
i++;
|
|
122
|
+
}
|
|
123
|
+
const next = code[i];
|
|
124
|
+
if (hasNewline && last && next && last !== "{" && last !== "}" && last !== ";" && next !== "}" && next !== ";")
|
|
125
|
+
append("\n");
|
|
126
|
+
else if (last && next && isIdentChar(last) && isIdentChar(next))
|
|
127
|
+
append(" ");
|
|
128
|
+
else if (last && next && (last === "+" && next === "+" || last === "-" && next === "-"))
|
|
129
|
+
append(" ");
|
|
130
|
+
} else {
|
|
131
|
+
append(ch);
|
|
132
|
+
i++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return result.trim();
|
|
136
|
+
}
|
|
137
|
+
function isIdentChar(ch) {
|
|
138
|
+
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_" || ch === "$";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function isJsonWhitespace(char) {
|
|
142
|
+
return char === " " || char === "\n" || char === "\r" || char === " ";
|
|
143
|
+
}
|
|
144
|
+
function minifyJSON(code) {
|
|
145
|
+
let escaped = false;
|
|
146
|
+
let inString = false;
|
|
147
|
+
let segmentStart = 0;
|
|
148
|
+
let chunks;
|
|
149
|
+
for (let i = 0; i < code.length; i++) {
|
|
150
|
+
const char = code[i];
|
|
151
|
+
if (inString) {
|
|
152
|
+
if (escaped)
|
|
153
|
+
escaped = false;
|
|
154
|
+
else if (char === "\\")
|
|
155
|
+
escaped = true;
|
|
156
|
+
else if (char === '"')
|
|
157
|
+
inString = false;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (char === '"') {
|
|
161
|
+
inString = true;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (isJsonWhitespace(char)) {
|
|
165
|
+
chunks ||= [];
|
|
166
|
+
if (segmentStart < i)
|
|
167
|
+
chunks.push(code.slice(segmentStart, i));
|
|
168
|
+
segmentStart = i + 1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!chunks)
|
|
172
|
+
return code;
|
|
173
|
+
try {
|
|
174
|
+
JSON.parse(code);
|
|
175
|
+
} catch {
|
|
176
|
+
return code;
|
|
177
|
+
}
|
|
178
|
+
if (segmentStart < code.length)
|
|
179
|
+
chunks.push(code.slice(segmentStart));
|
|
180
|
+
return chunks.join("");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { minifyCSS, minifyJS, minifyJSON };
|