@artinstack/migrator 0.1.10 → 0.1.13

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.
Files changed (35) hide show
  1. package/README.md +2 -1
  2. package/dist/{bundle-Do-9ikQv.d.ts → bundle-BgoXkWMy.d.ts} +1 -1
  3. package/dist/{chunk-3YJFSTYR.js → chunk-373TTCG7.js} +12 -1
  4. package/dist/chunk-373TTCG7.js.map +1 -0
  5. package/dist/chunk-4XZK55RW.js +837 -0
  6. package/dist/chunk-4XZK55RW.js.map +1 -0
  7. package/dist/{chunk-YLVPZ4M3.js → chunk-53VXTXGM.js} +97 -524
  8. package/dist/chunk-53VXTXGM.js.map +1 -0
  9. package/dist/{chunk-3A2PA4P3.js → chunk-5TRCJONX.js} +4 -232
  10. package/dist/chunk-5TRCJONX.js.map +1 -0
  11. package/dist/chunk-HUSXCKPI.js +357 -0
  12. package/dist/chunk-HUSXCKPI.js.map +1 -0
  13. package/dist/{chunk-LC7CGWDN.js → chunk-PD5AZX3B.js} +1 -1
  14. package/dist/chunk-PD5AZX3B.js.map +1 -0
  15. package/dist/{chunk-S4SUJT2D.js → chunk-VQ5HKNYP.js} +109 -4
  16. package/dist/chunk-VQ5HKNYP.js.map +1 -0
  17. package/dist/cli/index.js +5 -4
  18. package/dist/cli/index.js.map +1 -1
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +7 -6
  21. package/dist/normalizer/index.d.ts +106 -4
  22. package/dist/normalizer/index.js +2 -2
  23. package/dist/sinks/index.d.ts +2 -2
  24. package/dist/sinks/index.js +3 -3
  25. package/dist/transformers/index.d.ts +1 -1
  26. package/dist/transformers/index.js +3 -2
  27. package/dist/{types-TCHy3Oko.d.ts → types-Bicgdp4Z.d.ts} +15 -1
  28. package/package.json +1 -1
  29. package/dist/chunk-3A2PA4P3.js.map +0 -1
  30. package/dist/chunk-3YJFSTYR.js.map +0 -1
  31. package/dist/chunk-BONZ3U3I.js +0 -124
  32. package/dist/chunk-BONZ3U3I.js.map +0 -1
  33. package/dist/chunk-LC7CGWDN.js.map +0 -1
  34. package/dist/chunk-S4SUJT2D.js.map +0 -1
  35. package/dist/chunk-YLVPZ4M3.js.map +0 -1
@@ -1,15 +1,17 @@
1
1
  import {
2
2
  SquarespaceCollectionClient,
3
- WORDPRESS_BUILDER_REGISTRY,
4
- WORDPRESS_WIDGET_REGISTRY,
5
- WP_WIDGET_PLACEHOLDER,
6
3
  enumerateSquarespaceEntities,
7
4
  summarizeSquarespaceExport,
8
5
  validateSquarespaceExportFile
9
- } from "./chunk-3A2PA4P3.js";
6
+ } from "./chunk-5TRCJONX.js";
7
+ import {
8
+ flattenWordPressBuilders,
9
+ parseSliderMetaValue,
10
+ parseSliderShortcodeMarkup
11
+ } from "./chunk-4XZK55RW.js";
10
12
  import {
11
13
  stampMigrationMediaRefs
12
- } from "./chunk-BONZ3U3I.js";
14
+ } from "./chunk-HUSXCKPI.js";
13
15
  import {
14
16
  linkToPath,
15
17
  sanitizeSlug
@@ -19,7 +21,6 @@ import {
19
21
  canonicalizeInlineAssetUrl,
20
22
  discoverContentAssetUrls,
21
23
  discoverContentAssets,
22
- normalizeAssetUrl,
23
24
  parseMigrationMediaRef,
24
25
  resolveFeaturedContentAssetUrl,
25
26
  rewriteOriginUrlsInText
@@ -29,523 +30,6 @@ import {
29
30
  import { readFile } from "fs/promises";
30
31
  import { basename } from "path";
31
32
  import { XMLParser } from "fast-xml-parser";
32
-
33
- // src/parsers/wordpress/builders/flatten.ts
34
- function escapeRegExp(value) {
35
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36
- }
37
- function extractQuotedParam(params, name) {
38
- const pattern = new RegExp(`\\b${escapeRegExp(name)}\\s*=\\s*`, "i");
39
- const match = pattern.exec(params);
40
- if (!match) return void 0;
41
- let index = match.index + match[0].length;
42
- while (index < params.length && /\s/.test(params[index])) index += 1;
43
- const quote = params[index];
44
- if (quote !== '"' && quote !== "'") return void 0;
45
- index += 1;
46
- let value = "";
47
- while (index < params.length) {
48
- const char = params[index];
49
- if (char === "\\" && index + 1 < params.length) {
50
- value += params[index + 1];
51
- index += 2;
52
- continue;
53
- }
54
- if (char === quote) break;
55
- value += char;
56
- index += 1;
57
- }
58
- const trimmed = value.trim();
59
- return trimmed || void 0;
60
- }
61
- function escapeLayoutAttr(value) {
62
- return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
63
- }
64
- function parseFractionWidth(fraction) {
65
- if (!fraction?.trim()) return void 0;
66
- const trimmed = fraction.trim();
67
- const match = trimmed.match(/^(\d+)\s*\/\s*(\d+)$/);
68
- if (!match) return void 0;
69
- const numerator = Number(match[1]);
70
- const denominator = Number(match[2]);
71
- if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator <= 0) {
72
- return void 0;
73
- }
74
- const percent = numerator / denominator * 100;
75
- const rounded = Math.round(percent * 100) / 100;
76
- return `${rounded % 1 === 0 ? rounded.toFixed(0) : rounded}%`;
77
- }
78
- function parseRowLayoutCols(layout) {
79
- if (!layout?.trim()) return void 0;
80
- const parts = layout.split("+").map((part) => part.trim()).filter(Boolean);
81
- return parts.length > 1 ? parts.length : void 0;
82
- }
83
- function openSectionDiv(params, bgParamName) {
84
- const attrs = ['data-layout="section"'];
85
- const bgImage = extractQuotedParam(params, bgParamName ?? "bg_image");
86
- if (bgImage?.startsWith("http")) {
87
- attrs.push(`data-bg-image="${escapeLayoutAttr(bgImage)}"`);
88
- }
89
- return `<div ${attrs.join(" ")}>`;
90
- }
91
- function openRowDiv(params, colsParamName) {
92
- const attrs = ['data-layout="row"'];
93
- const cols = parseRowLayoutCols(extractQuotedParam(params, colsParamName ?? "layout"));
94
- if (cols) attrs.push(`data-cols="${cols}"`);
95
- return `<div ${attrs.join(" ")}>`;
96
- }
97
- function openColumnDiv(params, widthParamName) {
98
- const attrs = ['data-layout="column"'];
99
- const width = parseFractionWidth(extractQuotedParam(params, widthParamName ?? "width"));
100
- if (width) attrs.push(`data-col-width="${width}"`);
101
- return `<div ${attrs.join(" ")}>`;
102
- }
103
- function applyPrefixedLayoutMap(content, map) {
104
- let html = content;
105
- html = html.replace(map.sectionRegex, (_, params) => openSectionDiv(params, map.bgParamName));
106
- html = html.replace(map.sectionCloseRegex, "</div>");
107
- html = html.replace(map.rowRegex, (_, params) => openRowDiv(params, map.colsParamName));
108
- html = html.replace(map.rowCloseRegex, "</div>");
109
- html = html.replace(map.columnRegex, '<div data-layout="column">');
110
- html = html.replace(map.columnCloseRegex, "</div>");
111
- return html;
112
- }
113
- function applyFractionalLayoutMap(content, map) {
114
- let html = content;
115
- html = html.replace(map.sectionRegex, (_, params) => openSectionDiv(params, map.bgParamName));
116
- html = html.replace(map.sectionCloseRegex, "</div>");
117
- html = html.replace(map.rowRegex, (_, params) => openRowDiv(params));
118
- html = html.replace(map.rowCloseRegex, "</div>");
119
- for (let index = 0; index < map.columnTokens.length; index += 1) {
120
- const token = map.columnTokens[index];
121
- const width = map.columnWidths[token];
122
- const openRegex = map.columnOpenRegexes[index];
123
- const closeRegex = map.columnCloseRegexes[index];
124
- html = html.replace(openRegex, () => {
125
- const attrs = ['data-layout="column"'];
126
- if (width) attrs.push(`data-col-width="${width}"`);
127
- return `<div ${attrs.join(" ")}>`;
128
- });
129
- html = html.replace(closeRegex, "</div>");
130
- }
131
- return html;
132
- }
133
- function applyExtendedPrefixedLayoutMap(content, map) {
134
- let html = content;
135
- const levels = [...map.levels].sort((left, right) => {
136
- const leftMax = Math.max(...left.tokens.map((token) => token.length));
137
- const rightMax = Math.max(...right.tokens.map((token) => token.length));
138
- return rightMax - leftMax;
139
- });
140
- for (const level of levels) {
141
- const tokens = [...level.tokens].sort((left, right) => right.length - left.length);
142
- for (const token of tokens) {
143
- const openRegex = new RegExp(`\\[${escapeRegExp(token)}\\b([^\\]]*)\\]`, "gi");
144
- const closeRegex = new RegExp(`\\[\\/${escapeRegExp(token)}\\b[^\\]]*\\]`, "gi");
145
- html = html.replace(openRegex, (_, params) => {
146
- switch (level.role) {
147
- case "section":
148
- return openSectionDiv(params, level.bgParamName);
149
- case "row":
150
- return openRowDiv(params, level.colsParamName);
151
- case "column":
152
- return openColumnDiv(params, level.widthParamName);
153
- }
154
- });
155
- html = html.replace(closeRegex, "</div>");
156
- }
157
- }
158
- return html;
159
- }
160
- function applyStructuralLayoutMap(content, map) {
161
- switch (map.kind) {
162
- case "prefixed":
163
- return applyPrefixedLayoutMap(content, map);
164
- case "fractional":
165
- return applyFractionalLayoutMap(content, map);
166
- case "extended-prefixed":
167
- return applyExtendedPrefixedLayoutMap(content, map);
168
- }
169
- }
170
- function collectLayoutMaps(theme) {
171
- const maps = [];
172
- if (theme.layoutMap) maps.push(theme.layoutMap);
173
- if (theme.layoutMaps?.length) maps.push(...theme.layoutMaps);
174
- return maps;
175
- }
176
- function extractShortcodeParam(params, names) {
177
- for (const name of names) {
178
- const value = extractQuotedParam(params, name);
179
- if (value) return value;
180
- }
181
- return void 0;
182
- }
183
- function escapeHtmlText(text) {
184
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
185
- }
186
- function textToHtml(text, tag) {
187
- const paragraphs = text.split(/\n{2,}/).map((part) => part.trim()).filter(Boolean);
188
- if (paragraphs.length === 0) return "";
189
- return paragraphs.map((paragraph) => {
190
- const inner = escapeHtmlText(paragraph).replace(/\n/g, "<br />");
191
- return `<${tag}>${inner}</${tag}>`;
192
- }).join("\n");
193
- }
194
- function emitHtmlTag(tag, url) {
195
- const normalized = normalizeAssetUrl(url) ?? url;
196
- const escaped = normalized.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
197
- switch (tag) {
198
- case "img":
199
- return `<img src="${escaped}" alt="" />`;
200
- case "video":
201
- return `<video src="${escaped}" controls></video>`;
202
- case "iframe":
203
- return `<iframe src="${escaped}" loading="lazy"></iframe>`;
204
- }
205
- }
206
- function convertUrlRule(content, rule) {
207
- const prefix = escapeRegExp(rule.shortcodePrefix);
208
- const pattern = new RegExp(
209
- `\\[${prefix}\\b([^\\]]*)\\]\\s*(?:\\[\\/${prefix}\\b[^\\]]*\\])?`,
210
- "gi"
211
- );
212
- return content.replace(pattern, (block, params) => {
213
- const url = extractShortcodeParam(params, rule.urlParams);
214
- if (!url) return block;
215
- return emitHtmlTag(rule.tag, url);
216
- });
217
- }
218
- function convertTextRule(content, rule) {
219
- const prefix = escapeRegExp(rule.shortcodePrefix);
220
- const pattern = new RegExp(
221
- `\\[${prefix}\\b([^\\]]*)\\]\\s*(?:\\[\\/${prefix}\\b[^\\]]*\\])?`,
222
- "gis"
223
- );
224
- return content.replace(pattern, (block, params) => {
225
- const parts = [];
226
- for (const field of rule.fields) {
227
- const text = extractQuotedParam(params, field.param);
228
- if (!text) continue;
229
- const html = textToHtml(text, field.tag);
230
- if (html) parts.push(html);
231
- }
232
- return parts.length > 0 ? parts.join("\n") : block;
233
- });
234
- }
235
- function convertWrapperRule(content, rule) {
236
- const prefix = escapeRegExp(rule.shortcodePrefix);
237
- const pattern = new RegExp(
238
- `\\[${prefix}\\b([^\\]]*)\\]([\\s\\S]*?)\\[\\/${prefix}\\b[^\\]]*\\]`,
239
- "gi"
240
- );
241
- return content.replace(pattern, (_, params, inner) => {
242
- const parts = [];
243
- if (rule.urlParams?.length) {
244
- const url = extractShortcodeParam(params, rule.urlParams);
245
- if (url) parts.push(emitHtmlTag("img", url));
246
- }
247
- parts.push(inner.trim());
248
- return parts.filter(Boolean).join("\n");
249
- });
250
- }
251
- function convertIconImageRule(content, rule) {
252
- const prefix = escapeRegExp(rule.shortcodePrefix);
253
- const pattern = new RegExp(
254
- `\\[${prefix}\\b([^\\]]*)\\]\\s*(?:\\[\\/${prefix}\\b[^\\]]*\\])?`,
255
- "gi"
256
- );
257
- return content.replace(pattern, (_, params) => {
258
- const iconImage = extractQuotedParam(params, rule.imageParam);
259
- if (!iconImage?.startsWith("http") || iconImage.includes("placehold")) {
260
- return "";
261
- }
262
- const img = emitHtmlTag("img", iconImage);
263
- if (rule.hrefParam) {
264
- const href = extractQuotedParam(params, rule.hrefParam);
265
- if (href?.startsWith("http")) {
266
- const escapedHref = href.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
267
- return `<a href="${escapedHref}">${img}</a>`;
268
- }
269
- }
270
- return img;
271
- });
272
- }
273
- function convertPlaceholderRule(content, rule) {
274
- const prefix = escapeRegExp(rule.shortcodePrefix);
275
- const pattern = new RegExp(
276
- `\\[${prefix}\\b([^\\]]*)\\]\\s*(?:\\[\\/${prefix}\\b[^\\]]*\\])?`,
277
- "gi"
278
- );
279
- return content.replace(pattern, rule.html);
280
- }
281
- function stripScaffoldingPrefix(content, prefix) {
282
- const escaped = escapeRegExp(prefix);
283
- const opener = new RegExp(`\\[${escaped}[a-z0-9_-]*[^\\]]*\\]`, "gi");
284
- const closer = new RegExp(`\\[\\/${escaped}[a-z0-9_-]*[^\\]]*\\]`, "gi");
285
- return content.replace(opener, "").replace(closer, "");
286
- }
287
- function stripLegacyTokens(content, tokens) {
288
- let result = content;
289
- for (const token of tokens) {
290
- const escaped = escapeRegExp(token);
291
- const opener = new RegExp(`\\[${escaped}\\b[^\\]]*\\]`, "gi");
292
- const closer = new RegExp(`\\[\\/${escaped}\\b[^\\]]*\\]`, "gi");
293
- result = result.replace(opener, "").replace(closer, "");
294
- }
295
- return result;
296
- }
297
- function detectThemes(content, registry) {
298
- return registry.filter((theme) => theme.detect.test(content));
299
- }
300
- function extractBareOrQuotedParam(params, name) {
301
- const quoted = extractQuotedParam(params, name);
302
- if (quoted) return quoted;
303
- const pattern = new RegExp(`\\b${escapeRegExp(name)}\\s*=\\s*([^\\s"'\\]]+)`, "i");
304
- const match = pattern.exec(params);
305
- return match?.[1]?.trim() || void 0;
306
- }
307
- function emitWidgetStub(widget, attrs, tag = "div") {
308
- const parts = [`data-wp-widget="${escapeLayoutAttr(widget)}"`];
309
- for (const [key, value] of Object.entries(attrs)) {
310
- if (value) parts.push(`${key}="${escapeLayoutAttr(value)}"`);
311
- }
312
- return `<${tag} ${parts.join(" ")}>${WP_WIDGET_PLACEHOLDER}</${tag}>`;
313
- }
314
- function normalizeVideoEmbedUrl(raw) {
315
- const trimmed = raw.trim();
316
- if (!trimmed || trimmed.startsWith("data:")) return void 0;
317
- try {
318
- const url = new URL(trimmed.startsWith("//") ? `https:${trimmed}` : trimmed);
319
- const host = url.hostname.replace(/^www\./, "").replace(/^m\./, "");
320
- if (host === "youtu.be") {
321
- const id = url.pathname.split("/").filter(Boolean)[0];
322
- if (id) {
323
- return { provider: "youtube", embedUrl: `https://www.youtube-nocookie.com/embed/${id}` };
324
- }
325
- }
326
- if (host === "youtube.com" || host === "youtube-nocookie.com") {
327
- const embedMatch = url.pathname.match(/\/embed\/([^/?#]+)/);
328
- if (embedMatch?.[1]) {
329
- const start = url.searchParams.get("start");
330
- const suffix = start ? `?start=${start}` : "";
331
- return {
332
- provider: "youtube",
333
- embedUrl: `https://www.youtube-nocookie.com/embed/${embedMatch[1]}${suffix}`
334
- };
335
- }
336
- const videoId = url.searchParams.get("v");
337
- if (videoId) {
338
- const t = url.searchParams.get("t") ?? url.searchParams.get("start");
339
- const startSeconds = t?.endsWith("s") ? t.slice(0, -1) : t;
340
- const suffix = startSeconds ? `?start=${startSeconds}` : "";
341
- return {
342
- provider: "youtube",
343
- embedUrl: `https://www.youtube-nocookie.com/embed/${videoId}${suffix}`
344
- };
345
- }
346
- }
347
- if (host === "vimeo.com") {
348
- const segments = url.pathname.split("/").filter(Boolean);
349
- const id = segments[segments.length - 1];
350
- if (id && /^\d+$/.test(id)) {
351
- return { provider: "vimeo", embedUrl: `https://player.vimeo.com/video/${id}` };
352
- }
353
- }
354
- if (host === "player.vimeo.com") {
355
- const match = url.pathname.match(/\/video\/(\d+)/);
356
- if (match?.[1]) {
357
- return { provider: "vimeo", embedUrl: `https://player.vimeo.com/video/${match[1]}` };
358
- }
359
- }
360
- } catch {
361
- return void 0;
362
- }
363
- return void 0;
364
- }
365
- function emitVideoWidgetFromParams(params, inner) {
366
- const url = extractShortcodeParam(params, ["url", "src", "video", "link", "youtube_url", "vimeo_url"]) ?? inner.trim().match(/^https?:\/\/\S+/)?.[0];
367
- if (!url) {
368
- return emitWidgetStub("video", { "data-video-provider": "external" });
369
- }
370
- const normalized = normalizeVideoEmbedUrl(url);
371
- if (normalized) {
372
- return emitWidgetStub("video", {
373
- "data-video-provider": normalized.provider,
374
- "data-embed-url": normalized.embedUrl
375
- });
376
- }
377
- if (/\.(mp4|webm|ogg)(\?|#|$)/i.test(url)) {
378
- return emitHtmlTag("video", url);
379
- }
380
- return emitWidgetStub("video", {
381
- "data-video-provider": "external",
382
- "data-embed-url": url
383
- });
384
- }
385
- function flattenMapShortcodes(content, widgetRegistry) {
386
- let html = content;
387
- for (const prefix of widgetRegistry.mapShortcodePrefixes) {
388
- const pattern = new RegExp(
389
- `\\[${escapeRegExp(prefix)}\\b([^\\]]*)\\]\\s*(?:\\[\\/${escapeRegExp(prefix)}\\b[^\\]]*\\])?`,
390
- "gi"
391
- );
392
- html = html.replace(pattern, (_, params) => {
393
- const embedUrl = extractShortcodeParam(params, ["embed_url", "url", "src", "map_url"]);
394
- const query = extractBareOrQuotedParam(params, "address") ?? extractBareOrQuotedParam(params, "q");
395
- return emitWidgetStub("map", {
396
- ...embedUrl?.includes("google.com/maps") ? { "data-embed-url": embedUrl } : {},
397
- ...query && !embedUrl ? { "data-wp-map-query": query } : {}
398
- });
399
- });
400
- }
401
- return html;
402
- }
403
- function flattenContactFormShortcodes(content, widgetRegistry) {
404
- let html = content;
405
- for (const rule of widgetRegistry.contactFormRules) {
406
- const pattern = new RegExp(
407
- `\\[${escapeRegExp(rule.tag)}\\b([^\\]]*)\\]\\s*(?:\\[\\/${escapeRegExp(rule.tag)}\\b[^\\]]*\\])?`,
408
- "gi"
409
- );
410
- html = html.replace(pattern, (_, params) => {
411
- const id = extractBareOrQuotedParam(params, rule.idParam);
412
- return emitWidgetStub(
413
- "contact-form",
414
- {
415
- "data-wp-form-source": rule.source,
416
- ...id ? { "data-wp-form-id": id } : {}
417
- },
418
- "section"
419
- );
420
- });
421
- }
422
- return html;
423
- }
424
- function emitInlineGalleryFromIds(idList) {
425
- const images = idList.map((id) => `<img data-wp-attachment-id="${escapeLayoutAttr(id)}" alt="" />`).join("");
426
- return `<figure data-wp-inline-gallery>${images}</figure>`;
427
- }
428
- function parseGalleryAttachmentIds(params) {
429
- const ids = extractBareOrQuotedParam(params, "ids");
430
- const idList = ids?.split(",").map((part) => part.trim()).filter((part) => /^\d+$/.test(part));
431
- return idList?.length ? idList : void 0;
432
- }
433
- function flattenIdGalleryShortcode(content, tag) {
434
- const escaped = escapeRegExp(tag);
435
- const pattern = new RegExp(`\\[${escaped}\\b([^\\]]*)\\](?:\\s*\\[\\/${escaped}\\])?`, "gi");
436
- return content.replace(pattern, (fullMatch, params) => {
437
- const idList = parseGalleryAttachmentIds(params);
438
- if (idList?.length) {
439
- return emitInlineGalleryFromIds(idList);
440
- }
441
- return fullMatch;
442
- });
443
- }
444
- function flattenGalleryShortcodes(content, widgetRegistry) {
445
- const tag = escapeRegExp(widgetRegistry.galleryShortcode);
446
- const pattern = new RegExp(`\\[${tag}\\b([^\\]]*)\\](?:\\s*\\[\\/${tag}\\])?`, "gi");
447
- return content.replace(pattern, (_, params) => {
448
- const idList = parseGalleryAttachmentIds(params);
449
- if (idList?.length) {
450
- return emitInlineGalleryFromIds(idList);
451
- }
452
- const category = extractBareOrQuotedParam(params, "category") ?? extractBareOrQuotedParam(params, "type");
453
- return emitWidgetStub("portfolio", {
454
- "data-wp-gallery-dynamic": "1",
455
- ...category ? { "data-wp-portfolio-category": category } : {}
456
- });
457
- });
458
- }
459
- function flattenIdBasedGalleryShortcodes(content, widgetRegistry) {
460
- let html = content;
461
- for (const tag of widgetRegistry.idGalleryShortcodes) {
462
- html = flattenIdGalleryShortcode(html, tag);
463
- }
464
- return html;
465
- }
466
- function flattenPortfolioShortcodes(content, widgetRegistry) {
467
- const tag = escapeRegExp(widgetRegistry.portfolioShortcode);
468
- const pattern = new RegExp(`\\[${tag}\\b([^\\]]*)\\](?:\\s*\\[\\/${tag}\\])?`, "gi");
469
- return content.replace(pattern, (_, params) => {
470
- const category = extractBareOrQuotedParam(params, "category");
471
- const slug = extractBareOrQuotedParam(params, "slug");
472
- return emitWidgetStub("portfolio", {
473
- ...category ? { "data-wp-portfolio-category": category } : {},
474
- ...slug ? { "data-wp-portfolio-slug": slug } : {}
475
- });
476
- });
477
- }
478
- function flattenVideoShortcodes(content, widgetRegistry) {
479
- let html = content;
480
- for (const prefix of widgetRegistry.videoShortcodePrefixes) {
481
- const wrapped = new RegExp(
482
- `\\[${escapeRegExp(prefix)}\\b([^\\]]*)\\]([\\s\\S]*?)\\[\\/${escapeRegExp(prefix)}\\b[^\\]]*\\]`,
483
- "gi"
484
- );
485
- html = html.replace(
486
- wrapped,
487
- (_, params, inner) => emitVideoWidgetFromParams(params, inner)
488
- );
489
- const selfClosing = new RegExp(
490
- `\\[${escapeRegExp(prefix)}\\b([^\\]]*)\\]`,
491
- "gi"
492
- );
493
- html = html.replace(selfClosing, (_, params) => emitVideoWidgetFromParams(params, ""));
494
- }
495
- return html;
496
- }
497
- function flattenWordPressWidgets(content, widgetRegistry = WORDPRESS_WIDGET_REGISTRY) {
498
- let html = content;
499
- html = flattenGalleryShortcodes(html, widgetRegistry);
500
- html = flattenIdBasedGalleryShortcodes(html, widgetRegistry);
501
- html = flattenPortfolioShortcodes(html, widgetRegistry);
502
- html = flattenMapShortcodes(html, widgetRegistry);
503
- html = flattenContactFormShortcodes(html, widgetRegistry);
504
- html = flattenVideoShortcodes(html, widgetRegistry);
505
- return html;
506
- }
507
- function flattenWordPressBuilders(content, options = {}) {
508
- if (!content.trim()) {
509
- return { html: content, detectedThemes: [] };
510
- }
511
- const registry = options.registry ?? WORDPRESS_BUILDER_REGISTRY;
512
- const themes = detectThemes(content, registry);
513
- const widgetRegistry = options.widgetRegistry ?? WORDPRESS_WIDGET_REGISTRY;
514
- let html = flattenWordPressWidgets(content, widgetRegistry);
515
- for (const theme of themes) {
516
- for (const rule of theme.wrapperRules ?? []) {
517
- html = convertWrapperRule(html, rule);
518
- }
519
- for (const rule of theme.textRules ?? []) {
520
- html = convertTextRule(html, rule);
521
- }
522
- for (const rule of theme.urlRules ?? []) {
523
- html = convertUrlRule(html, rule);
524
- }
525
- for (const rule of theme.placeholderRules ?? []) {
526
- html = convertPlaceholderRule(html, rule);
527
- }
528
- for (const rule of theme.iconImageRules ?? []) {
529
- html = convertIconImageRule(html, rule);
530
- }
531
- for (const layoutMap of collectLayoutMaps(theme)) {
532
- html = applyStructuralLayoutMap(html, layoutMap);
533
- }
534
- for (const prefix of theme.scaffoldingPrefixes ?? []) {
535
- html = stripScaffoldingPrefix(html, prefix);
536
- }
537
- if (theme.legacyScaffoldingTokens?.length) {
538
- html = stripLegacyTokens(html, theme.legacyScaffoldingTokens);
539
- }
540
- }
541
- html = html.replace(/\n{3,}/g, "\n\n").trim();
542
- return {
543
- html,
544
- detectedThemes: themes.map((theme) => theme.id)
545
- };
546
- }
547
-
548
- // src/parsers/wordpress/parse-wxr.ts
549
33
  var PLATFORM = "wordpress";
550
34
  var DEFAULT_WORDPRESS_PORTFOLIO_CPT_SLUGS = ["portfolio"];
551
35
  var WOOCOMMERCE_STUB_PAGE_SLUGS = /* @__PURE__ */ new Set(["cart", "checkout", "my-account"]);
@@ -671,6 +155,86 @@ function getPostMeta(item, key) {
671
155
  }
672
156
  return void 0;
673
157
  }
158
+ var PORTFOLIO_LISTING_PAGE_SLUGS = /* @__PURE__ */ new Set([
159
+ "portfolio",
160
+ "work",
161
+ "works",
162
+ "gallery",
163
+ "projects",
164
+ "our-work"
165
+ ]);
166
+ function inferPortfolioListingPage(item, options) {
167
+ if (options.isPortfolioCpt || options.postType !== "page") return false;
168
+ const template = (getPostMeta(item, "_wp_page_template") ?? "").trim().toLowerCase();
169
+ if (template.includes("portfolio") && template !== "default") return true;
170
+ const hasPortfolioListingWidget = /data-wp-widget=["']portfolio["']/i.test(options.contentHtml);
171
+ return hasPortfolioListingWidget && PORTFOLIO_LISTING_PAGE_SLUGS.has(options.slug.toLowerCase());
172
+ }
173
+ function toHeroSliderHint(parsed, source) {
174
+ return {
175
+ plugin: parsed.plugin,
176
+ alias: parsed.alias,
177
+ slidertitle: parsed.slidertitle,
178
+ source
179
+ };
180
+ }
181
+ function findSliderInTatsuTree(node) {
182
+ if (!node) return void 0;
183
+ if (Array.isArray(node)) {
184
+ for (const child of node) {
185
+ const found = findSliderInTatsuTree(child);
186
+ if (found) return found;
187
+ }
188
+ return void 0;
189
+ }
190
+ if (typeof node !== "object") return void 0;
191
+ const obj = node;
192
+ const name = typeof obj.name === "string" ? obj.name : "";
193
+ if (name === "tatsu_rev_slider") {
194
+ const atts = obj.atts;
195
+ const alias = typeof atts?.rev_slider_alias === "string" ? atts.rev_slider_alias.trim() : "";
196
+ if (alias) {
197
+ return toHeroSliderHint({ plugin: "revslider", alias }, "tatsu-json");
198
+ }
199
+ }
200
+ if (name === "masterslider" || name === "tatsu_masterslider") {
201
+ const atts = obj.atts;
202
+ const alias = typeof atts?.alias === "string" ? atts.alias.trim() : "";
203
+ if (alias) {
204
+ return toHeroSliderHint({ plugin: "masterslider", alias }, "tatsu-json");
205
+ }
206
+ }
207
+ if (obj.inner) return findSliderInTatsuTree(obj.inner);
208
+ return void 0;
209
+ }
210
+ function inferHeroSliderLayoutHint(item) {
211
+ const shortcodeMeta = getPostMeta(item, "be_themes_hero_section_slider_shortcode");
212
+ if (shortcodeMeta) {
213
+ const parsed = parseSliderShortcodeMarkup(shortcodeMeta);
214
+ if (parsed) {
215
+ return { heroSlider: toHeroSliderHint(parsed, "meta-shortcode") };
216
+ }
217
+ }
218
+ const sliderMeta = getPostMeta(item, "_slider");
219
+ if (sliderMeta) {
220
+ const parsed = parseSliderMetaValue(sliderMeta);
221
+ if (parsed) {
222
+ return { heroSlider: toHeroSliderHint(parsed, "meta-slider-field") };
223
+ }
224
+ }
225
+ const heroSection = (getPostMeta(item, "be_themes_hero_section") ?? "").trim().toLowerCase();
226
+ if (heroSection === "slider") {
227
+ const tatsuContent = getPostMeta(item, "_tatsu_page_content");
228
+ if (tatsuContent) {
229
+ try {
230
+ const heroSlider = findSliderInTatsuTree(JSON.parse(tatsuContent));
231
+ if (heroSlider) return { heroSlider };
232
+ } catch {
233
+ }
234
+ }
235
+ }
236
+ return void 0;
237
+ }
674
238
  function parseItems(xml) {
675
239
  const parser = new XMLParser({
676
240
  ignoreAttributes: false,
@@ -922,6 +486,13 @@ async function* enumerateWxrEntities(options) {
922
486
  yield post;
923
487
  } else {
924
488
  const isHomePage = !isPortfolioCpt && (getPostMeta(item, "_wp_show_on_front") === "1" || getPostMeta(item, "page_on_front") === "1");
489
+ const isPortfolioPage = !isPortfolioCpt && inferPortfolioListingPage(item, {
490
+ postType,
491
+ isPortfolioCpt,
492
+ slug,
493
+ contentHtml
494
+ });
495
+ const layoutHints = inferHeroSliderLayoutHint(item);
925
496
  const pageSourceId = isPortfolioCpt ? portfolioCptSourceId(id) : id;
926
497
  const page = {
927
498
  type: "page",
@@ -931,6 +502,8 @@ async function* enumerateWxrEntities(options) {
931
502
  slug,
932
503
  contentHtml,
933
504
  isHomePage: isHomePage || void 0,
505
+ isPortfolioPage: isPortfolioPage || void 0,
506
+ layoutHints: layoutHints ?? void 0,
934
507
  status: mapPublishStatus(textValue(item.status))
935
508
  };
936
509
  yield page;
@@ -2990,4 +2563,4 @@ export {
2990
2563
  wixAdapter,
2991
2564
  getAdapter
2992
2565
  };
2993
- //# sourceMappingURL=chunk-YLVPZ4M3.js.map
2566
+ //# sourceMappingURL=chunk-53VXTXGM.js.map