@luna-park/plugin 1.3.0 → 1.4.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/bin/preview.js +50 -50
- package/dist/dist-hc-SHkAg.mjs +600 -0
- package/dist/extractor.d.mts +85 -0
- package/dist/extractor.mjs +611 -0
- package/dist/index-X3hhfmWd.d.mts +368 -0
- package/dist/index.d.mts +941 -0
- package/dist/index.mjs +887 -0
- package/dist/preview.d.mts +8 -0
- package/dist/preview.mjs +47 -0
- package/dist/style.css +8 -0
- package/package.json +35 -36
- package/dist/chunk-rCEYsGS8.cjs +0 -1
- package/dist/dist-BUZt4gnZ.js +0 -421
- package/dist/dist-BkSFkjuo.cjs +0 -5
- package/dist/extractor.cjs +0 -14
- package/dist/extractor.d.ts +0 -247
- package/dist/extractor.js +0 -512
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -1464
- package/dist/index.js +0 -2961
- package/dist/plugin.css +0 -2
- package/dist/preview.cjs +0 -1
- package/dist/preview.d.ts +0 -7
- package/dist/preview.js +0 -29
package/dist/plugin.css
DELETED
package/dist/preview.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-rCEYsGS8.cjs`);let t=require(`path`),n=require(`fs`),r=require(`@fastify/cors`);r=e.n(r);let i=require(`@fastify/static`);i=e.n(i);let a=require(`fastify`);a=e.n(a);function o(e,t){return e.replace(/\bimport\s+(.*?)\s+from\s+['"]([^.'/][^'"]*)['"];/g,(e,n,r)=>t.includes(r)?e:`import ${n} from 'https://esm.sh/${r}';`).replace(/\bimport\s+['"]([^.'/][^'"]*)['"];/g,(e,n)=>t.includes(n)?e:`import 'https://esm.sh/${n}';`)}async function s(e){let s=(0,a.default)({logger:!1});s.register(r.default,{origin:[`https://luna-park.app`,/localhost:[0-9]+/,/127\.0\.0\.1:[0-9]+/]}),s.addHook(`onRequest`,async(r,i)=>{let a=r.url===`/`?`/index.js`:r.url,s=(0,t.join)(e.dist,a);if(!(0,n.existsSync)(s)&&!(0,t.extname)(r.url)&&(s=(0,t.join)(e.dist,`index.js`)),(0,n.existsSync)(s)&&(0,t.extname)(s)===`.js`){let t=o((0,n.readFileSync)(s,`utf-8`),e.externals).replaceAll(`process.env.NODE_ENV`,JSON.stringify(`development`));return i.type(`application/javascript`).send(t),i}}),s.register(i.default,{prefix:`/`,root:e.dist}),await s.listen({host:`127.0.0.1`,port:e.port}),console.log(`Preview server started at http://127.0.0.1:${e.port}`)}exports.startPreviewServer=s;
|
package/dist/preview.d.ts
DELETED
package/dist/preview.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { extname, join } from "path";
|
|
2
|
-
import { existsSync, readFileSync } from "fs";
|
|
3
|
-
import fastifyCors from "@fastify/cors";
|
|
4
|
-
import fastifyStatic from "@fastify/static";
|
|
5
|
-
import Fastify from "fastify";
|
|
6
|
-
function transformImports(e, n) {
|
|
7
|
-
return e.replace(/\bimport\s+(.*?)\s+from\s+['"]([^.'/][^'"]*)['"];/g, (e, r, i) => n.includes(i) ? e : `import ${r} from 'https://esm.sh/${i}';`).replace(/\bimport\s+['"]([^.'/][^'"]*)['"];/g, (e, r) => n.includes(r) ? e : `import 'https://esm.sh/${r}';`);
|
|
8
|
-
}
|
|
9
|
-
async function startPreviewServer(c) {
|
|
10
|
-
let l = Fastify({ logger: !1 });
|
|
11
|
-
l.register(fastifyCors, { origin: [
|
|
12
|
-
"https://luna-park.app",
|
|
13
|
-
/localhost:[0-9]+/,
|
|
14
|
-
/127\.0\.0\.1:[0-9]+/
|
|
15
|
-
] }), l.addHook("onRequest", async (a, o) => {
|
|
16
|
-
let s = a.url === "/" ? "/index.js" : a.url, l = join(c.dist, s);
|
|
17
|
-
if (!existsSync(l) && !extname(a.url) && (l = join(c.dist, "index.js")), existsSync(l) && extname(l) === ".js") {
|
|
18
|
-
let e = transformImports(readFileSync(l, "utf-8"), c.externals).replaceAll("process.env.NODE_ENV", JSON.stringify("development"));
|
|
19
|
-
return o.type("application/javascript").send(e), o;
|
|
20
|
-
}
|
|
21
|
-
}), l.register(fastifyStatic, {
|
|
22
|
-
prefix: "/",
|
|
23
|
-
root: c.dist
|
|
24
|
-
}), await l.listen({
|
|
25
|
-
host: "127.0.0.1",
|
|
26
|
-
port: c.port
|
|
27
|
-
}), console.log(`Preview server started at http://127.0.0.1:${c.port}`);
|
|
28
|
-
}
|
|
29
|
-
export { startPreviewServer };
|