gemi 0.46.0 → 0.47.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.
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../client/useQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMzC,UAAU,MAAM,CAAC,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AAgBD,KAAK,MAAM,GAAG;KACX,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,SAAS,OAAO,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;CACnE,CAAC;AAEF,KAAK,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,IAC9B,MAAM,CAAC,CAAC,CAAC,SAAS,gBAAgB,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AASzF,KA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,CAAC,CAAC;KAC9C;IACD,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACzB;UAiPsB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;WAErB,KAAK;;cA9CT,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;cAC9B,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;;;;aAiDzD,MAAM;EAEpC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Transport-level compression for SSR HTML responses.
3
+ *
4
+ * This lives in the runtime rather than in an app, because every gemi app
5
+ * serves the same shape of response: a streamed `text/html` document whose
6
+ * bulk is critical CSS, markup and the `window.__GEMI_DATA__` hydration
7
+ * payload. Compressing it here means the win is portable across deployments —
8
+ * it does not depend on a CDN being configured to compress on the origin's
9
+ * behalf — and it also cuts origin→edge bandwidth, which edge compression
10
+ * cannot.
11
+ *
12
+ * Compression stays strictly at the transport layer: what the client decodes
13
+ * is byte-for-byte the HTML React rendered, so hydration is unaffected.
14
+ *
15
+ * Deliberately dependency-free apart from `node:zlib`/`node:stream` so it can
16
+ * be unit tested without booting a server.
17
+ */
18
+ /** The content codings we can produce, in the order we prefer them. */
19
+ export type ContentEncoding = "br" | "gzip";
20
+ /**
21
+ * Parses a request `Accept-Encoding` into `coding -> qvalue`.
22
+ *
23
+ * Returns `null` when the header is *absent*, which is distinct from an empty
24
+ * one. RFC 9110 §12.5.3 says an absent header means any coding is acceptable,
25
+ * but a client that cannot decode and forgets to say so is a broken page, not
26
+ * a slow one — so we treat "absent" as "identity" and only encode when a
27
+ * client has explicitly opted in. An empty header (`Accept-Encoding:`) is a
28
+ * deliberate "identity only" and parses to an empty map.
29
+ */
30
+ export declare function parseAcceptEncoding(header: string | null | undefined): Map<string, number> | null;
31
+ /**
32
+ * Picks the coding to use, or `null` for identity.
33
+ *
34
+ * A `q=0` is a refusal, `*` covers codings the client did not name, and ties
35
+ * fall back to `available`'s order — so a plain `Accept-Encoding: gzip, br`
36
+ * (equal q of 1) resolves to our preference rather than the client's.
37
+ */
38
+ export declare function negotiateEncoding(header: string | null | undefined, available?: ContentEncoding[]): ContentEncoding | null;
39
+ /**
40
+ * Whether this response's representation is one we may encode — and therefore
41
+ * one that varies by `Accept-Encoding`, even on the requests where we end up
42
+ * sending identity.
43
+ *
44
+ * HTML only, on purpose. JSON view-data and API responses are left alone so
45
+ * that this change cannot alter how they are produced, framed or cached;
46
+ * widening the set is a separate decision.
47
+ */
48
+ export declare function isCompressible(method: string, res: Response): boolean;
49
+ /**
50
+ * Builds the encoder as a web `TransformStream`-shaped pair.
51
+ *
52
+ * Both codings are driven through `node:zlib` with an explicit per-write flush.
53
+ * Without it the compressor holds output until its internal buffer fills,
54
+ * which would sit on React's shell flush and turn a streamed render into a
55
+ * buffered one — the compression win would be paid for in time to first byte.
56
+ */
57
+ export declare function createEncoderStream(encoding: ContentEncoding): ReadableWritablePair<Uint8Array, Uint8Array>;
58
+ /**
59
+ * Compresses an SSR HTML response when the client asked for it.
60
+ *
61
+ * Non-HTML responses are returned untouched — same object, same body, so this
62
+ * is safe to apply at the edge of the server for every request.
63
+ *
64
+ * HTML responses always gain `Vary: Accept-Encoding`, whether or not this
65
+ * particular request got an encoded body: without it a shared cache could
66
+ * serve a stored encoded variant to a client that cannot decode it.
67
+ */
68
+ export declare function compressResponse(req: Request, res: Response): Response;
69
+ //# sourceMappingURL=compression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../../server/compression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,CAAC;AAgD5C;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CA6BjG;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,SAAS,GAAE,eAAe,EAAsB,GAC/C,eAAe,GAAG,IAAI,CAmBxB;AAaD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CA6CrE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAYb,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAC3F;AAiBD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAwCtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"httpProd.d.ts","sourceRoot":"","sources":["../../server/httpProd.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAc1C,wBAAsB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,kCA8LxE"}
1
+ {"version":3,"file":"httpProd.d.ts","sourceRoot":"","sources":["../../server/httpProd.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAc1C,wBAAsB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,kCAwMxE"}
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{n as g}from"../chunk-ppt296ye.js";import{o as b}from"../chunk-r64ba1pf.js";import"../chunk-d9k245jt.js";import"../chunk-evkv0xa7.js";import"../chunk-p5r0t9jh.js";import"../chunk-xkrthw08.js";import"../chunk-4z53shav.js";import"../chunk-m0earq80.js";import{ic as S}from"../chunk-f18weffa.js";class i{app;instrumentation;constructor(f){this.app=new b({kernel:f.kernel}),this.instrumentation=f.instrumentation??((z,B)=>B(z))}async start(){if(Bun.env.NODE_ENV==="production"){let{httpProd:f}=await import("../chunk-zp9ybbp6.js");await f(this.app,this.instrumentation.bind(this))}else{g();let{httpDev:f}=await import("../chunk-qmsngk2y.js");await f(this.app,this.instrumentation.bind(this))}}}export{i as Server};
2
+ import{n as g}from"../chunk-ppt296ye.js";import{o as b}from"../chunk-r64ba1pf.js";import"../chunk-d9k245jt.js";import"../chunk-evkv0xa7.js";import"../chunk-p5r0t9jh.js";import"../chunk-xkrthw08.js";import"../chunk-4z53shav.js";import"../chunk-m0earq80.js";import{ic as S}from"../chunk-f18weffa.js";class i{app;instrumentation;constructor(f){this.app=new b({kernel:f.kernel}),this.instrumentation=f.instrumentation??((z,B)=>B(z))}async start(){if(Bun.env.NODE_ENV==="production"){let{httpProd:f}=await import("../chunk-3wjd8x9t.js");await f(this.app,this.instrumentation.bind(this))}else{g();let{httpDev:f}=await import("../chunk-732aak4d.js");await f(this.app,this.instrumentation.bind(this))}}}export{i as Server};
3
3
 
4
4
  //# debugId=7F0F14957FE1591264756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.46.0",
3
+ "version": "0.47.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{h as g,i as R}from"./chunk-3ervqphj.js";import"./chunk-ppt296ye.js";import{K,M as W}from"./chunk-d9k245jt.js";import"./chunk-evkv0xa7.js";import"./chunk-p5r0t9jh.js";import"./chunk-4z53shav.js";import"./chunk-m0earq80.js";import"./chunk-f18weffa.js";import{join as j}from"path";function V(J){let x=J.toString(),Q=new Bun.CryptoHasher("sha1");return Q.update(x),Q.digest("hex")}if(!globalThis.URLPattern)globalThis.URLPattern=K;import{exists as v}from"fs/promises";var u=process.env.GEMI_PROJECT_DIR??"",T=j(process.cwd(),u),F=j(T,"app"),$=j(T,"dist");async function a(J,x){let Q=await import(`${$}/client/.vite/manifest.json`),O=await import(`${$}/server/.vite/manifest.json`);process.env.ROOT_DIR=T,process.env.APP_DIR=F,process.env.DIST_DIR=$;let A={},C={},I={},S=(b,L)=>`"${b}": () => import("${L}")`,_=[];for(let b of["404",...J.getFlatComponentTree.call(J)]){let L=O[`app/views/${b}.tsx`];if(!L?.file){console.log(`Server file not found for ${b}`),console.log(L);let U=Object.keys(O),Y=`app/views/${b}.tsx`;console.log(`${Y} not found in server manifest`),console.log(U)}let z=await import(`${process.env.DIST_DIR}/server/${L?.file}`);A[b]=z.default,C[b]=z.OpenGraph;let k=Q[`app/views/${b}.tsx`];if(k?.css&&k?.css.length>0)I[b]=k?.css;if(k)_.push(S(b,`/${k?.file}`))}let N=`{${_.join(",")}}`,w=Q["app/client.tsx"]?.css??[],M=(await Promise.all(w.map((b)=>Bun.file(`${$}/client/${b}`).text()))).join(`
3
- `),D=new K({pathname:"/*.:filetype(png|txt|js|css|jpg|svg|jpeg|avif|webp|ico|ttf|map)"});async function E(b){let{pathname:L}=new URL(b.url),z=L.startsWith("/.well-known"),k=D.test({pathname:L})||z,U=L.startsWith("/api");if(k&&!U){let Y=new URL(b.url),B=b.url.replace(Y.origin,"").split("?")[0],Z=`${$}/client${B.replace("/assets/assets","/assets")}`,H=await v(Z);if(!H&&Y.pathname.includes(".js"))return new Response(`if(caches){caches?.delete("${Z}")}window.location.reload();export {}`,{headers:{"Content-Type":"application/javascript"}});if(!H){if(L===W||L.startsWith(`${W}/`))return new Response("Not found",{status:404});return await y(b,L)}try{let G=Bun.file(Z),X=V(G.lastModified);return new Response(G.stream(),{headers:{"Content-Type":G.type,"Cache-Control":"public, max-age=31536000, must-revalidate","Content-Length":String(G.size),ETag:X}})}catch(G){return J.onException?.(G),new Response("Not found",{status:404})}}return await y(b,L)}async function y(b,L){let z=J.fetch.bind(J);try{let k=await z(b);if(k instanceof Response)return k;else{let U=[];return U.push({content:M}),await k({getStyles:async(B)=>{if(!B)return g([]);for(let Z of B){let H=Q[`app/views/${Z}.tsx`];for(let G of H?.css??[]){let X=Bun.file(`${process.env.DIST_DIR}/client/${G}`);U.push({id:G,content:await X.text()})}}return g(U)},bootstrapModules:[`/${Q["app/client.tsx"].file}`],loaders:N,viewImportMap:A,ogMap:C,cssManifest:I})}}catch(k){if(console.error(k),L.startsWith("/api"))return new Response(JSON.stringify({error:k.message}),{status:500,headers:{"Content-Type":"application/json"}});return J.onException?.(k),new Response(k.stack,{status:500})}}let P=Bun.serve({maxRequestBodySize:10737418240,fetch:async(b,L)=>{if(!b.headers.get("x-forwarded-for")){let z=L.requestIP(b);if(z)b.headers.set("x-forwarded-for",z.address)}return await x(b,E)},idleTimeout:Number(process.env.SERVER_IDLE_TIMEOUT??10),port:process.env.PORT||5173});return R({port:P.port,rootDir:T}),P}export{a as httpProd};
4
-
5
- //# debugId=B6DC0792DD8A023A64756E2164756E21
@@ -1,12 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../server/httpProd.ts", "../server/generateEtag.ts", "../../../node_modules/.bun/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.js"],
4
- "sourcesContent": [
5
- "import { join } from \"node:path\";\nimport { generateETag } from \"./generateEtag\";\nimport { URLPattern } from \"urlpattern-polyfill\";\nimport { exists } from \"node:fs/promises\";\nimport { createStyles } from \"./styles\";\nimport type { App } from \"../app\";\nimport { Instrumentation } from \"./types\";\nimport { printStartupBanner } from \"./banner\";\nimport { RESERVED_ROUTE_PREFIX } from \"../services/router/ViewRouterServiceContainer\";\n\nconst projectDir = process.env.GEMI_PROJECT_DIR ?? \"\";\nconst rootDir = join(process.cwd(), projectDir);\n\nconst appDir = join(rootDir, \"app\");\nconst distDir = join(rootDir, \"dist\");\n\n// `app` is built by `Server.start` (from the kernel) and passed in — same as\n// `httpDev` — so prod and dev share one construction path. What differs here is\n// that views/styles are served from the built `dist/` manifests instead of\n// Vite's dev SSR graph.\nexport async function httpProd(app: App, instrumentation: Instrumentation) {\n const manifest = await import(`${distDir}/client/.vite/manifest.json`);\n const serverManifest = await import(`${distDir}/server/.vite/manifest.json`);\n\n process.env.ROOT_DIR = rootDir;\n process.env.APP_DIR = appDir;\n process.env.DIST_DIR = distDir;\n\n const viewImportMap = {};\n const ogMap = {};\n const cssManifest = {};\n const template = (viewName: string, path: string) => `\"${viewName}\": () => import(\"${path}\")`;\n const templates = [];\n\n for (const fileName of [\"404\", ...app.getFlatComponentTree.call(app)]) {\n const serverFile = serverManifest[`app/views/${fileName}.tsx`];\n if (!serverFile?.file) {\n console.log(`Server file not found for ${fileName}`);\n console.log(serverFile);\n const files = Object.keys(serverManifest);\n const path = `app/views/${fileName}.tsx`;\n console.log(`${path} not found in server manifest`);\n console.log(files);\n }\n const mod = await import(`${process.env.DIST_DIR}/server/${serverFile?.file}`);\n viewImportMap[fileName] = mod.default;\n ogMap[fileName] = mod.OpenGraph;\n const clientFile = manifest[`app/views/${fileName}.tsx`];\n\n if (clientFile?.css && clientFile?.css.length > 0) {\n cssManifest[fileName] = clientFile?.css;\n }\n if (clientFile) {\n templates.push(template(fileName, `/${clientFile?.file}`));\n }\n }\n\n const loaders = `{${templates.join(\",\")}}`;\n\n // Vite's manifest `css` field is a `string[]` — a client entry can emit more\n // than one CSS chunk. Read and concatenate them all instead of interpolating\n // the array into a single path (which only works for a one-element array).\n const appCssFiles: string[] = manifest[\"app/client.tsx\"]?.css ?? [];\n const appCSSContent = (\n await Promise.all(appCssFiles.map((cssFile) => Bun.file(`${distDir}/client/${cssFile}`).text()))\n ).join(\"\\n\");\n\n const staticFilePattern = new URLPattern({\n pathname: \"/*.:filetype(png|txt|js|css|jpg|svg|jpeg|avif|webp|ico|ttf|map)\",\n });\n\n async function requestHandler(req: Request) {\n const { pathname } = new URL(req.url);\n\n const isWellKnownFile = pathname.startsWith(\"/.well-known\");\n const isFileRequest = staticFilePattern.test({ pathname }) || isWellKnownFile;\n\n const isApi = pathname.startsWith(\"/api\");\n\n if (isFileRequest && !isApi) {\n const url = new URL(req.url);\n const filePath = req.url.replace(url.origin, \"\").split(\"?\")[0];\n const distPath = `${distDir}/client${filePath.replace(\"/assets/assets\", \"/assets\")}`;\n const doesExist = await exists(distPath);\n\n if (!doesExist && url.pathname.includes(\".js\")) {\n return new Response(\n `if(caches){caches?.delete(\"${distPath}\")}window.location.reload();export {}`,\n {\n headers: { \"Content-Type\": \"application/javascript\" },\n },\n );\n }\n\n if (!doesExist) {\n // `/assets` is reserved for build output (the router rejects routes\n // there at boot), so a miss is a miss — 404 without paying for an SSR\n // render.\n if (\n pathname === RESERVED_ROUTE_PREFIX ||\n pathname.startsWith(`${RESERVED_ROUTE_PREFIX}/`)\n ) {\n return new Response(\"Not found\", { status: 404 });\n }\n\n // Anywhere else the pattern above matched on extension alone, so this\n // may well be an app route — a file route like\n // `this.file(() => Bun.file(...))` mounted at `/files/logo.svg` lands\n // here too. Hand it to the app rather than 404ing on its behalf.\n return await handleWithApp(req, pathname);\n }\n\n // `Bun.file(path).stream()` is lazy — a missing file only throws ENOENT\n // once the body is streamed, which is *after* this handler has returned,\n // so the `try/catch` below can't catch it (it surfaces as an unhandled\n // rejection with the response already committed as 200). Never build the\n // streaming Response without checking existence first.\n\n try {\n const file = Bun.file(distPath);\n\n const etag = generateETag(file.lastModified);\n return new Response(file.stream(), {\n headers: {\n \"Content-Type\": file.type,\n \"Cache-Control\": \"public, max-age=31536000, must-revalidate\",\n \"Content-Length\": String(file.size),\n ETag: etag,\n },\n });\n } catch (error) {\n app.onException?.(error);\n return new Response(\"Not found\", { status: 404 });\n }\n }\n\n return await handleWithApp(req, pathname);\n }\n\n async function handleWithApp(req: Request, pathname: string) {\n const handler = app.fetch.bind(app);\n\n try {\n const result = await handler(req);\n if (result instanceof Response) {\n return result;\n } else {\n const styles = [];\n\n styles.push({\n content: appCSSContent,\n });\n\n const getStyles = async (currentViews: string[]) => {\n if (!currentViews) {\n return createStyles([]);\n }\n for (const view of currentViews) {\n const clientFile = manifest[`app/views/${view}.tsx`];\n for (const cssFile of clientFile?.css ?? []) {\n const css = Bun.file(`${process.env.DIST_DIR}/client/${cssFile}`);\n styles.push({\n id: cssFile,\n content: await css.text(),\n });\n }\n }\n return createStyles(styles);\n };\n\n return await result({\n getStyles,\n bootstrapModules: [`/${manifest[\"app/client.tsx\"].file}`],\n loaders,\n viewImportMap,\n ogMap,\n cssManifest,\n });\n }\n } catch (err) {\n console.error(err);\n if (pathname.startsWith(\"/api\")) {\n return new Response(JSON.stringify({ error: err.message }), {\n status: 500,\n headers: { \"Content-Type\": \"application/json\" },\n });\n }\n app.onException?.(err);\n return new Response(err.stack, { status: 500 });\n }\n }\n\n const server = Bun.serve({\n maxRequestBodySize: 10 * 1024 * 1024 * 1024, // 10 GB\n fetch: async (req, server) => {\n if (!req.headers.get(\"x-forwarded-for\")) {\n // `requestIP` is null for closed/unix sockets — guard so it never\n // throws before the request is handled.\n const ip = server.requestIP(req);\n if (ip) req.headers.set(\"x-forwarded-for\", ip.address);\n }\n return await instrumentation(req, requestHandler);\n },\n idleTimeout: Number(process.env.SERVER_IDLE_TIMEOUT ?? 10),\n port: process.env.PORT || 5173,\n });\n\n printStartupBanner({ port: server.port, rootDir });\n\n return server;\n}\n",
6
- "export function generateETag(lastModified: number): string {\n // Assuming the last modified timestamp is in milliseconds\n const lastModifiedStr = lastModified.toString();\n\n const hasher = new Bun.CryptoHasher(\"sha1\");\n hasher.update(lastModifiedStr);\n const hash = hasher.digest(\"hex\");\n\n return hash;\n}\n",
7
- "import { URLPattern } from \"./dist/urlpattern.js\";\n\nexport { URLPattern };\n\nif (!globalThis.URLPattern) {\n globalThis.URLPattern = URLPattern;\n}\n"
8
- ],
9
- "mappings": ";2SAAA,SAA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