@justanarthur/payload-www 0.3.5 → 1.2.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 +317 -307
- package/dist/access.d.ts +2 -2
- package/dist/access.js +3 -17
- package/dist/blocks.d.ts +7 -12
- package/dist/blocks.js +24 -43
- package/dist/cli.js +201 -0
- package/dist/collections.d.ts +33 -225
- package/dist/collections.js +185 -639
- package/dist/config.d.ts +19 -105
- package/dist/config.js +257 -855
- package/dist/fields.d.ts +4 -46
- package/dist/fields.js +177 -53
- package/dist/imagehash.js +0 -15
- package/dist/import-map-provider.d.ts +0 -16
- package/dist/import-map-provider.js +0 -15
- package/dist/metadata.d.ts +24 -89
- package/dist/metadata.js +123 -255
- package/dist/pages.d.ts +37 -319
- package/dist/pages.js +349 -964
- package/dist/render-pages.d.ts +70 -565
- package/dist/render-pages.js +464 -1477
- package/dist/sitemap.d.ts +10 -0
- package/dist/sitemap.js +337 -0
- package/dist/translator.js +0 -15
- package/dist/utils.d.ts +10 -12
- package/dist/utils.js +18 -41
- package/package.json +81 -178
- package/dist/components.d.ts +0 -6
- package/dist/components.js +0 -39
- package/dist/core-access.d.ts +0 -11
- package/dist/core-access.js +0 -34
- package/dist/core-blocks.d.ts +0 -24
- package/dist/core-blocks.js +0 -79
- package/dist/core-fields.d.ts +0 -73
- package/dist/core-fields.js +0 -167
- package/dist/core-utils.d.ts +0 -16
- package/dist/core-utils.js +0 -63
- package/dist/data-collections.d.ts +0 -229
- package/dist/data-collections.js +0 -676
- package/dist/data-seed.d.ts +0 -76
- package/dist/data-seed.js +0 -212
- package/dist/data-test.d.ts +0 -30
- package/dist/data-test.js +0 -1110
- package/dist/globals.d.ts +0 -69
- package/dist/globals.js +0 -251
- package/dist/hooks.d.ts +0 -108
- package/dist/hooks.js +0 -228
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -39
- package/dist/render-components.d.ts +0 -42
- package/dist/render-components.js +0 -154
- package/dist/render-metadata.d.ts +0 -122
- package/dist/render-metadata.js +0 -390
- package/dist/render-utils.d.ts +0 -166
- package/dist/render-utils.js +0 -398
- package/dist/seed.d.ts +0 -76
- package/dist/seed.js +0 -212
- package/dist/server.d.ts +0 -980
- package/dist/server.js +0 -2231
- package/dist/test.d.ts +0 -30
- package/dist/test.js +0 -1110
- package/dist/with-www-config.d.ts +0 -108
- package/dist/with-www-config.js +0 -1006
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type CreateCollectionPageExportsDeps<S extends string> = {
|
|
2
|
+
getServerSideURL: () => string;
|
|
3
|
+
pagePathPrefix?: string;
|
|
4
|
+
};
|
|
5
|
+
type GenerateSitemapPageExportsArgs = CreateCollectionPageExportsDeps<any>;
|
|
6
|
+
declare function createSitemapFromCollections(...args: GenerateSitemapPageExportsArgs[]): () => Response;
|
|
7
|
+
declare const _default: {
|
|
8
|
+
createSitemapFromCollections: typeof createSitemapFromCollections;
|
|
9
|
+
};
|
|
10
|
+
export { _default as default, createSitemapFromCollections };
|
package/dist/sitemap.js
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
4
|
+
import"server-only";
|
|
5
|
+
|
|
6
|
+
// src/render/metadata/slug.ts
|
|
7
|
+
var SLUG_NESTED_DIVIDER = "_";
|
|
8
|
+
function paramsSlugToSlug(slug, _shape) {
|
|
9
|
+
if (!slug)
|
|
10
|
+
return "";
|
|
11
|
+
return (Array.isArray(slug) ? slug : [slug]).join(SLUG_NESTED_DIVIDER);
|
|
12
|
+
}
|
|
13
|
+
function slugToParamsSlug(slug, shape) {
|
|
14
|
+
if (!slug)
|
|
15
|
+
return shape === "catch-all" ? [] : "";
|
|
16
|
+
return shape === "catch-all" ? slug.split(SLUG_NESTED_DIVIDER) : slug;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/render/metadata/query.ts
|
|
20
|
+
import { getPayload } from "payload";
|
|
21
|
+
|
|
22
|
+
// src/collections/hooks/createRevalidateCollectionGlobalHook.ts
|
|
23
|
+
import { revalidateTag } from "next/cache";
|
|
24
|
+
function createRevalidateCollectionGlobalHook() {
|
|
25
|
+
const afterChangeDeleteHook = async ({ doc, req, ...args }) => {
|
|
26
|
+
const previousDoc = "previousDoc" in args ? args.previousDoc : null, locale = req.locale;
|
|
27
|
+
function revalidate(args2) {
|
|
28
|
+
try {
|
|
29
|
+
revalidateTag(createCollectionCacheKey({ ...args2, locale }), "max");
|
|
30
|
+
} catch (error) {
|
|
31
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
32
|
+
if (msg.includes("static generation store missing"))
|
|
33
|
+
return;
|
|
34
|
+
console.error(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if ("collection" in args) {
|
|
38
|
+
[
|
|
39
|
+
doc && doc._status !== "draft" && doc.slug,
|
|
40
|
+
previousDoc && previousDoc._status === "published" && previousDoc.slug
|
|
41
|
+
].filter((slug) => slug !== undefined && slug !== false).map((slug) => revalidate({ collectionSlug: args.collection.slug, slug }));
|
|
42
|
+
} else {
|
|
43
|
+
revalidate({ globalSlug: args.global.slug });
|
|
44
|
+
}
|
|
45
|
+
return doc;
|
|
46
|
+
};
|
|
47
|
+
return { afterChange: afterChangeDeleteHook, afterDelete: afterChangeDeleteHook };
|
|
48
|
+
}
|
|
49
|
+
function createCollectionCacheKey(args) {
|
|
50
|
+
return `${"globalSlug" in args ? args.globalSlug : args.collectionSlug + args.slug}_${args.locale}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/render/metadata/query.ts
|
|
54
|
+
async function withUnstableCache(keyParts, tags, fn) {
|
|
55
|
+
const { unstable_cache } = await import("next/cache");
|
|
56
|
+
return unstable_cache(fn, keyParts.map(String), { tags })();
|
|
57
|
+
}
|
|
58
|
+
async function queryDoc(args, { config: configPromise }) {
|
|
59
|
+
return withUnstableCache(Object.values(args), [createCollectionCacheKey(args)], async () => {
|
|
60
|
+
if ("globalSlug" in args)
|
|
61
|
+
return queryGlobal({ ...args, config: configPromise });
|
|
62
|
+
else
|
|
63
|
+
return queryDocBySlug({ ...args, config: configPromise });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function queryDocBySlug({
|
|
67
|
+
collectionSlug,
|
|
68
|
+
slug,
|
|
69
|
+
slugField = "slug",
|
|
70
|
+
locale,
|
|
71
|
+
draft = false,
|
|
72
|
+
config
|
|
73
|
+
}) {
|
|
74
|
+
return withUnstableCache([collectionSlug, slug, locale, draft], [createCollectionCacheKey({ collectionSlug, slug, locale })], async () => {
|
|
75
|
+
const payload = await getPayload({ config });
|
|
76
|
+
const result = await payload.find({
|
|
77
|
+
collection: collectionSlug,
|
|
78
|
+
draft,
|
|
79
|
+
limit: 1,
|
|
80
|
+
pagination: false,
|
|
81
|
+
overrideAccess: draft,
|
|
82
|
+
where: { [slugField]: { equals: slug } },
|
|
83
|
+
locale
|
|
84
|
+
});
|
|
85
|
+
return result.docs?.[0] ?? null;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function queryGlobal({
|
|
89
|
+
globalSlug,
|
|
90
|
+
locale,
|
|
91
|
+
draft = false,
|
|
92
|
+
config
|
|
93
|
+
}) {
|
|
94
|
+
return withUnstableCache([globalSlug, locale, draft], [createCollectionCacheKey({ globalSlug, locale })], async () => {
|
|
95
|
+
const payload = await getPayload({ config });
|
|
96
|
+
try {
|
|
97
|
+
return await payload.findGlobal({ slug: globalSlug, draft, locale });
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.warn("[WWW] queryGlobal failed", { globalSlug, locale, error: String(error) });
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function queryAllDocs({
|
|
105
|
+
collectionSlug,
|
|
106
|
+
slugField = "slug",
|
|
107
|
+
locale,
|
|
108
|
+
config
|
|
109
|
+
}) {
|
|
110
|
+
return withUnstableCache([collectionSlug, slugField, locale], [createCollectionCacheKey({ collectionSlug, slug: "__all__", locale })], async () => {
|
|
111
|
+
const payload = await getPayload({ config });
|
|
112
|
+
const result = await payload.find({
|
|
113
|
+
collection: collectionSlug,
|
|
114
|
+
draft: false,
|
|
115
|
+
limit: 1000,
|
|
116
|
+
pagination: false,
|
|
117
|
+
overrideAccess: false,
|
|
118
|
+
select: { [slugField]: true },
|
|
119
|
+
locale
|
|
120
|
+
});
|
|
121
|
+
return result.docs ?? [];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function queryAllLocaleSlugs({
|
|
125
|
+
collectionSlug,
|
|
126
|
+
id,
|
|
127
|
+
slugField = "slug",
|
|
128
|
+
config
|
|
129
|
+
}) {
|
|
130
|
+
const payload = await getPayload({ config });
|
|
131
|
+
const doc = await payload.findByID({
|
|
132
|
+
collection: collectionSlug,
|
|
133
|
+
id,
|
|
134
|
+
locale: "all",
|
|
135
|
+
select: { [slugField]: true }
|
|
136
|
+
});
|
|
137
|
+
return doc?.[slugField];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
141
|
+
import { setRequestLocale } from "next-intl/server";
|
|
142
|
+
|
|
143
|
+
// src/render/pages/utils/buildLocalizedPath.ts
|
|
144
|
+
function buildLocalizedPath(locale, prefix, slug, { routing }) {
|
|
145
|
+
return `${routing.localePrefix === "never" ? "" : routing.localePrefix === "always" ? locale : routing.localePrefix === "as-needed" ? locale === routing.defaultLocale ? "" : "/" + locale : (() => {
|
|
146
|
+
throw new Error("Unsupported locale prefix");
|
|
147
|
+
})()}${prefix ? "/" + prefix : ""}${slug ? "/" + slug : ""}`;
|
|
148
|
+
}
|
|
149
|
+
function buildLocalizedPaths(localesSlug, pagePathPrefix, { routing }) {
|
|
150
|
+
return routing.locales.reduce((paths, locale) => {
|
|
151
|
+
const slug = localesSlug[locale];
|
|
152
|
+
paths[locale] = buildLocalizedPath(locale, pagePathPrefix, slug, { routing });
|
|
153
|
+
return paths;
|
|
154
|
+
}, {});
|
|
155
|
+
}
|
|
156
|
+
function buildAlternates(locale, ...args) {
|
|
157
|
+
const siteUrl = args[2].siteUrl;
|
|
158
|
+
let localizedPaths = buildLocalizedPaths(...args);
|
|
159
|
+
localizedPaths["x-default"] = localizedPaths[args[2].routing.defaultLocale];
|
|
160
|
+
localizedPaths = Object.fromEntries(Object.entries(localizedPaths).map(([key, value]) => [key, siteUrl + localizedPaths[key]]));
|
|
161
|
+
return {
|
|
162
|
+
languages: localizedPaths,
|
|
163
|
+
canonical: localizedPaths[locale]
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
168
|
+
import { createSiteDefaults, generateMeta } from "@justanarthur/payload-plugin-seo/next-metadata";
|
|
169
|
+
|
|
170
|
+
// package.json
|
|
171
|
+
var name = "@justanarthur/payload-www";
|
|
172
|
+
|
|
173
|
+
// src/render/getFromImportMap.ts
|
|
174
|
+
function getFromImportMap(key, importMap) {
|
|
175
|
+
if (!key)
|
|
176
|
+
return;
|
|
177
|
+
const entry = importMap[key.includes("#") ? key : `${key}#default`];
|
|
178
|
+
if (entry == null)
|
|
179
|
+
return;
|
|
180
|
+
if (typeof entry === "function") {
|
|
181
|
+
return entry().then((mod) => {
|
|
182
|
+
if (typeof mod === "function")
|
|
183
|
+
return mod;
|
|
184
|
+
const modObj = mod;
|
|
185
|
+
return modObj.default ?? mod;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return entry;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/render/renderWWWModule.tsx
|
|
192
|
+
import { jsx } from "react/jsx-runtime";
|
|
193
|
+
async function renderWWWDataModule(data, {
|
|
194
|
+
collectionSlug,
|
|
195
|
+
configPath = "collections",
|
|
196
|
+
config: configPromise,
|
|
197
|
+
importMap
|
|
198
|
+
}, props) {
|
|
199
|
+
const config = await configPromise;
|
|
200
|
+
const renderPath = config[configPath]?.find((c) => c.slug === collectionSlug)?.custom?.[name]?.path;
|
|
201
|
+
const RenderModule = await getFromImportMap(renderPath, importMap);
|
|
202
|
+
if (!RenderModule) {
|
|
203
|
+
if (false) {}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
return /* @__PURE__ */ jsx(RenderModule, {
|
|
207
|
+
data,
|
|
208
|
+
config,
|
|
209
|
+
importMap,
|
|
210
|
+
...props
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
215
|
+
import { jsx as jsx2, Fragment } from "react/jsx-runtime";
|
|
216
|
+
function createCollectionPageExports({
|
|
217
|
+
slug: collectionSlug = "pages",
|
|
218
|
+
config: configPromise,
|
|
219
|
+
importMap,
|
|
220
|
+
routing,
|
|
221
|
+
slugShape = "single"
|
|
222
|
+
}, {
|
|
223
|
+
getServerSideURL,
|
|
224
|
+
pagePathPrefix
|
|
225
|
+
}) {
|
|
226
|
+
const siteUrl = getServerSideURL();
|
|
227
|
+
async function fetchDoc(locale, slug) {
|
|
228
|
+
return queryDoc({
|
|
229
|
+
slug,
|
|
230
|
+
locale,
|
|
231
|
+
collectionSlug
|
|
232
|
+
}, {
|
|
233
|
+
config: configPromise
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const default_ = async (props) => {
|
|
237
|
+
const params = await props.params;
|
|
238
|
+
const locale = params.locale;
|
|
239
|
+
if (!routing.locales.includes(locale)) {
|
|
240
|
+
const { notFound } = await import("next/navigation");
|
|
241
|
+
return notFound();
|
|
242
|
+
} else
|
|
243
|
+
setRequestLocale(locale);
|
|
244
|
+
const slug = paramsSlugToSlug(params.slug, slugShape);
|
|
245
|
+
const doc = await fetchDoc(locale, slug);
|
|
246
|
+
if (!doc) {
|
|
247
|
+
const { notFound } = await import("next/navigation");
|
|
248
|
+
notFound();
|
|
249
|
+
}
|
|
250
|
+
const rendered = renderWWWDataModule(doc, { collectionSlug, config: configPromise, importMap }, { ...props, locale });
|
|
251
|
+
return /* @__PURE__ */ jsx2(Fragment, {
|
|
252
|
+
children: rendered
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
async function generateMetadata(props) {
|
|
256
|
+
const params = await props.params;
|
|
257
|
+
const locale = params.locale, slug = paramsSlugToSlug(params.slug, slugShape);
|
|
258
|
+
const doc = await fetchDoc(locale, slug);
|
|
259
|
+
const [localesSlug, siteDefaults] = await Promise.all([
|
|
260
|
+
doc ? queryAllLocaleSlugs({
|
|
261
|
+
id: doc.id,
|
|
262
|
+
collectionSlug,
|
|
263
|
+
config: configPromise
|
|
264
|
+
}) : Promise.resolve({}),
|
|
265
|
+
createSiteDefaults({ config: configPromise, locale })
|
|
266
|
+
]);
|
|
267
|
+
if (!doc)
|
|
268
|
+
return {};
|
|
269
|
+
const alternates = buildAlternates(locale, localesSlug ?? {}, pagePathPrefix, { routing, siteUrl });
|
|
270
|
+
const meta = await generateMeta({
|
|
271
|
+
meta: doc.meta,
|
|
272
|
+
url: alternates.canonical,
|
|
273
|
+
type: "website",
|
|
274
|
+
locale,
|
|
275
|
+
availableLocales: routing.locales,
|
|
276
|
+
fallback: doc,
|
|
277
|
+
siteDefaults
|
|
278
|
+
});
|
|
279
|
+
console.log("[www#generateMetadata]", { alternates, meta, locale, localesSlug, doc });
|
|
280
|
+
return { ...meta, alternates };
|
|
281
|
+
}
|
|
282
|
+
async function generateStaticParams(props) {
|
|
283
|
+
const locale = (await props.params).locale;
|
|
284
|
+
const docs = await queryAllDocs({ locale, collectionSlug, config: configPromise });
|
|
285
|
+
return docs.filter((doc) => typeof doc.slug === "string" && doc.slug.length > 0).map((doc) => ({ slug: slugToParamsSlug(doc.slug, slugShape) }));
|
|
286
|
+
}
|
|
287
|
+
async function generateSitemap() {
|
|
288
|
+
const locale = routing.defaultLocale;
|
|
289
|
+
const docs = await queryAllDocs({
|
|
290
|
+
collectionSlug,
|
|
291
|
+
locale,
|
|
292
|
+
config: configPromise
|
|
293
|
+
});
|
|
294
|
+
return await Promise.all(docs.map(async (doc) => {
|
|
295
|
+
const localesSlug = await queryAllLocaleSlugs({
|
|
296
|
+
id: doc.id,
|
|
297
|
+
collectionSlug,
|
|
298
|
+
config: configPromise
|
|
299
|
+
}) ?? {};
|
|
300
|
+
const alternates = buildAlternates(locale, localesSlug, pagePathPrefix, { routing, siteUrl });
|
|
301
|
+
return {
|
|
302
|
+
url: alternates.canonical,
|
|
303
|
+
alternates,
|
|
304
|
+
lastModified: doc.updatedAt || new Date
|
|
305
|
+
};
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
generateSitemap.getServerSideURL = getServerSideURL;
|
|
309
|
+
generateSitemap.pagePathPrefix = pagePathPrefix;
|
|
310
|
+
return {
|
|
311
|
+
default: default_,
|
|
312
|
+
generateMetadata,
|
|
313
|
+
generateStaticParams,
|
|
314
|
+
generateSitemap
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function createSitemapFromCollections(...args) {
|
|
318
|
+
const baseUrl = args[0].getServerSideURL();
|
|
319
|
+
return function sitemap() {
|
|
320
|
+
const sitemaps = args.map((arg) => `${baseUrl}/${arg.pagePathPrefix}/sitemap.xml`);
|
|
321
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
322
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
323
|
+
${sitemaps.map((url) => ` <sitemap><loc>${url}</loc></sitemap>`).join(`
|
|
324
|
+
`)}
|
|
325
|
+
</sitemapindex>`;
|
|
326
|
+
return new Response(xml, {
|
|
327
|
+
headers: { "Content-Type": "application/xml" }
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/exports/sitemap.ts
|
|
333
|
+
var sitemap_default = { createSitemapFromCollections };
|
|
334
|
+
export {
|
|
335
|
+
sitemap_default as default,
|
|
336
|
+
createSitemapFromCollections
|
|
337
|
+
};
|
package/dist/translator.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
2
|
|
|
18
3
|
// src/exports/translator.ts
|
|
19
4
|
import { translator } from "@justanarthur/payload-plugin-translator";
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { ImportMap } from "payload";
|
|
2
|
-
declare function getFromImportMap(key: string, importMap: ImportMap): any;
|
|
3
1
|
declare function generateImportName(type: "block" | "page", slug: string): string;
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
import { ImportMap } from "payload";
|
|
4
|
+
type AsyncImportMapEntry<T = ComponentType> = T | (() => Promise<{
|
|
5
|
+
default: T;
|
|
6
|
+
} | T>);
|
|
7
|
+
type AsyncImportMap = Record<string, AsyncImportMapEntry>;
|
|
8
|
+
type ResolvedImportMapEntry<T = ComponentType> = T | Promise<T>;
|
|
9
|
+
declare function getFromImportMap<T = ComponentType>(key: string | undefined, importMap: ImportMap | AsyncImportMap): ResolvedImportMapEntry<T> | undefined;
|
|
10
|
+
declare const utils: {
|
|
12
11
|
getFromImportMap: typeof getFromImportMap;
|
|
13
12
|
generateImportName: typeof generateImportName;
|
|
14
|
-
renderCollectionModule: typeof renderCollectionModule;
|
|
15
13
|
};
|
|
16
|
-
export {
|
|
14
|
+
export { getFromImportMap, generateImportName, utils as default };
|
package/dist/utils.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
2
|
|
|
18
|
-
// src/
|
|
19
|
-
function getFromImportMap(key, importMap) {
|
|
20
|
-
return importMap[key.includes("#") ? key : key + "#default"];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// src/core/utils/generateImportName.ts
|
|
3
|
+
// src/render/generateImportName.ts
|
|
24
4
|
function generateImportName(type, slug) {
|
|
25
5
|
switch (type) {
|
|
26
6
|
case "block":
|
|
@@ -32,31 +12,28 @@ function generateImportName(type, slug) {
|
|
|
32
12
|
}
|
|
33
13
|
}
|
|
34
14
|
|
|
35
|
-
// src/render/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
// src/render/getFromImportMap.ts
|
|
16
|
+
function getFromImportMap(key, importMap) {
|
|
17
|
+
if (!key)
|
|
18
|
+
return;
|
|
19
|
+
const entry = importMap[key.includes("#") ? key : `${key}#default`];
|
|
20
|
+
if (entry == null)
|
|
21
|
+
return;
|
|
22
|
+
if (typeof entry === "function") {
|
|
23
|
+
return entry().then((mod) => {
|
|
24
|
+
if (typeof mod === "function")
|
|
25
|
+
return mod;
|
|
26
|
+
const modObj = mod;
|
|
27
|
+
return modObj.default ?? mod;
|
|
28
|
+
});
|
|
48
29
|
}
|
|
49
|
-
|
|
50
|
-
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
51
|
-
importMap,
|
|
52
|
-
...props
|
|
53
|
-
});
|
|
30
|
+
return entry;
|
|
54
31
|
}
|
|
55
32
|
|
|
56
33
|
// src/exports/utils.ts
|
|
57
|
-
var
|
|
34
|
+
var utils = { getFromImportMap, generateImportName };
|
|
35
|
+
var utils_default = utils;
|
|
58
36
|
export {
|
|
59
|
-
renderCollectionModule,
|
|
60
37
|
getFromImportMap,
|
|
61
38
|
generateImportName,
|
|
62
39
|
utils_default as default
|