@sveltejs/kit 1.0.0-next.98 → 1.0.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/README.md +5 -1
- package/package.json +91 -77
- package/postinstall.js +47 -0
- package/src/cli.js +44 -0
- package/src/constants.js +5 -0
- package/src/core/adapt/builder.js +221 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +100 -0
- package/src/core/config/options.js +387 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +138 -0
- package/src/core/generate_manifest/index.js +116 -0
- package/src/core/prerender/crawl.js +207 -0
- package/src/core/prerender/entities.js +2252 -0
- package/src/core/prerender/fallback.js +43 -0
- package/src/core/prerender/prerender.js +459 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/conflict.js +0 -0
- package/src/core/sync/create_manifest_data/index.js +523 -0
- package/src/core/sync/create_manifest_data/sort.js +161 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +33 -0
- package/src/core/sync/write_ambient.js +58 -0
- package/src/core/sync/write_client_manifest.js +107 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +91 -0
- package/src/core/sync/write_tsconfig.js +195 -0
- package/src/core/sync/write_types/index.js +809 -0
- package/src/core/utils.js +67 -0
- package/src/exports/hooks/index.js +1 -0
- package/src/exports/hooks/sequence.js +44 -0
- package/src/exports/index.js +55 -0
- package/src/exports/node/index.js +172 -0
- package/src/exports/node/polyfills.js +28 -0
- package/src/exports/vite/build/build_server.js +359 -0
- package/src/exports/vite/build/build_service_worker.js +85 -0
- package/src/exports/vite/build/utils.js +230 -0
- package/src/exports/vite/dev/index.js +597 -0
- package/src/exports/vite/graph_analysis/index.js +99 -0
- package/src/exports/vite/graph_analysis/types.d.ts +5 -0
- package/src/exports/vite/graph_analysis/utils.js +6 -0
- package/src/exports/vite/index.js +708 -0
- package/src/exports/vite/preview/index.js +194 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +184 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +13 -0
- package/src/runtime/app/forms.js +135 -0
- package/src/runtime/app/navigation.js +22 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +57 -0
- package/src/runtime/client/ambient.d.ts +30 -0
- package/src/runtime/client/client.js +1725 -0
- package/src/runtime/client/constants.js +10 -0
- package/src/runtime/client/fetcher.js +127 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +45 -0
- package/src/runtime/client/types.d.ts +86 -0
- package/src/runtime/client/utils.js +257 -0
- package/src/runtime/components/error.svelte +6 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +45 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +6 -0
- package/src/runtime/env-public.js +6 -0
- package/src/runtime/env.js +12 -0
- package/src/runtime/hash.js +20 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +228 -0
- package/src/runtime/server/data/index.js +158 -0
- package/src/runtime/server/endpoint.js +86 -0
- package/src/runtime/server/fetch.js +175 -0
- package/src/runtime/server/index.js +405 -0
- package/src/runtime/server/page/actions.js +267 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +250 -0
- package/src/runtime/server/page/index.js +326 -0
- package/src/runtime/server/page/load_data.js +270 -0
- package/src/runtime/server/page/render.js +393 -0
- package/src/runtime/server/page/respond_with_error.js +103 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +35 -0
- package/src/runtime/server/utils.js +179 -0
- package/src/utils/array.js +9 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +46 -0
- package/src/utils/exports.js +54 -0
- package/src/utils/filesystem.js +178 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +72 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/promises.js +17 -0
- package/src/utils/routing.js +201 -0
- package/src/utils/unit_test.js +11 -0
- package/src/utils/url.js +161 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +451 -0
- package/types/index.d.ts +1168 -5
- package/types/internal.d.ts +348 -160
- package/types/private.d.ts +237 -0
- package/types/synthetic/$env+dynamic+private.md +10 -0
- package/types/synthetic/$env+dynamic+public.md +8 -0
- package/types/synthetic/$env+static+private.md +19 -0
- package/types/synthetic/$env+static+public.md +7 -0
- package/types/synthetic/$lib.md +5 -0
- package/CHANGELOG.md +0 -819
- package/assets/components/error.svelte +0 -21
- package/assets/runtime/app/env.js +0 -16
- package/assets/runtime/app/navigation.js +0 -53
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -87
- package/assets/runtime/chunks/utils.js +0 -13
- package/assets/runtime/env.js +0 -8
- package/assets/runtime/internal/singletons.js +0 -20
- package/assets/runtime/internal/start.js +0 -1061
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/_commonjsHelpers.js +0 -8
- package/dist/chunks/cert.js +0 -29079
- package/dist/chunks/constants.js +0 -3
- package/dist/chunks/index.js +0 -3526
- package/dist/chunks/index2.js +0 -583
- package/dist/chunks/index3.js +0 -31
- package/dist/chunks/index4.js +0 -1005
- package/dist/chunks/index5.js +0 -327
- package/dist/chunks/index6.js +0 -325
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -149
- package/dist/cli.js +0 -711
- package/dist/http.js +0 -66
- package/dist/install-fetch.js +0 -1699
- package/dist/ssr.js +0 -1529
- package/types/ambient-modules.d.ts +0 -115
- package/types/config.d.ts +0 -101
- package/types/endpoint.d.ts +0 -23
- package/types/helper.d.ts +0 -19
- package/types/hooks.d.ts +0 -23
- package/types/page.d.ts +0 -30
package/dist/chunks/standard.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
|
3
|
-
* @param ...
|
|
4
|
-
*/
|
|
5
|
-
function Mime() {
|
|
6
|
-
this._types = Object.create(null);
|
|
7
|
-
this._extensions = Object.create(null);
|
|
8
|
-
|
|
9
|
-
for (let i = 0; i < arguments.length; i++) {
|
|
10
|
-
this.define(arguments[i]);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
this.define = this.define.bind(this);
|
|
14
|
-
this.getType = this.getType.bind(this);
|
|
15
|
-
this.getExtension = this.getExtension.bind(this);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
|
20
|
-
* to an array of extensions associated with the type. The first extension is
|
|
21
|
-
* used as the default extension for the type.
|
|
22
|
-
*
|
|
23
|
-
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
|
24
|
-
*
|
|
25
|
-
* If a type declares an extension that has already been defined, an error will
|
|
26
|
-
* be thrown. To suppress this error and force the extension to be associated
|
|
27
|
-
* with the new type, pass `force`=true. Alternatively, you may prefix the
|
|
28
|
-
* extension with "*" to map the type to extension, without mapping the
|
|
29
|
-
* extension to the type.
|
|
30
|
-
*
|
|
31
|
-
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param map (Object) type definitions
|
|
35
|
-
* @param force (Boolean) if true, force overriding of existing definitions
|
|
36
|
-
*/
|
|
37
|
-
Mime.prototype.define = function(typeMap, force) {
|
|
38
|
-
for (let type in typeMap) {
|
|
39
|
-
let extensions = typeMap[type].map(function(t) {
|
|
40
|
-
return t.toLowerCase();
|
|
41
|
-
});
|
|
42
|
-
type = type.toLowerCase();
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < extensions.length; i++) {
|
|
45
|
-
const ext = extensions[i];
|
|
46
|
-
|
|
47
|
-
// '*' prefix = not the preferred type for this extension. So fixup the
|
|
48
|
-
// extension, and skip it.
|
|
49
|
-
if (ext[0] === '*') {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!force && (ext in this._types)) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
'Attempt to change mapping for "' + ext +
|
|
56
|
-
'" extension from "' + this._types[ext] + '" to "' + type +
|
|
57
|
-
'". Pass `force=true` to allow this, otherwise remove "' + ext +
|
|
58
|
-
'" from the list of extensions for "' + type + '".'
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this._types[ext] = type;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Use first extension as default
|
|
66
|
-
if (force || !this._extensions[type]) {
|
|
67
|
-
const ext = extensions[0];
|
|
68
|
-
this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Lookup a mime type based on extension
|
|
75
|
-
*/
|
|
76
|
-
Mime.prototype.getType = function(path) {
|
|
77
|
-
path = String(path);
|
|
78
|
-
let last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
|
79
|
-
let ext = last.replace(/^.*\./, '').toLowerCase();
|
|
80
|
-
|
|
81
|
-
let hasPath = last.length < path.length;
|
|
82
|
-
let hasDot = ext.length < last.length - 1;
|
|
83
|
-
|
|
84
|
-
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Return file extension associated with a mime type
|
|
89
|
-
*/
|
|
90
|
-
Mime.prototype.getExtension = function(type) {
|
|
91
|
-
type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
|
|
92
|
-
return type && this._extensions[type.toLowerCase()] || null;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
var Mime_1 = Mime;
|
|
96
|
-
|
|
97
|
-
var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};
|
|
98
|
-
|
|
99
|
-
export { Mime_1 as M, standard as s };
|
package/dist/chunks/utils.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import fs__default from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { $ } from '../cli.js';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
/** @param {string} dir */
|
|
7
|
-
function mkdirp(dir) {
|
|
8
|
-
try {
|
|
9
|
-
fs__default.mkdirSync(dir, { recursive: true });
|
|
10
|
-
} catch (e) {
|
|
11
|
-
if (e.code === 'EEXIST') return;
|
|
12
|
-
throw e;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @param {string} path */
|
|
17
|
-
function rimraf(path) {
|
|
18
|
-
(fs__default.rmSync || fs__default.rmdirSync)(path, { recursive: true, force: true });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {string} from
|
|
23
|
-
* @param {string} to
|
|
24
|
-
* @param {(basename: string) => boolean} filter
|
|
25
|
-
*/
|
|
26
|
-
function copy(from, to, filter = () => true) {
|
|
27
|
-
if (!fs__default.existsSync(from)) return [];
|
|
28
|
-
if (!filter(path.basename(from))) return [];
|
|
29
|
-
|
|
30
|
-
const files = [];
|
|
31
|
-
const stats = fs__default.statSync(from);
|
|
32
|
-
|
|
33
|
-
if (stats.isDirectory()) {
|
|
34
|
-
fs__default.readdirSync(from).forEach((file) => {
|
|
35
|
-
files.push(...copy(path.join(from, file), path.join(to, file)));
|
|
36
|
-
});
|
|
37
|
-
} else {
|
|
38
|
-
mkdirp(path.dirname(to));
|
|
39
|
-
fs__default.copyFileSync(from, to);
|
|
40
|
-
files.push(to);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return files;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
47
|
-
const __dirname = path.dirname(__filename);
|
|
48
|
-
|
|
49
|
-
/** @param {string} dest */
|
|
50
|
-
function copy_assets(dest) {
|
|
51
|
-
let prefix = '..';
|
|
52
|
-
do {
|
|
53
|
-
// we jump through these hoops so that this function
|
|
54
|
-
// works whether or not it's been bundled
|
|
55
|
-
const resolved = path.resolve(__dirname, `${prefix}/assets`);
|
|
56
|
-
|
|
57
|
-
if (fs__default.existsSync(resolved)) {
|
|
58
|
-
copy(resolved, dest);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
prefix = `../${prefix}`;
|
|
63
|
-
} while (true); // eslint-disable-line
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function noop() {}
|
|
67
|
-
|
|
68
|
-
/** @param {{ verbose: boolean }} opts */
|
|
69
|
-
function logger({ verbose }) {
|
|
70
|
-
/** @type {import('types/internal').Logger} */
|
|
71
|
-
const log = (msg) => console.log(msg.replace(/^/gm, ' '));
|
|
72
|
-
|
|
73
|
-
log.success = (msg) => log($.green(`✔ ${msg}`));
|
|
74
|
-
log.error = (msg) => log($.bold().red(msg));
|
|
75
|
-
log.warn = (msg) => log($.bold().yellow(msg));
|
|
76
|
-
|
|
77
|
-
log.minor = verbose ? (msg) => log($.grey(msg)) : noop;
|
|
78
|
-
log.info = verbose ? log : noop;
|
|
79
|
-
|
|
80
|
-
return log;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
|
|
85
|
-
* @param {string} entry
|
|
86
|
-
* @returns {string}
|
|
87
|
-
*/
|
|
88
|
-
function resolve_entry(entry) {
|
|
89
|
-
if (fs__default.existsSync(entry)) {
|
|
90
|
-
const stats = fs__default.statSync(entry);
|
|
91
|
-
if (stats.isDirectory()) {
|
|
92
|
-
return resolve_entry(path.join(entry, 'index'));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return entry;
|
|
96
|
-
} else {
|
|
97
|
-
const dir = path.dirname(entry);
|
|
98
|
-
|
|
99
|
-
if (fs__default.existsSync(dir)) {
|
|
100
|
-
const base = path.basename(entry);
|
|
101
|
-
const files = fs__default.readdirSync(dir);
|
|
102
|
-
|
|
103
|
-
const found = files.find((file) => file.replace(/\.[^.]+$/, '') === base);
|
|
104
|
-
|
|
105
|
-
if (found) return path.join(dir, found);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** @param {string} str */
|
|
113
|
-
function posixify(str) {
|
|
114
|
-
return str.replace(/\\/g, '/');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Get a list of packages that use pkg.svelte, so they can be added
|
|
119
|
-
* to ssr.noExternal. This is done on a best-effort basis to reduce
|
|
120
|
-
* the frequency of 'Must use import to load ES Module' and similar
|
|
121
|
-
* @param {string} cwd
|
|
122
|
-
* @returns {string[]}
|
|
123
|
-
*/
|
|
124
|
-
function find_svelte_packages(cwd) {
|
|
125
|
-
const pkg_file = path.join(cwd, 'package.json');
|
|
126
|
-
if (!fs__default.existsSync(pkg_file)) return [];
|
|
127
|
-
|
|
128
|
-
const pkg = JSON.parse(fs__default.readFileSync(pkg_file, 'utf8'));
|
|
129
|
-
|
|
130
|
-
const deps = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
|
|
131
|
-
|
|
132
|
-
return deps.filter((dep) => {
|
|
133
|
-
const dep_pkg_file = path.join(cwd, 'node_modules', dep, 'package.json');
|
|
134
|
-
if (!fs__default.existsSync(dep_pkg_file)) return false;
|
|
135
|
-
|
|
136
|
-
const dep_pkg = JSON.parse(fs__default.readFileSync(dep_pkg_file, 'utf-8'));
|
|
137
|
-
return !!dep_pkg.svelte;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* @param {string} cwd
|
|
143
|
-
* @param {string[]} [user_specified_deps]
|
|
144
|
-
*/
|
|
145
|
-
function get_no_external(cwd, user_specified_deps = []) {
|
|
146
|
-
return [...user_specified_deps, ...find_svelte_packages(cwd)];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export { resolve_entry as a, copy as b, copy_assets as c, get_no_external as g, logger as l, mkdirp as m, posixify as p, rimraf as r };
|