pict-section-form 1.3.15 → 1.3.16
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/docs/Providers.md +12 -7
- package/docs/_sidebar.md +2 -0
- package/docs/input_providers/016-facet-filter.md +106 -0
- package/docs/input_providers/README.md +1 -0
- package/example_applications/README.md +6 -0
- package/example_applications/facet_filter/.quackage.json +9 -0
- package/example_applications/facet_filter/Facet-Filter-Application.js +210 -0
- package/example_applications/facet_filter/Facet-Filter-Server.js +233 -0
- package/example_applications/facet_filter/Facet-Filter-Smoke-Runner.js +101 -0
- package/example_applications/facet_filter/FacetFilterData.json +44 -0
- package/example_applications/facet_filter/README-FacetFilter.md +70 -0
- package/example_applications/facet_filter/html/Facet-Filter-Smoke.js +128 -0
- package/example_applications/facet_filter/html/index.html +74 -0
- package/example_applications/facet_filter/package.json +27 -0
- package/example_applications/nested_distill_sandbox/Sandbox-Driver-Headlight.js +17 -0
- package/example_applications/nested_distill_sandbox/Sandbox-Driver.js +369 -0
- package/example_applications/nested_distill_sandbox/Sandbox-Runner.js +372 -0
- package/example_applications/nested_distill_sandbox/approaches/A1-tabular-trigger-group.js +67 -0
- package/example_applications/nested_distill_sandbox/approaches/A3-crossmap-selectoptionsrefresh.js +61 -0
- package/example_applications/nested_distill_sandbox/approaches/A4-graph-solvers-flat-list.js +53 -0
- package/example_applications/nested_distill_sandbox/approaches/A5-facet-filter.js +75 -0
- package/example_applications/nested_distill_sandbox/approaches/A5b-facet-filter-symmetric.js +15 -0
- package/example_applications/nested_distill_sandbox/approaches/A5h-facet-filter-headlight-picker.js +15 -0
- package/example_applications/nested_distill_sandbox/approaches/R0-original-jmf-manifest-headlight.js +27 -0
- package/example_applications/nested_distill_sandbox/approaches/R1-real-jmf-manifest-headlight.js +136 -0
- package/example_applications/nested_distill_sandbox/approaches/_Common.js +344 -0
- package/example_applications/nested_distill_sandbox/approaches/_Scenarios.js +262 -0
- package/package.json +1 -1
- package/source/providers/Pict-Provider-DynamicSolver.js +2 -0
- package/source/providers/Pict-Provider-ListDistilling.js +266 -1
- package/source/providers/Pict-Provider-MetaLists.js +16 -2
- package/source/providers/inputs/Pict-Provider-Input-FacetFilter.js +232 -0
- package/source/providers/inputs/Pict-Provider-Input-Select.js +41 -1
- package/source/views/Pict-View-Form-Metacontroller.js +5 -3
- package/test/Pict-Provider-ListDistilling-Facet_tests.js +375 -0
- package/test/PictSectionForm-Injection-Conformance_tests.js +11 -0
- package/test/fixtures/injection/Injection-Fixture-Cases.js +1 -0
- package/test/fixtures/injection/Injection-Fixture-Manifest.json +15 -0
- package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
- package/types/source/providers/Pict-Provider-ListDistilling.d.ts +90 -1
- package/types/source/providers/Pict-Provider-ListDistilling.d.ts.map +1 -1
- package/types/source/providers/Pict-Provider-MetaLists.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts +103 -0
- package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts.map +1 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts +12 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts.map +1 -1
- package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
|
@@ -0,0 +1,369 @@
|
|
|
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 };
|