@orion-studios/payload-studio 0.6.0-beta.70 → 0.6.0-beta.72
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.
|
@@ -175,7 +175,7 @@ var normalizeBuilderV2ProjectData = (value, fallbackTitle = "Untitled Page") =>
|
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
// src/builder-v2/runtime/placeholders.ts
|
|
178
|
-
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)
|
|
178
|
+
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)>/gis;
|
|
179
179
|
var attrPattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)=(?:"([^"]*)"|'([^']*)')/g;
|
|
180
180
|
var decodeHtmlAttribute = (value) => value.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
181
181
|
var parseAttributes = (value) => {
|
|
@@ -208,9 +208,19 @@ var parseAttributes = (value) => {
|
|
|
208
208
|
return props;
|
|
209
209
|
};
|
|
210
210
|
var extractAttribute = (attrs, name) => {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
attrPattern.lastIndex = 0;
|
|
212
|
+
let match;
|
|
213
|
+
while ((match = attrPattern.exec(attrs)) !== null) {
|
|
214
|
+
if (match[1] === name) {
|
|
215
|
+
return decodeHtmlAttribute(match[2] ?? match[3] ?? "");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
};
|
|
220
|
+
var extractWrapperAttributes = (attrs) => {
|
|
221
|
+
const id = extractAttribute(attrs, "id") || void 0;
|
|
222
|
+
const className = extractAttribute(attrs, "class") || void 0;
|
|
223
|
+
return id || className ? { className, id } : void 0;
|
|
214
224
|
};
|
|
215
225
|
var parseBuilderV2DynamicComponents = (html) => {
|
|
216
226
|
const instances = [];
|
|
@@ -224,7 +234,8 @@ var parseBuilderV2DynamicComponents = (html) => {
|
|
|
224
234
|
instances.push({
|
|
225
235
|
component,
|
|
226
236
|
id: extractAttribute(attrs, "data-orion-id") || `component-${instances.length + 1}`,
|
|
227
|
-
props: parseAttributes(attrs)
|
|
237
|
+
props: parseAttributes(attrs),
|
|
238
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
228
239
|
});
|
|
229
240
|
}
|
|
230
241
|
return instances;
|
|
@@ -51,7 +51,7 @@ var normalizeBuilderV2ProjectData = (value, fallbackTitle = "Untitled Page") =>
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// src/builder-v2/runtime/placeholders.ts
|
|
54
|
-
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)
|
|
54
|
+
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)>/gis;
|
|
55
55
|
var attrPattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)=(?:"([^"]*)"|'([^']*)')/g;
|
|
56
56
|
var decodeHtmlAttribute = (value) => value.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
57
57
|
var parseAttributes = (value) => {
|
|
@@ -84,9 +84,19 @@ var parseAttributes = (value) => {
|
|
|
84
84
|
return props;
|
|
85
85
|
};
|
|
86
86
|
var extractAttribute = (attrs, name) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
attrPattern.lastIndex = 0;
|
|
88
|
+
let match;
|
|
89
|
+
while ((match = attrPattern.exec(attrs)) !== null) {
|
|
90
|
+
if (match[1] === name) {
|
|
91
|
+
return decodeHtmlAttribute(match[2] ?? match[3] ?? "");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
var extractWrapperAttributes = (attrs) => {
|
|
97
|
+
const id = extractAttribute(attrs, "id") || void 0;
|
|
98
|
+
const className = extractAttribute(attrs, "class") || void 0;
|
|
99
|
+
return id || className ? { className, id } : void 0;
|
|
90
100
|
};
|
|
91
101
|
var parseBuilderV2DynamicComponents = (html) => {
|
|
92
102
|
const instances = [];
|
|
@@ -100,7 +110,8 @@ var parseBuilderV2DynamicComponents = (html) => {
|
|
|
100
110
|
instances.push({
|
|
101
111
|
component,
|
|
102
112
|
id: extractAttribute(attrs, "data-orion-id") || `component-${instances.length + 1}`,
|
|
103
|
-
props: parseAttributes(attrs)
|
|
113
|
+
props: parseAttributes(attrs),
|
|
114
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
104
115
|
});
|
|
105
116
|
}
|
|
106
117
|
return instances;
|
|
@@ -103,6 +103,10 @@ type BuilderV2DynamicComponentInstance = {
|
|
|
103
103
|
component: string;
|
|
104
104
|
id: string;
|
|
105
105
|
props: Record<string, unknown>;
|
|
106
|
+
wrapperAttributes?: {
|
|
107
|
+
className?: string;
|
|
108
|
+
id?: string;
|
|
109
|
+
};
|
|
106
110
|
};
|
|
107
111
|
type BuilderV2RuntimeComponentProps = {
|
|
108
112
|
instance: BuilderV2DynamicComponentInstance;
|
|
@@ -103,6 +103,10 @@ type BuilderV2DynamicComponentInstance = {
|
|
|
103
103
|
component: string;
|
|
104
104
|
id: string;
|
|
105
105
|
props: Record<string, unknown>;
|
|
106
|
+
wrapperAttributes?: {
|
|
107
|
+
className?: string;
|
|
108
|
+
id?: string;
|
|
109
|
+
};
|
|
106
110
|
};
|
|
107
111
|
type BuilderV2RuntimeComponentProps = {
|
|
108
112
|
instance: BuilderV2DynamicComponentInstance;
|
package/dist/builder-v2/index.js
CHANGED
|
@@ -185,7 +185,7 @@ var appendBuilderV2PageFields = (fields, options) => [
|
|
|
185
185
|
];
|
|
186
186
|
|
|
187
187
|
// src/builder-v2/runtime/placeholders.ts
|
|
188
|
-
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)
|
|
188
|
+
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)>/gis;
|
|
189
189
|
var attrPattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)=(?:"([^"]*)"|'([^']*)')/g;
|
|
190
190
|
var decodeHtmlAttribute = (value) => value.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
191
191
|
var parseAttributes = (value) => {
|
|
@@ -218,9 +218,39 @@ var parseAttributes = (value) => {
|
|
|
218
218
|
return props;
|
|
219
219
|
};
|
|
220
220
|
var extractAttribute = (attrs, name) => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
attrPattern.lastIndex = 0;
|
|
222
|
+
let match;
|
|
223
|
+
while ((match = attrPattern.exec(attrs)) !== null) {
|
|
224
|
+
if (match[1] === name) {
|
|
225
|
+
return decodeHtmlAttribute(match[2] ?? match[3] ?? "");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
};
|
|
230
|
+
var extractWrapperAttributes = (attrs) => {
|
|
231
|
+
const id = extractAttribute(attrs, "id") || void 0;
|
|
232
|
+
const className = extractAttribute(attrs, "class") || void 0;
|
|
233
|
+
return id || className ? { className, id } : void 0;
|
|
234
|
+
};
|
|
235
|
+
var findPlaceholderEnd = (html, tag, startIndex) => {
|
|
236
|
+
const tagPattern = new RegExp(`<\\/?${tag}\\b[^>]*>`, "gi");
|
|
237
|
+
tagPattern.lastIndex = startIndex;
|
|
238
|
+
let depth = 1;
|
|
239
|
+
let match;
|
|
240
|
+
while ((match = tagPattern.exec(html)) !== null) {
|
|
241
|
+
const token = match[0];
|
|
242
|
+
const isClosing = token.startsWith("</");
|
|
243
|
+
const isSelfClosing = /\/\s*>$/.test(token);
|
|
244
|
+
if (isClosing) {
|
|
245
|
+
depth -= 1;
|
|
246
|
+
} else if (!isSelfClosing) {
|
|
247
|
+
depth += 1;
|
|
248
|
+
}
|
|
249
|
+
if (depth === 0) {
|
|
250
|
+
return tagPattern.lastIndex;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return startIndex;
|
|
224
254
|
};
|
|
225
255
|
var parseBuilderV2DynamicComponents = (html) => {
|
|
226
256
|
const instances = [];
|
|
@@ -234,7 +264,8 @@ var parseBuilderV2DynamicComponents = (html) => {
|
|
|
234
264
|
instances.push({
|
|
235
265
|
component,
|
|
236
266
|
id: extractAttribute(attrs, "data-orion-id") || `component-${instances.length + 1}`,
|
|
237
|
-
props: parseAttributes(attrs)
|
|
267
|
+
props: parseAttributes(attrs),
|
|
268
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
238
269
|
});
|
|
239
270
|
}
|
|
240
271
|
return instances;
|
|
@@ -251,16 +282,20 @@ var splitBuilderV2HtmlIntoChunks = (html) => {
|
|
|
251
282
|
}
|
|
252
283
|
const attrs = `${match.groups?.attrs ?? ""} ${match.groups?.rest ?? ""}`;
|
|
253
284
|
const component = match.groups?.component ?? "";
|
|
285
|
+
const tag = match.groups?.tag ?? "";
|
|
286
|
+
const placeholderEnd = tag ? findPlaceholderEnd(html, tag, placeholderPattern.lastIndex) : placeholderPattern.lastIndex;
|
|
254
287
|
chunks.push({
|
|
255
288
|
instance: {
|
|
256
289
|
component,
|
|
257
290
|
id: extractAttribute(attrs, "data-orion-id") || `component-${componentIndex + 1}`,
|
|
258
|
-
props: parseAttributes(attrs)
|
|
291
|
+
props: parseAttributes(attrs),
|
|
292
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
259
293
|
},
|
|
260
294
|
kind: "component"
|
|
261
295
|
});
|
|
262
296
|
componentIndex += 1;
|
|
263
|
-
lastIndex =
|
|
297
|
+
lastIndex = placeholderEnd;
|
|
298
|
+
placeholderPattern.lastIndex = placeholderEnd;
|
|
264
299
|
}
|
|
265
300
|
const after = html.slice(lastIndex);
|
|
266
301
|
if (after.length > 0) {
|
|
@@ -710,7 +745,20 @@ function BuilderPageRuntime({ adapter, className, page }) {
|
|
|
710
745
|
`component-${chunk.instance.id}-${index}`
|
|
711
746
|
);
|
|
712
747
|
}
|
|
713
|
-
|
|
748
|
+
const renderedComponent = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { instance: chunk.instance, page });
|
|
749
|
+
const wrapperAttributes = chunk.instance.wrapperAttributes;
|
|
750
|
+
if (wrapperAttributes?.id || wrapperAttributes?.className) {
|
|
751
|
+
return (0, import_react.createElement)(
|
|
752
|
+
"div",
|
|
753
|
+
{
|
|
754
|
+
className: wrapperAttributes.className,
|
|
755
|
+
id: wrapperAttributes.id,
|
|
756
|
+
key: `component-${chunk.instance.id}-${index}`
|
|
757
|
+
},
|
|
758
|
+
renderedComponent
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
return (0, import_react.createElement)(import_react.Fragment, { key: `component-${chunk.instance.id}-${index}` }, renderedComponent);
|
|
714
762
|
})
|
|
715
763
|
] });
|
|
716
764
|
}
|
|
@@ -136,7 +136,7 @@ var appendBuilderV2PageFields = (fields, options) => [
|
|
|
136
136
|
];
|
|
137
137
|
|
|
138
138
|
// src/builder-v2/runtime/placeholders.ts
|
|
139
|
-
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)
|
|
139
|
+
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)>/gis;
|
|
140
140
|
var attrPattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)=(?:"([^"]*)"|'([^']*)')/g;
|
|
141
141
|
var decodeHtmlAttribute = (value) => value.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
142
142
|
var parseAttributes = (value) => {
|
|
@@ -169,9 +169,39 @@ var parseAttributes = (value) => {
|
|
|
169
169
|
return props;
|
|
170
170
|
};
|
|
171
171
|
var extractAttribute = (attrs, name) => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
attrPattern.lastIndex = 0;
|
|
173
|
+
let match;
|
|
174
|
+
while ((match = attrPattern.exec(attrs)) !== null) {
|
|
175
|
+
if (match[1] === name) {
|
|
176
|
+
return decodeHtmlAttribute(match[2] ?? match[3] ?? "");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
};
|
|
181
|
+
var extractWrapperAttributes = (attrs) => {
|
|
182
|
+
const id = extractAttribute(attrs, "id") || void 0;
|
|
183
|
+
const className = extractAttribute(attrs, "class") || void 0;
|
|
184
|
+
return id || className ? { className, id } : void 0;
|
|
185
|
+
};
|
|
186
|
+
var findPlaceholderEnd = (html, tag, startIndex) => {
|
|
187
|
+
const tagPattern = new RegExp(`<\\/?${tag}\\b[^>]*>`, "gi");
|
|
188
|
+
tagPattern.lastIndex = startIndex;
|
|
189
|
+
let depth = 1;
|
|
190
|
+
let match;
|
|
191
|
+
while ((match = tagPattern.exec(html)) !== null) {
|
|
192
|
+
const token = match[0];
|
|
193
|
+
const isClosing = token.startsWith("</");
|
|
194
|
+
const isSelfClosing = /\/\s*>$/.test(token);
|
|
195
|
+
if (isClosing) {
|
|
196
|
+
depth -= 1;
|
|
197
|
+
} else if (!isSelfClosing) {
|
|
198
|
+
depth += 1;
|
|
199
|
+
}
|
|
200
|
+
if (depth === 0) {
|
|
201
|
+
return tagPattern.lastIndex;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return startIndex;
|
|
175
205
|
};
|
|
176
206
|
var parseBuilderV2DynamicComponents = (html) => {
|
|
177
207
|
const instances = [];
|
|
@@ -185,7 +215,8 @@ var parseBuilderV2DynamicComponents = (html) => {
|
|
|
185
215
|
instances.push({
|
|
186
216
|
component,
|
|
187
217
|
id: extractAttribute(attrs, "data-orion-id") || `component-${instances.length + 1}`,
|
|
188
|
-
props: parseAttributes(attrs)
|
|
218
|
+
props: parseAttributes(attrs),
|
|
219
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
189
220
|
});
|
|
190
221
|
}
|
|
191
222
|
return instances;
|
|
@@ -202,16 +233,20 @@ var splitBuilderV2HtmlIntoChunks = (html) => {
|
|
|
202
233
|
}
|
|
203
234
|
const attrs = `${match.groups?.attrs ?? ""} ${match.groups?.rest ?? ""}`;
|
|
204
235
|
const component = match.groups?.component ?? "";
|
|
236
|
+
const tag = match.groups?.tag ?? "";
|
|
237
|
+
const placeholderEnd = tag ? findPlaceholderEnd(html, tag, placeholderPattern.lastIndex) : placeholderPattern.lastIndex;
|
|
205
238
|
chunks.push({
|
|
206
239
|
instance: {
|
|
207
240
|
component,
|
|
208
241
|
id: extractAttribute(attrs, "data-orion-id") || `component-${componentIndex + 1}`,
|
|
209
|
-
props: parseAttributes(attrs)
|
|
242
|
+
props: parseAttributes(attrs),
|
|
243
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
210
244
|
},
|
|
211
245
|
kind: "component"
|
|
212
246
|
});
|
|
213
247
|
componentIndex += 1;
|
|
214
|
-
lastIndex =
|
|
248
|
+
lastIndex = placeholderEnd;
|
|
249
|
+
placeholderPattern.lastIndex = placeholderEnd;
|
|
215
250
|
}
|
|
216
251
|
const after = html.slice(lastIndex);
|
|
217
252
|
if (after.length > 0) {
|
|
@@ -661,7 +696,20 @@ function BuilderPageRuntime({ adapter, className, page }) {
|
|
|
661
696
|
`component-${chunk.instance.id}-${index}`
|
|
662
697
|
);
|
|
663
698
|
}
|
|
664
|
-
|
|
699
|
+
const renderedComponent = /* @__PURE__ */ jsx(Component, { instance: chunk.instance, page });
|
|
700
|
+
const wrapperAttributes = chunk.instance.wrapperAttributes;
|
|
701
|
+
if (wrapperAttributes?.id || wrapperAttributes?.className) {
|
|
702
|
+
return createElement(
|
|
703
|
+
"div",
|
|
704
|
+
{
|
|
705
|
+
className: wrapperAttributes.className,
|
|
706
|
+
id: wrapperAttributes.id,
|
|
707
|
+
key: `component-${chunk.instance.id}-${index}`
|
|
708
|
+
},
|
|
709
|
+
renderedComponent
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
return createElement(Fragment, { key: `component-${chunk.instance.id}-${index}` }, renderedComponent);
|
|
665
713
|
})
|
|
666
714
|
] });
|
|
667
715
|
}
|
package/package.json
CHANGED