@parhelia/page-wizard 0.1.11004 → 0.1.11005

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 (91) hide show
  1. package/dist/SplashScreen.d.ts +1 -0
  2. package/dist/SplashScreen.js +110 -0
  3. package/dist/SplashScreen.js.map +1 -0
  4. package/dist/dist/PageWizard.d.ts +78 -0
  5. package/dist/dist/PageWizard.js +57 -0
  6. package/dist/dist/PageWizard.js.map +1 -0
  7. package/dist/dist/SplashScreen.d.ts +1 -0
  8. package/dist/dist/SplashScreen.js +110 -0
  9. package/dist/dist/SplashScreen.js.map +1 -0
  10. package/dist/dist/WizardBoxConnector.d.ts +4 -0
  11. package/dist/dist/WizardBoxConnector.js +6 -0
  12. package/dist/dist/WizardBoxConnector.js.map +1 -0
  13. package/dist/dist/WizardSteps.d.ts +8 -0
  14. package/dist/dist/WizardSteps.js +174 -0
  15. package/dist/dist/WizardSteps.js.map +1 -0
  16. package/dist/dist/config.d.ts +2 -0
  17. package/dist/dist/config.js +86 -0
  18. package/dist/dist/config.js.map +1 -0
  19. package/dist/dist/index.d.ts +2 -0
  20. package/dist/dist/index.js +2 -0
  21. package/dist/dist/index.js.map +1 -0
  22. package/dist/dist/service.d.ts +15 -0
  23. package/dist/dist/service.js +29 -0
  24. package/dist/dist/service.js.map +1 -0
  25. package/dist/dist/startPageWizardCommand.d.ts +13 -0
  26. package/dist/dist/startPageWizardCommand.js +31 -0
  27. package/dist/dist/startPageWizardCommand.js.map +1 -0
  28. package/dist/dist/steps/BuildPageStep.d.ts +2 -0
  29. package/dist/dist/steps/BuildPageStep.js +138 -0
  30. package/dist/dist/steps/BuildPageStep.js.map +1 -0
  31. package/dist/dist/steps/CollectStep.d.ts +2 -0
  32. package/dist/dist/steps/CollectStep.js +115 -0
  33. package/dist/dist/steps/CollectStep.js.map +1 -0
  34. package/dist/dist/steps/ComponentTypesSelector.d.ts +13 -0
  35. package/dist/dist/steps/ComponentTypesSelector.js +155 -0
  36. package/dist/dist/steps/ComponentTypesSelector.js.map +1 -0
  37. package/dist/dist/steps/Components.d.ts +9 -0
  38. package/dist/dist/steps/Components.js +89 -0
  39. package/dist/dist/steps/Components.js.map +1 -0
  40. package/dist/dist/steps/ContentStep.d.ts +2 -0
  41. package/dist/dist/steps/ContentStep.js +808 -0
  42. package/dist/dist/steps/ContentStep.js.map +1 -0
  43. package/dist/dist/steps/EditButton.d.ts +8 -0
  44. package/dist/dist/steps/EditButton.js +5 -0
  45. package/dist/dist/steps/EditButton.js.map +1 -0
  46. package/dist/dist/steps/FieldEditor.d.ts +5 -0
  47. package/dist/dist/steps/FieldEditor.js +27 -0
  48. package/dist/dist/steps/FieldEditor.js.map +1 -0
  49. package/dist/dist/steps/FindItemsStep.d.ts +2 -0
  50. package/dist/dist/steps/FindItemsStep.js +294 -0
  51. package/dist/dist/steps/FindItemsStep.js.map +1 -0
  52. package/dist/dist/steps/Generate.d.ts +6 -0
  53. package/dist/dist/steps/Generate.js +31 -0
  54. package/dist/dist/steps/Generate.js.map +1 -0
  55. package/dist/dist/steps/ImagesStep.d.ts +2 -0
  56. package/dist/dist/steps/ImagesStep.js +178 -0
  57. package/dist/dist/steps/ImagesStep.js.map +1 -0
  58. package/dist/dist/steps/LayoutStep.d.ts +2 -0
  59. package/dist/dist/steps/LayoutStep.js +128 -0
  60. package/dist/dist/steps/LayoutStep.js.map +1 -0
  61. package/dist/dist/steps/MetaDataStep.d.ts +2 -0
  62. package/dist/dist/steps/MetaDataStep.js +112 -0
  63. package/dist/dist/steps/MetaDataStep.js.map +1 -0
  64. package/dist/dist/steps/SchottSelectImagesStep.d.ts +2 -0
  65. package/dist/dist/steps/SchottSelectImagesStep.js +55 -0
  66. package/dist/dist/steps/SchottSelectImagesStep.js.map +1 -0
  67. package/dist/dist/steps/SelectStep.d.ts +2 -0
  68. package/dist/dist/steps/SelectStep.js +151 -0
  69. package/dist/dist/steps/SelectStep.js.map +1 -0
  70. package/dist/dist/steps/StructureStep.d.ts +2 -0
  71. package/dist/dist/steps/StructureStep.js +205 -0
  72. package/dist/dist/steps/StructureStep.js.map +1 -0
  73. package/dist/dist/steps/TranslateStep.d.ts +2 -0
  74. package/dist/dist/steps/TranslateStep.js +613 -0
  75. package/dist/dist/steps/TranslateStep.js.map +1 -0
  76. package/dist/dist/steps/schema.d.ts +13 -0
  77. package/dist/dist/steps/schema.js +139 -0
  78. package/dist/dist/steps/schema.js.map +1 -0
  79. package/dist/dist/steps/usePageCreator.d.ts +7 -0
  80. package/dist/dist/steps/usePageCreator.js +285 -0
  81. package/dist/dist/steps/usePageCreator.js.map +1 -0
  82. package/dist/dist/types.d.ts +27 -0
  83. package/dist/dist/types.js +2 -0
  84. package/dist/dist/types.js.map +1 -0
  85. package/dist/dist/usePageWizard.d.ts +22 -0
  86. package/dist/dist/usePageWizard.js +69 -0
  87. package/dist/dist/usePageWizard.js.map +1 -0
  88. package/dist/dist/utils/dataAccessor.d.ts +57 -0
  89. package/dist/dist/utils/dataAccessor.js +323 -0
  90. package/dist/dist/utils/dataAccessor.js.map +1 -0
  91. package/package.json +1 -1
@@ -0,0 +1,69 @@
1
+ import { useMemo, useState, useRef } from "react";
2
+ export const usePageWizard = () => {
3
+ const [wizard, setWizard] = useState(undefined);
4
+ const [parentItem, setParentItem] = useState(undefined);
5
+ // Wizard step state that should persist across re-renders
6
+ const [currentStepIndex, setCurrentStepIndex] = useState(0);
7
+ const [data, setData] = useState({});
8
+ const [pageModel, setPageModel] = useState({
9
+ components: [],
10
+ name: "",
11
+ metaDescription: "",
12
+ metaKeywords: "",
13
+ fields: [],
14
+ });
15
+ const [internalState, setInternalState] = useState({});
16
+ const [stepCompleted, setStepCompleted] = useState(-1);
17
+ const [pageItem, setPageItem] = useState();
18
+ const beforeNextCallbackRef = useRef(null);
19
+ // Reset wizard step state when wizard changes
20
+ const setWizardWithReset = (value) => {
21
+ const newWizard = typeof value === "function" ? value(wizard) : value;
22
+ if (newWizard !== wizard) {
23
+ setCurrentStepIndex(0);
24
+ setData({});
25
+ setPageModel({
26
+ components: [],
27
+ name: "",
28
+ metaDescription: "",
29
+ metaKeywords: "",
30
+ fields: [],
31
+ });
32
+ setInternalState({});
33
+ setStepCompleted(-1);
34
+ setPageItem(undefined);
35
+ beforeNextCallbackRef.current = null;
36
+ }
37
+ setWizard(newWizard);
38
+ };
39
+ return useMemo(() => ({
40
+ wizard,
41
+ setWizard: setWizardWithReset,
42
+ parentItem,
43
+ setParentItem,
44
+ // Wizard step state
45
+ currentStepIndex,
46
+ setCurrentStepIndex,
47
+ data,
48
+ setData,
49
+ pageModel,
50
+ setPageModel,
51
+ internalState,
52
+ setInternalState,
53
+ stepCompleted,
54
+ setStepCompleted,
55
+ pageItem,
56
+ setPageItem,
57
+ beforeNextCallbackRef,
58
+ }), [
59
+ wizard,
60
+ parentItem,
61
+ currentStepIndex,
62
+ data,
63
+ pageModel,
64
+ internalState,
65
+ stepCompleted,
66
+ pageItem,
67
+ ]);
68
+ };
69
+ //# sourceMappingURL=usePageWizard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePageWizard.js","sourceRoot":"","sources":["../src/usePageWizard.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIzD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IACpE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAC1C,SAAS,CACV,CAAC;IAEF,0DAA0D;IAC1D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;IACjD,MAAM,CAAC,SAAS,EAAE,Y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kBAAkB;QAC7B,UAAU;QACV,aAAa;QACb,oBAAoB;QACpB,gBAAgB;QAChB,mBAAmB;QACnB,IAAI;QACJ,OAAO;QACP,SAAS;QACT,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,aAAa;QACb,gBAAgB;QAChB,QAAQ;QACR,WAAW;QACX,qBAAqB;KACtB,CAAC,EACF;QACE,MAAM;QACN,UAAU;QACV,gBAAgB;QAChB,IAAI;QACJ,SAAS;QACT,aAAa;QACb,aAAa;QACb,QAAQ;KACT,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Utility for flexible data access in wizard steps
3
+ * Allows both simple property names and JavaScript expressions
4
+ */
5
+ export interface DataAccessResult<T = any> {
6
+ value: T | undefined;
7
+ error?: string;
8
+ }
9
+ /**
10
+ * Safely evaluates JavaScript expressions or property accessors against a data object
11
+ * @param inputProperties - Either a simple property name, a JavaScript expression, or multiple expressions separated by newlines
12
+ * @param data - The data object to evaluate against
13
+ * @returns The evaluated value(s) or undefined with an error message
14
+ */
15
+ export declare function evaluateDataExpression<T = any>(inputProperties: string, data: any): DataAccessResult<T>;
16
+ /**
17
+ * Evaluates expressions and maps them to object properties
18
+ * Supports explicit property names (name:expression) and implicit property names (derived from expression)
19
+ * @param inputProperties - Multiple expressions separated by newlines, optionally with explicit property names
20
+ * @param data - The data object to evaluate against
21
+ * @returns Object with properties mapped from expressions
22
+ */
23
+ export declare function evaluateDataExpressionToObject(inputProperties: string, data: any): DataAccessResult<Record<string, any>>;
24
+ /**
25
+ * Sets a value in the data object using either a simple property name or a path
26
+ * For now, this only supports simple property names since setting via expressions is complex
27
+ * @param propertyName - The property name to set
28
+ * @param value - The value to set
29
+ * @param data - The current data object
30
+ * @returns Updated data object
31
+ */
32
+ export declare function setDataProperty(propertyName: string, value: any, data: any): any;
33
+ /**
34
+ * Hook for using flexible data access in wizard steps
35
+ * @param expression - The expression or property name to read from
36
+ * @param data - The current data object
37
+ * @returns Object with the evaluated value and any error
38
+ */
39
+ export declare function useDataExpression<T = any>(expression: string, data: any): DataAccessResult<T>;
40
+ /**
41
+ * Filters input data based on the "inputProperties" field from a wizard step
42
+ * @param step - The wizard step containing the inputProperties field
43
+ * @param data - The data object to filter
44
+ * @returns Filtered data object or original data if no input properties specified
45
+ */
46
+ export declare function getFilteredInputData(step: {
47
+ fields: {
48
+ [key: string]: string;
49
+ };
50
+ }, data: any): any;
51
+ /**
52
+ * Processes a template string by replacing expressions wrapped in curly braces with their evaluated values
53
+ * @param template - The template string containing expressions like {data.items.map(x=>x.id)}
54
+ * @param data - The data object to evaluate expressions against
55
+ * @returns Object with the processed template and any errors encountered
56
+ */
57
+ export declare function processPromptTemplate(template: string, data: any): DataAccessResult<string>;
@@ -0,0 +1,323 @@
1
+ /**
2
+ * Utility for flexible data access in wizard steps
3
+ * Allows both simple property names and JavaScript expressions
4
+ */
5
+ /**
6
+ * Safely evaluates JavaScript expressions or property accessors against a data object
7
+ * @param inputProperties - Either a simple property name, a JavaScript expression, or multiple expressions separated by newlines
8
+ * @param data - The data object to evaluate against
9
+ * @returns The evaluated value(s) or undefined with an error message
10
+ */
11
+ export function evaluateDataExpression(inputProperties, data) {
12
+ if (!inputProperties) {
13
+ return { value: undefined };
14
+ }
15
+ try {
16
+ // Split by newlines and filter out empty lines
17
+ const expressionLines = inputProperties
18
+ .split("\n")
19
+ .map((line) => line.trim())
20
+ .filter((line) => line.length > 0);
21
+ // If no valid expressions found, return undefined
22
+ if (expressionLines.length === 0) {
23
+ return { value: undefined };
24
+ }
25
+ // If only one expression, return single result
26
+ if (expressionLines.length === 1) {
27
+ const firstExpression = expressionLines[0];
28
+ if (firstExpression) {
29
+ return evaluateSingleExpression(firstExpression, data);
30
+ }
31
+ }
32
+ // Multiple expressions - evaluate each and collect results
33
+ const results = [];
34
+ const errors = [];
35
+ for (const expression of expressionLines) {
36
+ const result = evaluateSingleExpression(expression, data);
37
+ if (result.error) {
38
+ errors.push(`Line "${expression}": ${result.error}`);
39
+ }
40
+ else if (result.value !== undefined) {
41
+ // Only add non-undefined results
42
+ if (Array.isArray(result.value)) {
43
+ results.push(...result.value);
44
+ }
45
+ else {
46
+ results.push(result.value);
47
+ }
48
+ }
49
+ }
50
+ // Return combined results or errors
51
+ if (errors.length > 0 && results.length === 0) {
52
+ return {
53
+ value: undefined,
54
+ error: `All expressions failed:\n${errors.join("\n")}`,
55
+ };
56
+ }
57
+ return {
58
+ value: results,
59
+ error: errors.length > 0
60
+ ? `Some expressions failed:\n${errors.join("\n")}`
61
+ : undefined,
62
+ };
63
+ }
64
+ catch (error) {
65
+ return {
66
+ value: undefined,
67
+ error: `Failed to evaluate expressions "${inputProperties}": ${error instanceof Error ? error.message : String(error)}`,
68
+ };
69
+ }
70
+ }
71
+ /**
72
+ * Evaluates expressions and maps them to object properties
73
+ * Supports explicit property names (name:expression) and implicit property names (derived from expression)
74
+ * @param inputProperties - Multiple expressions separated by newlines, optionally with explicit property names
75
+ * @param data - The data object to evaluate against
76
+ * @returns Object with properties mapped from expressions
77
+ */
78
+ export function evaluateDataExpressionToObject(inputProperties, data) {
79
+ if (!inputProperties || !inputProperties.trim()) {
80
+ return { value: {} };
81
+ }
82
+ try {
83
+ // Split by newlines and filter out empty lines
84
+ const expressionLines = inputProperties
85
+ .split("\n")
86
+ .map((line) => line.trim())
87
+ .filter((line) => line.length > 0);
88
+ if (expressionLines.length === 0) {
89
+ return { value: {} };
90
+ }
91
+ const result = {};
92
+ const errors = [];
93
+ for (const line of expressionLines) {
94
+ // Check if line contains explicit property name (name:expression format)
95
+ const colonIndex = line.indexOf(":");
96
+ let propertyName;
97
+ let expression;
98
+ if (colonIndex > 0 && colonIndex < line.length - 1) {
99
+ // Explicit property name format: "name:expression"
100
+ propertyName = line.substring(0, colonIndex).trim();
101
+ expression = line.substring(colonIndex + 1).trim();
102
+ }
103
+ else {
104
+ // Implicit property name - derive from expression
105
+ expression = line;
106
+ propertyName = derivePropertyNameFromExpression(expression);
107
+ }
108
+ // Evaluate the expression
109
+ const evalResult = evaluateSingleExpression(expression, data);
110
+ if (evalResult.error) {
111
+ errors.push(`Property "${propertyName}" (${expression}): ${evalResult.error}`);
112
+ }
113
+ else {
114
+ result[propertyName] = evalResult.value;
115
+ }
116
+ }
117
+ return {
118
+ value: result,
119
+ error: errors.length > 0 ? errors.join("\n") : undefined,
120
+ };
121
+ }
122
+ catch (error) {
123
+ return {
124
+ value: {},
125
+ error: `Failed to evaluate expressions "${inputProperties}": ${error instanceof Error ? error.message : String(error)}`,
126
+ };
127
+ }
128
+ }
129
+ /**
130
+ * Derives a property name from an expression
131
+ * Examples:
132
+ * - "selectedItems" -> "selectedItems"
133
+ * - "data.selectedItems" -> "selectedItems"
134
+ * - "data.user.profile.name" -> "name"
135
+ * - "data.items.filter(x => x.active)" -> "items"
136
+ */
137
+ function derivePropertyNameFromExpression(expression) {
138
+ // Remove "data." prefix if present
139
+ let cleaned = expression.replace(/^data\./, "");
140
+ // For method calls like "items.filter(...)", take the base property
141
+ const methodMatch = cleaned.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)\./);
142
+ if (methodMatch && methodMatch[1]) {
143
+ return methodMatch[1];
144
+ }
145
+ // For property access like "user.profile.name", take the last property
146
+ const parts = cleaned.split(".");
147
+ const lastPart = parts[parts.length - 1];
148
+ if (lastPart) {
149
+ // Extract just the property name (before any method calls or array access)
150
+ const propertyMatch = lastPart.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
151
+ if (propertyMatch && propertyMatch[1]) {
152
+ return propertyMatch[1];
153
+ }
154
+ }
155
+ // Fallback to the first valid identifier in the expression
156
+ const identifierMatch = cleaned.match(/([a-zA-Z_$][a-zA-Z0-9_$]*)/);
157
+ return identifierMatch && identifierMatch[1] ? identifierMatch[1] : "result";
158
+ }
159
+ /**
160
+ * Evaluates a single expression
161
+ */
162
+ function evaluateSingleExpression(expression, data) {
163
+ try {
164
+ // Normalize whitespace
165
+ const expr = expression.trim();
166
+ // Special-case: allow `{data}` to reference the entire data object
167
+ if (expr === "data") {
168
+ return { value: data };
169
+ }
170
+ // Check if it's a simple property name (no special characters that would indicate JS code)
171
+ const isSimpleProperty = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(expr);
172
+ if (isSimpleProperty) {
173
+ // Simple property access
174
+ return { value: data[expr] };
175
+ }
176
+ // It's a JavaScript expression
177
+ // If it doesn't start with "data.", prepend it automatically
178
+ let processedExpression = expr;
179
+ if (!expr.startsWith("data.")) {
180
+ processedExpression = `data.${expr}`;
181
+ }
182
+ // Create a safe evaluation context
183
+ const evalFunction = new Function("data", `
184
+ try {
185
+ return ${processedExpression};
186
+ } catch (error) {
187
+ throw new Error('Expression evaluation failed: ' + error.message);
188
+ }
189
+ `);
190
+ const result = evalFunction(data);
191
+ return { value: result };
192
+ }
193
+ catch (error) {
194
+ return {
195
+ value: undefined,
196
+ error: `Failed to evaluate expression "${expression}": ${error instanceof Error ? error.message : String(error)}`,
197
+ };
198
+ }
199
+ }
200
+ /**
201
+ * Sets a value in the data object using either a simple property name or a path
202
+ * For now, this only supports simple property names since setting via expressions is complex
203
+ * @param propertyName - The property name to set
204
+ * @param value - The value to set
205
+ * @param data - The current data object
206
+ * @returns Updated data object
207
+ */
208
+ export function setDataProperty(propertyName, value, data) {
209
+ // For now, only support simple property names for setting
210
+ const isSimpleProperty = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propertyName);
211
+ if (!isSimpleProperty) {
212
+ console.warn(`Setting data via expressions is not supported yet. Using property name as-is: ${propertyName}`);
213
+ }
214
+ return {
215
+ ...data,
216
+ [propertyName]: value,
217
+ };
218
+ }
219
+ /**
220
+ * Hook for using flexible data access in wizard steps
221
+ * @param expression - The expression or property name to read from
222
+ * @param data - The current data object
223
+ * @returns Object with the evaluated value and any error
224
+ */
225
+ export function useDataExpression(expression, data) {
226
+ return evaluateDataExpression(expression, data);
227
+ }
228
+ /**
229
+ * Filters input data based on the "inputProperties" field from a wizard step
230
+ * @param step - The wizard step containing the inputProperties field
231
+ * @param data - The data object to filter
232
+ * @returns Filtered data object or original data if no input properties specified
233
+ */
234
+ export function getFilteredInputData(step, data) {
235
+ const inputProperties = step.fields.inputProperties;
236
+ if (!inputProperties || !inputProperties.trim()) {
237
+ return data; // Return all data if no input properties specified
238
+ }
239
+ // Use evaluateDataExpressionToObject to handle both simple properties and JavaScript expressions
240
+ const result = evaluateDataExpressionToObject(inputProperties, data);
241
+ if (result.error) {
242
+ console.warn("Error evaluating input properties:", result.error);
243
+ return data; // Fall back to all data if evaluation fails
244
+ }
245
+ return result.value ?? data; // Return evaluated result or fall back to all data
246
+ }
247
+ /**
248
+ * Processes a template string by replacing expressions wrapped in curly braces with their evaluated values
249
+ * @param template - The template string containing expressions like {data.items.map(x=>x.id)}
250
+ * @param data - The data object to evaluate expressions against
251
+ * @returns Object with the processed template and any errors encountered
252
+ */
253
+ export function processPromptTemplate(template, data) {
254
+ if (!template) {
255
+ return { value: template };
256
+ }
257
+ try {
258
+ const errors = [];
259
+ let processedTemplate = template;
260
+ // Find all expressions wrapped in curly braces
261
+ const expressionRegex = /\{([^}]+)\}/g;
262
+ let match;
263
+ const replacements = [];
264
+ while ((match = expressionRegex.exec(template)) !== null) {
265
+ const fullMatch = match[0]; // The full match including braces: {expression}
266
+ const expression = match[1]?.trim(); // The expression inside braces
267
+ if (!expression) {
268
+ continue;
269
+ }
270
+ // Evaluate the expression
271
+ const evalResult = evaluateSingleExpression(expression, data);
272
+ if (evalResult.error) {
273
+ errors.push(`Expression "${expression}": ${evalResult.error}`);
274
+ continue;
275
+ }
276
+ // Convert the result to a string representation
277
+ let replacement;
278
+ try {
279
+ if (evalResult.value === undefined || evalResult.value === null) {
280
+ replacement = "";
281
+ }
282
+ else if (typeof evalResult.value === "string") {
283
+ replacement = evalResult.value;
284
+ }
285
+ else if (Array.isArray(evalResult.value)) {
286
+ replacement = JSON.stringify(evalResult.value);
287
+ }
288
+ else if (typeof evalResult.value === "object") {
289
+ replacement = JSON.stringify(evalResult.value);
290
+ }
291
+ else {
292
+ replacement = String(evalResult.value);
293
+ }
294
+ }
295
+ catch (stringifyError) {
296
+ replacement = String(evalResult.value);
297
+ }
298
+ replacements.push({ original: fullMatch, replacement });
299
+ }
300
+ // If there are any errors, don't process the template at all
301
+ if (errors.length > 0) {
302
+ return {
303
+ value: undefined,
304
+ error: `Template processing failed:\n${errors.join("\n")}`,
305
+ };
306
+ }
307
+ // Apply all replacements
308
+ for (const { original, replacement } of replacements) {
309
+ processedTemplate = processedTemplate.replace(original, replacement);
310
+ }
311
+ return {
312
+ value: processedTemplate,
313
+ error: undefined,
314
+ };
315
+ }
316
+ catch (error) {
317
+ return {
318
+ value: undefined,
319
+ error: `Failed to process template: ${error instanceof Error ? error.message : String(error)}`,
320
+ };
321
+ }
322
+ }
323
+ //# sourceMappingURL=dataAccessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataAccessor.js","sourceRoot":"","sources":["../../src/utils/dataAccessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAAuB,EACvB,IAAS;IAET,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,CAAC;QACH,+CAA+C;QAC/C,MAAM,eAAe,GAAG,eAAe;aACpC,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAErC,kDAAkD;QAClD,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC9B,CAAC;QAED,+CAA+C;QAC/C,IAAI,eAAe,CAAC,M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AC;YACtB,OAAO;gBACL,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,gCAAgC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aAC3D,CAAC;QACJ,CAAC;QAED,yBAAyB;QACzB,KAAK,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,YAAY,EAAE,CAAC;YACrD,iBAAiB,GAAG,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACvE,CAAC;QAED,OAAO;YACL,KAAK,EAAE,iBAAiB;YACxB,KAAK,EAAE,SAAS;SACjB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SAC/F,CAAC;IACJ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parhelia/page-wizard",
3
- "version": "0.1.11004",
3
+ "version": "0.1.11005",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"