@blocklet/pages-kit-inner-components 0.1.6 → 0.1.7

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,29 +0,0 @@
1
- "use strict";const v=require("@blocklet/pages-kit/builtin/utils"),N=require("@blocklet/pages-kit/types"),O=require("@blocklet/pages-kit/utils/property"),S=require("@blocklet/quickjs"),q=require("@blocklet/sdk/lib/config"),F=require("lru-cache"),I=require("node-fetch"),C=require("ufo"),B=require("@blocklet/logger"),K=require("@blocklet/pages-kit/utils/builtin"),Q=require("@blocklet/pages-kit/utils/typescript/builtin-module-transformer"),J=require("autoprefixer"),V=require("esbuild"),A=require("postcss"),G=require("tailwindcss"),W=require("typescript"),h=e=>e&&e.__esModule?e:{default:e};function H(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const T=h(q),z=h(I),X=h(B),Y=h(J),Z=H(V),ee=h(A),te=h(G),m=h(W),f=X.default("pages-kit"),oe=async(e,{componentId:t})=>{const o=`@tailwind components;
2
- @tailwind utilities;
3
- `,n=`.CustomComponent_${t}`;return(await ee.default([te.default({content:[{raw:e,extension:"tsx"}]}),Y.default({overrideBrowserslist:["> 1%","last 2 versions"],stats:{}}),i=>{i.walkRules(r=>{r.selectors=r.selectors.map(s=>s.replace(/\.(.+)/g,`${n}.$1,${n} .$1`))})}]).process(o)).css},ne=async(e,{componentId:t})=>{const o=await oe(e,{componentId:t});return`export const __PagesKit_CSS__ = ${JSON.stringify(o)};
4
-
5
- ${e}
6
- `},j=S.memoize(async(e,t)=>{let o=m.default.transpileModule(e,{compilerOptions:{jsx:m.default.JsxEmit.React,target:m.default.ScriptTarget.ES2016,module:m.default.ModuleKind.ESNext},transformers:{before:[Q.createBuiltinModuleTransformer(m.default)]}}).outputText;if(t.tailwind&&(o=await ne(o,{componentId:t.componentId})),t.module===N.PreloadComponentScriptModule.ESM)return o;const n=m.default.transpileModule(o,{compilerOptions:{jsx:m.default.JsxEmit.React,target:m.default.ScriptTarget.ES2016,module:m.default.ModuleKind.CommonJS,moduleResolution:m.default.ModuleResolutionKind.Node16}}).outputText;return se(t.moduleName,n)},{keyGenerator:(e,t)=>JSON.stringify(["transpileModule",e,t])}),re=async(e,t)=>{var r,s;const n=(s=(r=(await Z.build({entryPoints:["index.tsx"],external:Object.keys(K.BuiltinModules),format:"esm",target:"es2020",bundle:!0,write:!1,plugins:[{name:"vfs",setup(u){u.onResolve({filter:/.*/},c=>c.path==="index.tsx"?{path:"index.tsx",namespace:"vfs"}:c.path==="./component"?{path:"component.tsx",namespace:"vfs"}:null),u.onLoad({filter:/.*/,namespace:"vfs"},async c=>c.path==="index.tsx"?{contents:`export { ${t} } from './component'`,loader:"tsx"}:c.path==="component.tsx"?{contents:e,loader:"tsx"}:(console.warn("onLoad 11111111",c.path),null))}}]})).outputFiles)==null?void 0:r[0])==null?void 0:s.contents;if(!n)throw new Error("Failed to build server code");const a=Buffer.from(n).toString();return m.default.transpileModule(a,{compilerOptions:{module:m.default.ModuleKind.ESNext,target:m.default.ScriptTarget.ES2020}}).outputText},R=S.memoize(async(e,t)=>{const o=await re(e,t);return new RegExp(`export\\s+\\{\\s+${t}\\s+\\}`,"m").test(o)?o:void 0},{keyGenerator:(e,t)=>JSON.stringify(["extractExportValueSchema",e,t])}),se=(e,t)=>`// GENERATED FILE. DO NOT EDIT.
7
- var ${e} = function () {
8
- return (function(exports) {
9
- ${t}
10
- return exports
11
- })({})
12
- };
13
- `,w=new F.LRUCache({max:100}),$=60*60,M=60;function k(e){f.info("clear preload components cache",{cacheKey:e}),w.delete(e)}function ce(e){for(const t of w.keys())t.includes(e)&&(f.info("clear preload components cache",{cacheKey:t}),k(t))}function L({mode:e,instanceId:t,componentId:o,locale:n}){return["getPreloadComponents",e,t,o,n].join("-")}async function ae({mode:e,req:t,state:o,locale:n,instances:a,module:i}){const{supportedLocales:r,config:{defaultLocale:s}}=o;if(!s)return null;const u=(await Promise.all(a.map(async p=>{const d=L({mode:e,instanceId:p.id,componentId:p.componentId,locale:n});if(e!=="draft"&&p.useCache&&w.has(d))return f.info(`get preload component from cache: ${d}`),w.get(d);const _=y({state:o,componentId:p.componentId});if(!_)return null;const E=await U({req:t,state:o,componentId:_.id,locale:n,defaultLocale:s,properties:p.properties});if(!E)return null;const b={instanceId:p.id,preload:E};if(e!=="draft"&&p.useCache){let P=$;p.cacheDuration&&(P=p.cacheDuration),f.info(`set preload component to cache(${P}s): ${d}`),w.set(d,b,{ttl:P*1e3})}return b}))).filter(p=>!!p),c=Object.values(u.reduce((p,d)=>({...p,...d.preload.components}),{}));async function l(){const p=await Promise.all(c.map(async d=>{const _=O.componentUMDName({componentId:d.component.id}),E=i===N.PreloadComponentScriptModule.ESM?{module:i,script:await j(d.script,{componentId:d.component.id,module:i,tailwind:e!=="draft"})}:{module:i,script:await j(d.script,{componentId:d.component.id,module:i,moduleName:_,tailwind:e!=="draft"}),moduleName:_};return[d.component.id,{component:d.component,script:E}]}));return Object.fromEntries(p)}const g=await l();return{config:{defaultLocale:s,supportedLocales:r},components:g,instances:u.map(p=>({id:p.instanceId,componentId:p.preload.component.id,locales:{[p.preload.locale]:{props:p.preload.props}}}))}}async function U({req:e,state:t,componentId:o,locale:n,defaultLocale:a,properties:i}){const{supportedLocales:r}=t,s=y({state:t,componentId:o});if(!s)return null;const u=r.some(l=>l.locale===n)?n:a;if(!u)return null;const c=await D({req:e,state:t,componentId:o,locale:u,defaultLocale:a,properties:i});return c?{component:s,...c}:null}const ie=20;async function D({req:e,depth:t=0,state:o,componentId:n,locale:a,defaultLocale:i,properties:r}){if(t>ie)throw new RangeError("max component depth exceeded");const s=pe({state:o,componentId:n,properties:r,locale:a});if(!s)return null;const{props:u}=s,c={locale:a||i,components:{[s.component.id]:{component:s.component,script:s.script}},props:{...u}};try{const l=await le({...s,req:e});l!=null&&l.props&&Object.assign(c.props,l.props)}catch(l){f.error("preload data at server side error",{componentId:n,name:s.component.name},{error:l})}return await Promise.all(Object.entries(u).map(async([l,g])=>{if((g==null?void 0:g.type)===O.RenderNestedComponent){const x=await D({req:e,depth:t+1,state:o,componentId:g.componentId,locale:a,defaultLocale:i,properties:g.properties});x&&(Object.assign(c.components,x.components),Object.assign(c.props,{[l]:{type:O.RenderNestedComponent,componentId:g.componentId,props:x.props}}))}})),c}function pe({state:e,componentId:t,locale:o,properties:n}){const a=y({state:e,componentId:t});if(!a)return null;const i=O.mergeComponent({componentId:t,getComponent:r=>y({state:e,componentId:r}),locale:o,defaultLocale:e.config.defaultLocale,properties:n});return i?{component:a,script:i.script,props:{locale:o,...i.properties}}:null}function y({state:e,componentId:t}){var o,n,a;return((o=e.components[t])==null?void 0:o.data)??((a=(n=e.resources.components)==null?void 0:n[t])==null?void 0:a.component)}function ue({state:e,name:t}){var n,a;const o=t.toLowerCase();return((n=Object.values(e.components).find(i=>{var r;return((r=i.data.name)==null?void 0:r.toLowerCase())===o}))==null?void 0:n.data)??((a=e.resources.components&&Object.values(e.resources.components).find(i=>{var r;return((r=i.component.name)==null?void 0:r.toLowerCase())===o}))==null?void 0:a.component)}async function le({component:e,script:t,props:o,req:n}){const a=await R(t,"getServerSideProps");if(!a)return null;const i=new Promise((r,s)=>{setTimeout(()=>s(new Error("getServerSideProps timeout in promise race")),M*1e3)});return Promise.race([i,S.Sandbox.callFunction({code:`${a}
14
-
15
- export async function getServerSidePropsWrapper({ location, fetch, props}) {
16
- globalThis.location = location
17
- globalThis.fetch = fetch
18
-
19
- return getServerSideProps(props);
20
- }
21
- `,filename:`${e.name||e.id}.js`,moduleLoader:r=>{if(r==="@blocklet/pages-kit/builtin/utils")return`const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
22
- export { joinURL, withQuery, getQuery, getComponentMountPoint }
23
- `;if(r==="@blocklet/pages-kit/builtin/dayjs")return S.BuiltinModules.dayjs},global:{console:{log:(...r)=>{f.info(...r)},warn:(...r)=>{f.warn(...r)},error:(...r)=>{f.error(...r)}},getComponentMountPoint:v.getComponentMountPoint,joinURL:C.joinURL,withQuery:C.withQuery,getQuery:C.getQuery},functionName:"getServerSidePropsWrapper",args:[{location:{href:C.joinURL(C.withHttps(n.hostname),n.originalUrl)},fetch:(r,{...s}={})=>{const u=typeof r=="string"&&r.startsWith("/")?C.joinURL(T.default.env.appUrl,r):r;if(typeof u=="string"&&C.parseURL(u).host===C.parseURL(T.default.env.appUrl).host){const c=n.get("cookie");if(c){const l=new I.Headers(s.headers);l.set("cookie",c),s.headers=l}}return z.default(u,{...s,timeout:M*1e3}).then(c=>({ok:c.ok,status:c.status,statusText:c.statusText,headers:Object.fromEntries(c.headers.entries()),json:()=>c.json()}))},props:o}]})])}const de=S.memoize(async(e,t,o)=>{const n=await R(e,t);return n?await S.Sandbox.callFunction({code:`
24
- ${n}
25
-
26
- export function get${t}SchemaWrapper() {
27
- return ${t};
28
- }
29
- `,filename:`${o}.js`,functionName:`get${t}SchemaWrapper`}):null},{keyGenerator:(e,t,o)=>JSON.stringify(["getExportSchemaValueFromCode",e,t,o])});exports.CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS=$;exports.GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS=M;exports.clearPreloadComponentsCache=k;exports.clearPreloadComponentsCacheByMode=ce;exports.getComponentFromState=y;exports.getComponentFromStateByName=ue;exports.getExportSchemaValueFromCode=de;exports.getPreloadComponent=U;exports.getPreloadComponents=ae;exports.getPreloadComponentsCacheKey=L;exports.logger=f;
@@ -1,412 +0,0 @@
1
- import { getComponentMountPoint as k } from "@blocklet/pages-kit/builtin/utils";
2
- import { PreloadComponentScriptModule as $ } from "@blocklet/pages-kit/types";
3
- import { componentUMDName as v, RenderNestedComponent as M, mergeComponent as L } from "@blocklet/pages-kit/utils/property";
4
- import { memoize as O, Sandbox as _, BuiltinModules as U } from "@blocklet/quickjs";
5
- import T from "@blocklet/sdk/lib/config";
6
- import { LRUCache as D } from "lru-cache";
7
- import F, { Headers as B } from "node-fetch";
8
- import { joinURL as E, getQuery as J, withQuery as K, parseURL as b, withHttps as G } from "ufo";
9
- import Q from "@blocklet/logger";
10
- import { BuiltinModules as W } from "@blocklet/pages-kit/utils/builtin";
11
- import { createBuiltinModuleTransformer as V } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
12
- import A from "autoprefixer";
13
- import * as H from "esbuild";
14
- import z from "postcss";
15
- import X from "tailwindcss";
16
- import d from "typescript";
17
- const g = Q("pages-kit"), Y = async (e, { componentId: t }) => {
18
- const o = `@tailwind components;
19
- @tailwind utilities;
20
- `, r = `.CustomComponent_${t}`;
21
- return (await z([
22
- X({ content: [{ raw: e, extension: "tsx" }] }),
23
- A({
24
- overrideBrowserslist: ["> 1%", "last 2 versions"],
25
- stats: {}
26
- }),
27
- (a) => {
28
- a.walkRules((n) => {
29
- n.selectors = n.selectors.map((s) => s.replace(/\.(.+)/g, `${r}.$1,${r} .$1`));
30
- });
31
- }
32
- // FIXME: cssnano use browserslist, it is not working with the fs isolation
33
- // cssnano({ preset: 'default' }),
34
- ]).process(o)).css;
35
- }, Z = async (e, { componentId: t }) => {
36
- const o = await Y(e, { componentId: t });
37
- return `export const __PagesKit_CSS__ = ${JSON.stringify(o)};
38
-
39
- ${e}
40
- `;
41
- }, I = O(
42
- async (e, t) => {
43
- let o = d.transpileModule(e, {
44
- compilerOptions: {
45
- jsx: d.JsxEmit.React,
46
- target: d.ScriptTarget.ES2016,
47
- module: d.ModuleKind.ESNext
48
- },
49
- transformers: {
50
- before: [V(d)]
51
- }
52
- }).outputText;
53
- if (t.tailwind && (o = await Z(o, { componentId: t.componentId })), t.module === $.ESM) return o;
54
- const r = d.transpileModule(o, {
55
- compilerOptions: {
56
- jsx: d.JsxEmit.React,
57
- target: d.ScriptTarget.ES2016,
58
- module: d.ModuleKind.CommonJS,
59
- moduleResolution: d.ModuleResolutionKind.Node16
60
- }
61
- }).outputText;
62
- return ee(t.moduleName, r);
63
- },
64
- { keyGenerator: (e, t) => JSON.stringify(["transpileModule", e, t]) }
65
- ), q = async (e, t) => {
66
- var n, s;
67
- const r = (s = (n = (await H.build({
68
- entryPoints: ["index.tsx"],
69
- external: Object.keys(W),
70
- format: "esm",
71
- target: "es2020",
72
- bundle: !0,
73
- write: !1,
74
- plugins: [
75
- {
76
- name: "vfs",
77
- setup(l) {
78
- l.onResolve({ filter: /.*/ }, (c) => c.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : c.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : null), l.onLoad({ filter: /.*/, namespace: "vfs" }, async (c) => c.path === "index.tsx" ? { contents: `export { ${t} } from './component'`, loader: "tsx" } : c.path === "component.tsx" ? { contents: e, loader: "tsx" } : (console.warn("onLoad 11111111", c.path), null));
79
- }
80
- }
81
- ]
82
- })).outputFiles) == null ? void 0 : n[0]) == null ? void 0 : s.contents;
83
- if (!r) throw new Error("Failed to build server code");
84
- const i = Buffer.from(r).toString();
85
- return d.transpileModule(i, {
86
- compilerOptions: { module: d.ModuleKind.ESNext, target: d.ScriptTarget.ES2020 }
87
- }).outputText;
88
- }, N = O(
89
- async (e, t) => {
90
- const o = await q(e, t);
91
- return new RegExp(`export\\s+\\{\\s+${t}\\s+\\}`, "m").test(o) ? o : void 0;
92
- },
93
- { keyGenerator: (e, t) => JSON.stringify(["extractExportValueSchema", e, t]) }
94
- ), ee = (e, t) => `// GENERATED FILE. DO NOT EDIT.
95
- var ${e} = function () {
96
- return (function(exports) {
97
- ${t}
98
- return exports
99
- })({})
100
- };
101
- `, w = new D({
102
- max: 100
103
- }), te = 60 * 60, j = 60;
104
- function oe(e) {
105
- g.info("clear preload components cache", { cacheKey: e }), w.delete(e);
106
- }
107
- function Oe(e) {
108
- for (const t of w.keys())
109
- t.includes(e) && (g.info("clear preload components cache", { cacheKey: t }), oe(t));
110
- }
111
- function ne({
112
- mode: e,
113
- instanceId: t,
114
- componentId: o,
115
- locale: r
116
- }) {
117
- return ["getPreloadComponents", e, t, o, r].join("-");
118
- }
119
- async function Pe({
120
- mode: e,
121
- req: t,
122
- state: o,
123
- locale: r,
124
- instances: i,
125
- module: a
126
- }) {
127
- const {
128
- supportedLocales: n,
129
- config: { defaultLocale: s }
130
- } = o;
131
- if (!s) return null;
132
- const l = (await Promise.all(
133
- i.map(async (p) => {
134
- const u = ne({
135
- mode: e,
136
- instanceId: p.id,
137
- componentId: p.componentId,
138
- locale: r
139
- });
140
- if (e !== "draft" && p.useCache && w.has(u))
141
- return g.info(`get preload component from cache: ${u}`), w.get(u);
142
- const h = C({ state: o, componentId: p.componentId });
143
- if (!h) return null;
144
- const S = await re({
145
- req: t,
146
- state: o,
147
- componentId: h.id,
148
- locale: r,
149
- defaultLocale: s,
150
- properties: p.properties
151
- });
152
- if (!S) return null;
153
- const P = { instanceId: p.id, preload: S };
154
- if (e !== "draft" && p.useCache) {
155
- let y = te;
156
- p.cacheDuration && (y = p.cacheDuration), g.info(`set preload component to cache(${y}s): ${u}`), w.set(u, P, {
157
- ttl: y * 1e3
158
- });
159
- }
160
- return P;
161
- })
162
- )).filter((p) => !!p), c = Object.values(
163
- l.reduce((p, u) => ({ ...p, ...u.preload.components }), {})
164
- );
165
- async function m() {
166
- const p = await Promise.all(
167
- c.map(async (u) => {
168
- const h = v({ componentId: u.component.id }), S = a === $.ESM ? {
169
- module: a,
170
- script: await I(u.script, {
171
- componentId: u.component.id,
172
- module: a,
173
- tailwind: e !== "draft"
174
- })
175
- } : {
176
- module: a,
177
- script: await I(u.script, {
178
- componentId: u.component.id,
179
- module: a,
180
- moduleName: h,
181
- tailwind: e !== "draft"
182
- }),
183
- moduleName: h
184
- };
185
- return [u.component.id, { component: u.component, script: S }];
186
- })
187
- );
188
- return Object.fromEntries(p);
189
- }
190
- const f = await m();
191
- return {
192
- config: { defaultLocale: s, supportedLocales: n },
193
- components: f,
194
- instances: l.map((p) => ({
195
- id: p.instanceId,
196
- componentId: p.preload.component.id,
197
- locales: { [p.preload.locale]: { props: p.preload.props } }
198
- }))
199
- };
200
- }
201
- async function re({
202
- req: e,
203
- state: t,
204
- componentId: o,
205
- locale: r,
206
- defaultLocale: i,
207
- properties: a
208
- }) {
209
- const { supportedLocales: n } = t, s = C({ state: t, componentId: o });
210
- if (!s) return null;
211
- const l = n.some((m) => m.locale === r) ? r : i;
212
- if (!l) return null;
213
- const c = await R({ req: e, state: t, componentId: o, locale: l, defaultLocale: i, properties: a });
214
- return c ? {
215
- component: s,
216
- ...c
217
- } : null;
218
- }
219
- const se = 20;
220
- async function R({
221
- req: e,
222
- depth: t = 0,
223
- state: o,
224
- componentId: r,
225
- locale: i,
226
- defaultLocale: a,
227
- properties: n
228
- }) {
229
- if (t > se) throw new RangeError("max component depth exceeded");
230
- const s = ce({ state: o, componentId: r, properties: n, locale: i });
231
- if (!s) return null;
232
- const { props: l } = s, c = {
233
- locale: i || a,
234
- components: { [s.component.id]: { component: s.component, script: s.script } },
235
- props: { ...l }
236
- };
237
- try {
238
- const m = await ie({ ...s, req: e });
239
- m != null && m.props && Object.assign(c.props, m.props);
240
- } catch (m) {
241
- g.error("preload data at server side error", { componentId: r, name: s.component.name }, { error: m });
242
- }
243
- return await Promise.all(
244
- Object.entries(l).map(async ([m, f]) => {
245
- if ((f == null ? void 0 : f.type) === M) {
246
- const x = await R({
247
- req: e,
248
- depth: t + 1,
249
- state: o,
250
- componentId: f.componentId,
251
- locale: i,
252
- defaultLocale: a,
253
- properties: f.properties
254
- });
255
- x && (Object.assign(c.components, x.components), Object.assign(c.props, {
256
- [m]: {
257
- type: M,
258
- componentId: f.componentId,
259
- props: x.props
260
- }
261
- }));
262
- }
263
- })
264
- ), c;
265
- }
266
- function ce({
267
- state: e,
268
- componentId: t,
269
- locale: o,
270
- properties: r
271
- }) {
272
- const i = C({ state: e, componentId: t });
273
- if (!i) return null;
274
- const a = L({
275
- componentId: t,
276
- getComponent: (n) => C({ state: e, componentId: n }),
277
- locale: o,
278
- defaultLocale: e.config.defaultLocale,
279
- properties: r
280
- });
281
- return a ? { component: i, script: a.script, props: { locale: o, ...a.properties } } : null;
282
- }
283
- function C({ state: e, componentId: t }) {
284
- var o, r, i;
285
- return ((o = e.components[t]) == null ? void 0 : o.data) ?? ((i = (r = e.resources.components) == null ? void 0 : r[t]) == null ? void 0 : i.component);
286
- }
287
- function Me({ state: e, name: t }) {
288
- var r, i;
289
- const o = t.toLowerCase();
290
- return ((r = Object.values(e.components).find((a) => {
291
- var n;
292
- return ((n = a.data.name) == null ? void 0 : n.toLowerCase()) === o;
293
- })) == null ? void 0 : r.data) ?? ((i = e.resources.components && Object.values(e.resources.components).find((a) => {
294
- var n;
295
- return ((n = a.component.name) == null ? void 0 : n.toLowerCase()) === o;
296
- })) == null ? void 0 : i.component);
297
- }
298
- async function ie({
299
- component: e,
300
- script: t,
301
- props: o,
302
- req: r
303
- }) {
304
- const i = await N(t, "getServerSideProps");
305
- if (!i) return null;
306
- const a = new Promise((n, s) => {
307
- setTimeout(() => s(new Error("getServerSideProps timeout in promise race")), j * 1e3);
308
- });
309
- return Promise.race([
310
- a,
311
- _.callFunction({
312
- code: `${i}
313
-
314
- export async function getServerSidePropsWrapper({ location, fetch, props}) {
315
- globalThis.location = location
316
- globalThis.fetch = fetch
317
-
318
- return getServerSideProps(props);
319
- }
320
- `,
321
- filename: `${e.name || e.id}.js`,
322
- moduleLoader: (n) => {
323
- if (n === "@blocklet/pages-kit/builtin/utils")
324
- return `const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
325
- export { joinURL, withQuery, getQuery, getComponentMountPoint }
326
- `;
327
- if (n === "@blocklet/pages-kit/builtin/dayjs")
328
- return U.dayjs;
329
- },
330
- global: {
331
- console: {
332
- // NOTE: do not return logger.xxx result, it will cause memory leak
333
- // eslint-disable-next-line prettier/prettier
334
- log: (...n) => {
335
- g.info(...n);
336
- },
337
- warn: (...n) => {
338
- g.warn(...n);
339
- },
340
- error: (...n) => {
341
- g.error(...n);
342
- }
343
- },
344
- getComponentMountPoint: k,
345
- joinURL: E,
346
- withQuery: K,
347
- getQuery: J
348
- },
349
- functionName: "getServerSidePropsWrapper",
350
- args: [
351
- {
352
- // NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
353
- // because the global is shared between all runtime and just init once
354
- location: { href: E(G(r.hostname), r.originalUrl) },
355
- fetch: (n, { ...s } = {}) => {
356
- const l = typeof n == "string" && n.startsWith("/") ? E(T.env.appUrl, n) : n;
357
- if (typeof l == "string" && b(l).host === b(T.env.appUrl).host) {
358
- const c = r.get("cookie");
359
- if (c) {
360
- const m = new B(s.headers);
361
- m.set("cookie", c), s.headers = m;
362
- }
363
- }
364
- return F(l, {
365
- ...s,
366
- timeout: j * 1e3
367
- }).then((c) => ({
368
- ok: c.ok,
369
- status: c.status,
370
- statusText: c.statusText,
371
- headers: Object.fromEntries(c.headers.entries()),
372
- json: () => c.json()
373
- }));
374
- },
375
- props: o
376
- }
377
- ]
378
- })
379
- ]);
380
- }
381
- const Te = O(
382
- async (e, t, o) => {
383
- const r = await N(e, t);
384
- return r ? await _.callFunction({
385
- code: `
386
- ${r}
387
-
388
- export function get${t}SchemaWrapper() {
389
- return ${t};
390
- }
391
- `,
392
- filename: `${o}.js`,
393
- functionName: `get${t}SchemaWrapper`
394
- }) : null;
395
- },
396
- {
397
- keyGenerator: (e, t, o) => JSON.stringify(["getExportSchemaValueFromCode", e, t, o])
398
- }
399
- );
400
- export {
401
- te as C,
402
- j as G,
403
- Pe as a,
404
- oe as b,
405
- Oe as c,
406
- ne as d,
407
- re as e,
408
- C as f,
409
- Te as g,
410
- Me as h,
411
- g as l
412
- };