pict-section-form 1.3.16 → 1.3.17
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/package.json +1 -1
- package/source/providers/inputs/Pict-Provider-Input-Chart-CSS.js +49 -0
- package/example_applications/nested_distill_sandbox/Sandbox-Driver-Headlight.js +0 -17
- package/example_applications/nested_distill_sandbox/Sandbox-Driver.js +0 -369
- package/example_applications/nested_distill_sandbox/Sandbox-Runner.js +0 -372
- package/example_applications/nested_distill_sandbox/approaches/A1-tabular-trigger-group.js +0 -67
- package/example_applications/nested_distill_sandbox/approaches/A3-crossmap-selectoptionsrefresh.js +0 -61
- package/example_applications/nested_distill_sandbox/approaches/A4-graph-solvers-flat-list.js +0 -53
- package/example_applications/nested_distill_sandbox/approaches/A5-facet-filter.js +0 -75
- package/example_applications/nested_distill_sandbox/approaches/A5b-facet-filter-symmetric.js +0 -15
- package/example_applications/nested_distill_sandbox/approaches/A5h-facet-filter-headlight-picker.js +0 -15
- package/example_applications/nested_distill_sandbox/approaches/R0-original-jmf-manifest-headlight.js +0 -27
- package/example_applications/nested_distill_sandbox/approaches/R1-real-jmf-manifest-headlight.js +0 -136
- package/example_applications/nested_distill_sandbox/approaches/_Common.js +0 -344
- package/example_applications/nested_distill_sandbox/approaches/_Scenarios.js +0 -262
package/package.json
CHANGED
|
@@ -66,6 +66,55 @@ const libCSS = /*css*/`
|
|
|
66
66
|
border-radius: 5px; padding: 0.1rem 0.4rem; margin-bottom: 0.35rem; }
|
|
67
67
|
.pict-chart-legend-toggle:hover { color: var(--theme-color-text-primary, #1f2733);
|
|
68
68
|
border-color: var(--theme-color-border-strong, #c2c9d2); }
|
|
69
|
+
|
|
70
|
+
/* ---------------------------------------------------------------------------
|
|
71
|
+
PRINT
|
|
72
|
+
---------------------------------------------------------------------------
|
|
73
|
+
Three things break when a Chart.js chart is printed from the browser, and none
|
|
74
|
+
of them is "canvas does not print" -- the canvas rasterises fine.
|
|
75
|
+
|
|
76
|
+
1. CLIPPING. Chart.js writes an INLINE style.width/height on the canvas taken
|
|
77
|
+
from the SCREEN layout, and only corrects it from a ResizeObserver whose
|
|
78
|
+
callback runs in requestAnimationFrame -- which never fires inside the
|
|
79
|
+
synchronous print snapshot. So a canvas laid out at ~930px keeps that width
|
|
80
|
+
on a page box narrower than it, and the right-hand side is simply cut off.
|
|
81
|
+
max-width:100% overrides the inline width; height:auto keeps the ratio.
|
|
82
|
+
|
|
83
|
+
2. VANISHING SWATCHES. The legend swatches are painted with background and
|
|
84
|
+
::before/::after gradients, and browsers drop backgrounds in print unless
|
|
85
|
+
the reader happens to tick "Background graphics". Without these the legend
|
|
86
|
+
prints as a column of empty boxes and nothing can be matched to a line --
|
|
87
|
+
on a control chart, where telling the reading from the limits is the entire
|
|
88
|
+
point, that is worse than printing no legend at all.
|
|
89
|
+
|
|
90
|
+
3. INTERACTIVE AFFORDANCES. A hide-legend button and a collapse caret are
|
|
91
|
+
meaningless on paper, and a group a reader happened to collapse on screen
|
|
92
|
+
must still print -- collapsing is a space affordance, not a statement about
|
|
93
|
+
the data.
|
|
94
|
+
*/
|
|
95
|
+
@media print
|
|
96
|
+
{
|
|
97
|
+
.pict-input-chart canvas { max-width: 100% !important; height: auto !important; }
|
|
98
|
+
.pict-input-chart { break-inside: avoid; page-break-inside: avoid; }
|
|
99
|
+
|
|
100
|
+
/* Legend under the plot so the plot gets the full page width. */
|
|
101
|
+
.pict-chart-shell { display: block; break-inside: avoid; page-break-inside: avoid; }
|
|
102
|
+
.pict-chart-canvas-area { width: 100%; }
|
|
103
|
+
.pict-chart-legend { max-width: none; width: 100%; margin-top: 0.35rem; }
|
|
104
|
+
.pict-chart-legend-items { flex-direction: row; flex-wrap: wrap; gap: 0.1rem 0.75rem; }
|
|
105
|
+
|
|
106
|
+
.pict-chart-legend-toggle { display: none !important; }
|
|
107
|
+
|
|
108
|
+
.pict-chart-legend-group.pict-collapsed .pict-chart-legend-items { display: flex !important; }
|
|
109
|
+
|
|
110
|
+
.pict-chart-legend-swatch,
|
|
111
|
+
.pict-chart-legend-swatch::before,
|
|
112
|
+
.pict-chart-legend-swatch::after
|
|
113
|
+
{
|
|
114
|
+
-webkit-print-color-adjust: exact;
|
|
115
|
+
print-color-adjust: exact;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
69
118
|
`;
|
|
70
119
|
|
|
71
120
|
module.exports = libCSS;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Nested-distill sandbox driver, Headlight host: registers the Headlight dynamic inputs bundle the way a
|
|
3
|
-
Headlight application does (so Option / Select2 render as the Headlight Picker), then runs the same
|
|
4
|
-
driver. Local-only; it reaches into the monorepo checkout.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const libHeadlightDynamicInputsBundle = require('../../../../../../headlight/lib/web/headlight-dynamic-inputs-bundle/source/HeadlightDynamicInputsBundle.js');
|
|
8
|
-
|
|
9
|
-
window.SandboxHostSetup = (pPict) =>
|
|
10
|
-
{
|
|
11
|
-
const tmpBundle = new libHeadlightDynamicInputsBundle(pPict);
|
|
12
|
-
tmpBundle.attach();
|
|
13
|
-
// What web/dashboard does for an editable document.
|
|
14
|
-
pPict.views.PictFormMetacontroller.formTemplatePrefix = 'PictProvider-Theme-Edit';
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
module.exports = require('./Sandbox-Driver.js');
|
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Nested-distill sandbox: the in-page driver.
|
|
3
|
-
|
|
4
|
-
Boots a pict-section-form application with the manifest in window.SandboxConfig, serves entity reads
|
|
5
|
-
from recorded server responses (captured over the wire by the node runner), plays a script of user
|
|
6
|
-
actions against the real DOM and publishes what it saw as base64 JSON for the runner to read back
|
|
7
|
-
out of `chrome --dump-dom`.
|
|
8
|
-
*/
|
|
9
|
-
/* global Pict */
|
|
10
|
-
|
|
11
|
-
const libPictSectionForm = require('../../source/Pict-Section-Form.js');
|
|
12
|
-
|
|
13
|
-
const RESULTS_ELEMENT_ID = 'Sandbox-Results';
|
|
14
|
-
const BOOT_TIMEOUT_MS = 20000;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {number} pMilliseconds
|
|
18
|
-
* @return {Promise<void>}
|
|
19
|
-
*/
|
|
20
|
-
function wait(pMilliseconds)
|
|
21
|
-
{
|
|
22
|
-
return new Promise((fResolve) => setTimeout(fResolve, pMilliseconds));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {any} pValue
|
|
27
|
-
* @return {any}
|
|
28
|
-
*/
|
|
29
|
-
function cloneData(pValue)
|
|
30
|
-
{
|
|
31
|
-
if (pValue === undefined)
|
|
32
|
-
{
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
return JSON.parse(JSON.stringify(pValue));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class SandboxContext
|
|
39
|
-
{
|
|
40
|
-
/**
|
|
41
|
-
* @param {Record<string, any>} pConfig
|
|
42
|
-
*/
|
|
43
|
-
constructor(pConfig)
|
|
44
|
-
{
|
|
45
|
-
this.config = pConfig;
|
|
46
|
-
this.errors = [];
|
|
47
|
-
this.requests = [];
|
|
48
|
-
this.snapshots = [];
|
|
49
|
-
this.timings = {};
|
|
50
|
-
this.pict = null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Replaces the entity reads with the recorded responses, keyed "<Entity>|<Filter>".
|
|
55
|
-
*
|
|
56
|
-
* @param {any} pPict
|
|
57
|
-
*/
|
|
58
|
-
installRecordedServer(pPict)
|
|
59
|
-
{
|
|
60
|
-
const tmpResponses = this.config.ServerResponses || {};
|
|
61
|
-
const tmpLatency = this.config.ServerLatencyMs || 0;
|
|
62
|
-
const fRespond = (pEntity, pFilter, fCallback) =>
|
|
63
|
-
{
|
|
64
|
-
const tmpKey = `${pEntity}|${pFilter}`;
|
|
65
|
-
const tmpKnown = Object.prototype.hasOwnProperty.call(tmpResponses, tmpKey);
|
|
66
|
-
this.requests.push({ Entity: pEntity, Filter: pFilter, Recorded: tmpKnown, At: Date.now() });
|
|
67
|
-
setTimeout(() =>
|
|
68
|
-
{
|
|
69
|
-
if (!tmpKnown)
|
|
70
|
-
{
|
|
71
|
-
this.errors.push(`No recorded response for [${tmpKey}]`);
|
|
72
|
-
return fCallback(null, []);
|
|
73
|
-
}
|
|
74
|
-
return fCallback(null, cloneData(tmpResponses[tmpKey]));
|
|
75
|
-
}, tmpLatency);
|
|
76
|
-
};
|
|
77
|
-
pPict.EntityProvider.getEntitySet = (pEntity, pFilter, fCallback) => fRespond(pEntity, pFilter, fCallback);
|
|
78
|
-
pPict.EntityProvider.getEntitySetPage = (pEntity, pFilter, pStart, pCount, fCallback) => fRespond(pEntity, pFilter, fCallback);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @return {Promise<void>}
|
|
83
|
-
*/
|
|
84
|
-
async boot()
|
|
85
|
-
{
|
|
86
|
-
const tmpContext = this;
|
|
87
|
-
class SandboxApplication extends libPictSectionForm.PictFormApplication
|
|
88
|
-
{
|
|
89
|
-
constructor(pFable, pAppOptions, pServiceHash)
|
|
90
|
-
{
|
|
91
|
-
super(pFable, pAppOptions, pServiceHash);
|
|
92
|
-
if (tmpContext.config.MarshalDestination)
|
|
93
|
-
{
|
|
94
|
-
this.pict.providers.DataBroker.marshalDestination = tmpContext.config.MarshalDestination;
|
|
95
|
-
}
|
|
96
|
-
tmpContext.installRecordedServer(this.pict);
|
|
97
|
-
if (typeof(window.SandboxHostSetup) === 'function')
|
|
98
|
-
{
|
|
99
|
-
window.SandboxHostSetup(this.pict);
|
|
100
|
-
}
|
|
101
|
-
tmpContext.bootStart = Date.now();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
SandboxApplication.default_configuration = Object.assign({}, libPictSectionForm.PictFormApplication.default_configuration,
|
|
105
|
-
{
|
|
106
|
-
Name: 'Nested Distill Sandbox',
|
|
107
|
-
Hash: 'NestedDistillSandbox',
|
|
108
|
-
pict_configuration:
|
|
109
|
-
{
|
|
110
|
-
Product: 'NestedDistillSandbox',
|
|
111
|
-
DefaultFormManifest: cloneData(this.config.Manifest),
|
|
112
|
-
DefaultAppData: cloneData(this.config.AppData || {}),
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
Pict.safeLoadPictApplication(SandboxApplication, 0);
|
|
117
|
-
|
|
118
|
-
const tmpStart = Date.now();
|
|
119
|
-
while (!(window._Pict && window._Pict.views && window._Pict.views.PictFormMetacontroller && window._Pict.views.PictFormMetacontroller.FirstRenderCompleted))
|
|
120
|
-
{
|
|
121
|
-
if ((Date.now() - tmpStart) > BOOT_TIMEOUT_MS)
|
|
122
|
-
{
|
|
123
|
-
throw new Error('The form application did not finish its first render.');
|
|
124
|
-
}
|
|
125
|
-
await wait(20);
|
|
126
|
-
}
|
|
127
|
-
this.pict = window._Pict;
|
|
128
|
-
const tmpLog = this.pict.log;
|
|
129
|
-
const tmpOriginalError = tmpLog.error.bind(tmpLog);
|
|
130
|
-
tmpLog.error = (pMessage, pData) =>
|
|
131
|
-
{
|
|
132
|
-
this.errors.push(String(pMessage));
|
|
133
|
-
return tmpOriginalError(pMessage, pData);
|
|
134
|
-
};
|
|
135
|
-
this.timings.FirstRenderMs = Date.now() - this.bootStart;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @param {string} pGroupHash
|
|
140
|
-
* @return {{ View: any, GroupIndex: number, Group: any }}
|
|
141
|
-
*/
|
|
142
|
-
findGroup(pGroupHash)
|
|
143
|
-
{
|
|
144
|
-
for (const tmpViewHash of Object.keys(this.pict.views))
|
|
145
|
-
{
|
|
146
|
-
const tmpView = this.pict.views[tmpViewHash];
|
|
147
|
-
if (!tmpView || !tmpView.isPictSectionForm || (tmpView === this.pict.views.PictFormMetacontroller))
|
|
148
|
-
{
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const tmpGroupIndex = tmpView.getGroupIndexFromHash(pGroupHash);
|
|
152
|
-
if ((typeof tmpGroupIndex === 'number') && (tmpGroupIndex >= 0))
|
|
153
|
-
{
|
|
154
|
-
return { View: tmpView, GroupIndex: tmpGroupIndex, Group: tmpView.getGroup(tmpGroupIndex) };
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
throw new Error(`No view holds group [${pGroupHash}].`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @param {{ View: any, GroupIndex: number, Group: any }} pGroupInfo
|
|
162
|
-
* @param {string} pInputHash - the descriptor Hash (or key) of the tabular column
|
|
163
|
-
* @return {{ Input: any, InputIndex: number }}
|
|
164
|
-
*/
|
|
165
|
-
findColumn(pGroupInfo, pInputHash)
|
|
166
|
-
{
|
|
167
|
-
const tmpManifest = pGroupInfo.Group.supportingManifest;
|
|
168
|
-
const tmpAddresses = tmpManifest.elementAddresses;
|
|
169
|
-
for (let i = 0; i < tmpAddresses.length; i++)
|
|
170
|
-
{
|
|
171
|
-
const tmpDescriptor = tmpManifest.elementDescriptors[tmpAddresses[i]];
|
|
172
|
-
if ((tmpDescriptor.Hash === pInputHash) || (tmpAddresses[i] === pInputHash))
|
|
173
|
-
{
|
|
174
|
-
return { Input: pGroupInfo.View.getTabularRecordInput(pGroupInfo.GroupIndex, i), InputIndex: i };
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
throw new Error(`No column [${pInputHash}] in group [${pGroupInfo.Group.Hash}].`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Captures, for every row: the stored data, and for every select the offered options and what it shows.
|
|
182
|
-
*
|
|
183
|
-
* @param {string} pLabel
|
|
184
|
-
*/
|
|
185
|
-
snapshot(pLabel)
|
|
186
|
-
{
|
|
187
|
-
const tmpGroupInfo = this.findGroup(this.config.GroupHash);
|
|
188
|
-
const tmpRecords = cloneData(tmpGroupInfo.View.getTabularRecordSet(tmpGroupInfo.GroupIndex)) || [];
|
|
189
|
-
const tmpRows = [];
|
|
190
|
-
const tmpRecordArray = Array.isArray(tmpRecords) ? tmpRecords : Object.values(tmpRecords);
|
|
191
|
-
for (let tmpRowIndex = 0; tmpRowIndex < tmpRecordArray.length; tmpRowIndex++)
|
|
192
|
-
{
|
|
193
|
-
const tmpRow = { Data: {}, Options: {}, Shown: {} };
|
|
194
|
-
const tmpRecord = tmpRecordArray[tmpRowIndex] || {};
|
|
195
|
-
for (const tmpKey of Object.keys(tmpRecord))
|
|
196
|
-
{
|
|
197
|
-
if (!tmpKey.endsWith('__Record') && !tmpKey.endsWith('__Salt'))
|
|
198
|
-
{
|
|
199
|
-
tmpRow.Data[tmpKey] = tmpRecord[tmpKey];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
for (const tmpColumn of (this.config.SelectColumns || []))
|
|
203
|
-
{
|
|
204
|
-
const tmpColumnInfo = this.findColumn(tmpGroupInfo, tmpColumn);
|
|
205
|
-
const tmpPicker = this.pict.views[`Picker-${tmpColumnInfo.Input.Macro.RawHTMLID}-${tmpRowIndex}`];
|
|
206
|
-
if (tmpPicker)
|
|
207
|
-
{
|
|
208
|
-
tmpRow.Options[tmpColumn] = (tmpPicker.options.Options || []).map((pOption) => String(pOption.Value));
|
|
209
|
-
const tmpPickerValue = tmpPicker.getValue();
|
|
210
|
-
tmpRow.Shown[tmpColumn] = ((tmpPickerValue === undefined) || (tmpPickerValue === null) || (tmpPickerValue === '')) ? null : String(tmpPickerValue);
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
const tmpSelect = document.getElementById(`SELECT-TABULAR-DROPDOWN-${tmpColumnInfo.Input.Macro.RawHTMLID}-${tmpRowIndex}`);
|
|
214
|
-
if (!tmpSelect)
|
|
215
|
-
{
|
|
216
|
-
tmpRow.Options[tmpColumn] = null;
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
tmpRow.Options[tmpColumn] = Array.from(tmpSelect.options).map((pOption) => pOption.value);
|
|
220
|
-
tmpRow.Shown[tmpColumn] = (tmpSelect.selectedIndex >= 0) ? tmpSelect.options[tmpSelect.selectedIndex].value : null;
|
|
221
|
-
}
|
|
222
|
-
tmpRows.push(tmpRow);
|
|
223
|
-
}
|
|
224
|
-
this.snapshots.push({ Label: pLabel, At: Date.now(), Rows: tmpRows, Probe: this.probe() });
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* @return {Record<string, any>} values at the configured probe addresses (e.g. derived summary data)
|
|
229
|
-
*/
|
|
230
|
-
probe()
|
|
231
|
-
{
|
|
232
|
-
const tmpResult = {};
|
|
233
|
-
for (const tmpAddress of (this.config.ProbeAddresses || []))
|
|
234
|
-
{
|
|
235
|
-
tmpResult[tmpAddress] = cloneData(this.pict.manifest.getValueByHash(this.pict, tmpAddress));
|
|
236
|
-
}
|
|
237
|
-
return tmpResult;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Picks a value in a tabular select the way a user does: set the dropdown, then fire its onchange path.
|
|
242
|
-
*
|
|
243
|
-
* @param {number} pRowIndex
|
|
244
|
-
* @param {string} pColumn
|
|
245
|
-
* @param {string} pValue
|
|
246
|
-
*/
|
|
247
|
-
choose(pRowIndex, pColumn, pValue)
|
|
248
|
-
{
|
|
249
|
-
const tmpGroupInfo = this.findGroup(this.config.GroupHash);
|
|
250
|
-
const tmpColumnInfo = this.findColumn(tmpGroupInfo, pColumn);
|
|
251
|
-
const tmpPicker = this.pict.views[`Picker-${tmpColumnInfo.Input.Macro.RawHTMLID}-${pRowIndex}`];
|
|
252
|
-
if (tmpPicker)
|
|
253
|
-
{
|
|
254
|
-
const tmpPickerOffered = (tmpPicker.options.Options || []).map((pOption) => String(pOption.Value));
|
|
255
|
-
if ((pValue !== '') && (tmpPickerOffered.indexOf(String(pValue)) < 0))
|
|
256
|
-
{
|
|
257
|
-
this.errors.push(`choose: [${pValue}] is not offered in row ${pRowIndex} [${pColumn}] (offered ${tmpPickerOffered.length})`);
|
|
258
|
-
}
|
|
259
|
-
// What a pick does in the widget: set the value, then the picker's OnChange commits it to the form.
|
|
260
|
-
tmpPicker.setValue(String(pValue));
|
|
261
|
-
tmpPicker.options.OnChange(String(pValue));
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
const tmpSelect = document.getElementById(`SELECT-TABULAR-DROPDOWN-${tmpColumnInfo.Input.Macro.RawHTMLID}-${pRowIndex}`);
|
|
265
|
-
if (!tmpSelect)
|
|
266
|
-
{
|
|
267
|
-
throw new Error(`Row ${pRowIndex} has no dropdown for [${pColumn}].`);
|
|
268
|
-
}
|
|
269
|
-
const tmpOffered = Array.from(tmpSelect.options).map((pOption) => pOption.value);
|
|
270
|
-
if ((pValue !== '') && (tmpOffered.indexOf(String(pValue)) < 0))
|
|
271
|
-
{
|
|
272
|
-
this.errors.push(`choose: [${pValue}] is not offered in row ${pRowIndex} [${pColumn}] (offered ${tmpOffered.length})`);
|
|
273
|
-
}
|
|
274
|
-
tmpSelect.value = String(pValue);
|
|
275
|
-
// The rendered onchange handler passes its indices as strings; the event path tests them for truthiness.
|
|
276
|
-
tmpGroupInfo.View.inputDataRequestTabular(String(tmpGroupInfo.GroupIndex), String(tmpColumnInfo.InputIndex), String(pRowIndex));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* @param {Record<string, any>} pStep
|
|
281
|
-
* @return {Promise<void>}
|
|
282
|
-
*/
|
|
283
|
-
async runStep(pStep)
|
|
284
|
-
{
|
|
285
|
-
const tmpGroupInfo = this.findGroup(this.config.GroupHash);
|
|
286
|
-
const tmpStart = Date.now();
|
|
287
|
-
switch (pStep.Action)
|
|
288
|
-
{
|
|
289
|
-
case 'choose':
|
|
290
|
-
this.choose(pStep.Row, pStep.Column, pStep.Value);
|
|
291
|
-
break;
|
|
292
|
-
case 'addRow':
|
|
293
|
-
tmpGroupInfo.View.createDynamicTableRow(tmpGroupInfo.GroupIndex);
|
|
294
|
-
break;
|
|
295
|
-
case 'deleteRow':
|
|
296
|
-
await tmpGroupInfo.View.deleteDynamicTableRow(tmpGroupInfo.GroupIndex, pStep.Row);
|
|
297
|
-
break;
|
|
298
|
-
case 'moveRowUp':
|
|
299
|
-
tmpGroupInfo.View.moveDynamicTableRowUp(tmpGroupInfo.GroupIndex, pStep.Row);
|
|
300
|
-
break;
|
|
301
|
-
case 'wait':
|
|
302
|
-
await wait(pStep.Ms || 0);
|
|
303
|
-
break;
|
|
304
|
-
case 'snapshot':
|
|
305
|
-
this.snapshot(pStep.Label);
|
|
306
|
-
break;
|
|
307
|
-
default:
|
|
308
|
-
throw new Error(`Unknown step action [${pStep.Action}].`);
|
|
309
|
-
}
|
|
310
|
-
if (pStep.Action !== 'snapshot')
|
|
311
|
-
{
|
|
312
|
-
this.timings[`step:${pStep.Label || pStep.Action}`] = Date.now() - tmpStart;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
publish(pFatal)
|
|
317
|
-
{
|
|
318
|
-
const tmpResults =
|
|
319
|
-
{
|
|
320
|
-
Fatal: pFatal || null,
|
|
321
|
-
Errors: this.errors.slice(0, 200),
|
|
322
|
-
ErrorCount: this.errors.length,
|
|
323
|
-
Requests: this.requests,
|
|
324
|
-
Snapshots: this.snapshots,
|
|
325
|
-
Timings: this.timings,
|
|
326
|
-
};
|
|
327
|
-
const tmpEncoded = window.btoa(unescape(encodeURIComponent(JSON.stringify(tmpResults))));
|
|
328
|
-
let tmpElement = document.getElementById(RESULTS_ELEMENT_ID);
|
|
329
|
-
if (!tmpElement)
|
|
330
|
-
{
|
|
331
|
-
tmpElement = document.createElement('div');
|
|
332
|
-
tmpElement.id = RESULTS_ELEMENT_ID;
|
|
333
|
-
document.body.appendChild(tmpElement);
|
|
334
|
-
}
|
|
335
|
-
tmpElement.setAttribute('data-results', tmpEncoded);
|
|
336
|
-
document.title = 'Sandbox:done';
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* @return {Promise<void>}
|
|
342
|
-
*/
|
|
343
|
-
async function run()
|
|
344
|
-
{
|
|
345
|
-
const tmpContext = new SandboxContext(window.SandboxConfig);
|
|
346
|
-
window.addEventListener('error', (pEvent) =>
|
|
347
|
-
{
|
|
348
|
-
tmpContext.errors.push(`window.onerror: ${pEvent.message}`);
|
|
349
|
-
});
|
|
350
|
-
let tmpFatal = null;
|
|
351
|
-
try
|
|
352
|
-
{
|
|
353
|
-
await tmpContext.boot();
|
|
354
|
-
await wait(tmpContext.config.SettleMs || 50);
|
|
355
|
-
tmpContext.snapshot('loaded');
|
|
356
|
-
for (const tmpStep of (tmpContext.config.Script || []))
|
|
357
|
-
{
|
|
358
|
-
await tmpContext.runStep(tmpStep);
|
|
359
|
-
await wait((typeof tmpStep.SettleMs === 'number') ? tmpStep.SettleMs : (tmpContext.config.SettleMs || 50));
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
catch (pError)
|
|
363
|
-
{
|
|
364
|
-
tmpFatal = (pError && pError.stack) ? pError.stack : String(pError);
|
|
365
|
-
}
|
|
366
|
-
tmpContext.publish(tmpFatal);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
module.exports = { run: run };
|