pict-section-form 1.3.14 → 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.
Files changed (80) hide show
  1. package/docs/Injection_Conformance.md +137 -0
  2. package/docs/Providers.md +12 -7
  3. package/docs/_sidebar.md +3 -0
  4. package/docs/input_providers/016-facet-filter.md +106 -0
  5. package/docs/input_providers/README.md +1 -0
  6. package/example_applications/README.md +6 -0
  7. package/example_applications/facet_filter/.quackage.json +9 -0
  8. package/example_applications/facet_filter/Facet-Filter-Application.js +210 -0
  9. package/example_applications/facet_filter/Facet-Filter-Server.js +233 -0
  10. package/example_applications/facet_filter/Facet-Filter-Smoke-Runner.js +101 -0
  11. package/example_applications/facet_filter/FacetFilterData.json +44 -0
  12. package/example_applications/facet_filter/README-FacetFilter.md +70 -0
  13. package/example_applications/facet_filter/html/Facet-Filter-Smoke.js +128 -0
  14. package/example_applications/facet_filter/html/index.html +74 -0
  15. package/example_applications/facet_filter/package.json +27 -0
  16. package/example_applications/nested_distill_sandbox/Sandbox-Driver-Headlight.js +17 -0
  17. package/example_applications/nested_distill_sandbox/Sandbox-Driver.js +369 -0
  18. package/example_applications/nested_distill_sandbox/Sandbox-Runner.js +372 -0
  19. package/example_applications/nested_distill_sandbox/approaches/A1-tabular-trigger-group.js +67 -0
  20. package/example_applications/nested_distill_sandbox/approaches/A3-crossmap-selectoptionsrefresh.js +61 -0
  21. package/example_applications/nested_distill_sandbox/approaches/A4-graph-solvers-flat-list.js +53 -0
  22. package/example_applications/nested_distill_sandbox/approaches/A5-facet-filter.js +75 -0
  23. package/example_applications/nested_distill_sandbox/approaches/A5b-facet-filter-symmetric.js +15 -0
  24. package/example_applications/nested_distill_sandbox/approaches/A5h-facet-filter-headlight-picker.js +15 -0
  25. package/example_applications/nested_distill_sandbox/approaches/R0-original-jmf-manifest-headlight.js +27 -0
  26. package/example_applications/nested_distill_sandbox/approaches/R1-real-jmf-manifest-headlight.js +136 -0
  27. package/example_applications/nested_distill_sandbox/approaches/_Common.js +344 -0
  28. package/example_applications/nested_distill_sandbox/approaches/_Scenarios.js +262 -0
  29. package/package.json +6 -5
  30. package/source/providers/Pict-Provider-DynamicFormSolverBehaviors.js +73 -5
  31. package/source/providers/Pict-Provider-DynamicSolver.js +22 -2
  32. package/source/providers/Pict-Provider-ListDistilling.js +266 -1
  33. package/source/providers/Pict-Provider-MetaLists.js +16 -2
  34. package/source/providers/inputs/Pict-Provider-Input-FacetFilter.js +232 -0
  35. package/source/providers/inputs/Pict-Provider-Input-Select.js +41 -1
  36. package/source/views/Pict-View-Form-Metacontroller.js +690 -93
  37. package/test/Pict-Provider-DynamicFormSolverBehaviors-OrdinalScope_tests.js +105 -0
  38. package/test/Pict-Provider-ListDistilling-Facet_tests.js +375 -0
  39. package/test/Pict-View-Form-Metacontroller-DistinctManifest_tests.js +410 -0
  40. package/test/PictSectionForm-Injection-Conformance_tests.js +762 -0
  41. package/test/browser/Injection-Conformance-Differential-Scenario.js +346 -0
  42. package/test/browser/Injection-Conformance-EdgeCase-Scenario.js +168 -0
  43. package/test/browser/Injection-Conformance-Harness-Driver.js +538 -0
  44. package/test/browser/Injection-Conformance-Harness-Runner.js +487 -0
  45. package/test/browser/Injection-Conformance-Reconstitution-Scenario.js +191 -0
  46. package/test/browser/Injection-Conformance-Standalone-Scenario.js +114 -0
  47. package/test/fixtures/injection/Injection-Fixture-Cases.js +204 -0
  48. package/test/fixtures/injection/Injection-Fixture-Manifest.json +381 -0
  49. package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts +110 -1
  50. package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts.map +1 -1
  51. package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
  52. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts +17 -1
  53. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts.map +1 -1
  54. package/types/source/providers/Pict-Provider-InputExtension.d.ts +31 -0
  55. package/types/source/providers/Pict-Provider-InputExtension.d.ts.map +1 -1
  56. package/types/source/providers/Pict-Provider-ListDistilling.d.ts +90 -1
  57. package/types/source/providers/Pict-Provider-ListDistilling.d.ts.map +1 -1
  58. package/types/source/providers/Pict-Provider-MetaLists.d.ts.map +1 -1
  59. package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts +16 -0
  60. package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts.map +1 -0
  61. package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts +47 -0
  62. package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts.map +1 -1
  63. package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts +86 -0
  64. package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts.map +1 -1
  65. package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts +103 -0
  66. package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts.map +1 -0
  67. package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts +128 -0
  68. package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts.map +1 -0
  69. package/types/source/providers/inputs/Pict-Provider-Input-PreciseNumber.d.ts.map +1 -1
  70. package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts +12 -0
  71. package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts.map +1 -1
  72. package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts +10 -1
  73. package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts.map +1 -1
  74. package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts +10 -1
  75. package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts.map +1 -1
  76. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts +76 -4
  77. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts.map +1 -1
  78. package/types/source/views/Pict-View-DynamicForm.d.ts.map +1 -1
  79. package/types/source/views/Pict-View-Form-Metacontroller.d.ts +63 -2
  80. package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "facet_filter_application",
3
+ "version": "1.0.0",
4
+ "description": "Dropdowns over one shared catalog, each narrowed by the others in its row, served by a small REST stand-in.",
5
+ "main": "Facet-Filter-Application.js",
6
+ "scripts": {
7
+ "start": "node Facet-Filter-Server.js",
8
+ "build": "npx quack build && npx quack copy",
9
+ "smoke": "node Facet-Filter-Smoke-Runner.js"
10
+ },
11
+ "license": "MIT",
12
+ "devDependencies": {
13
+ },
14
+ "copyFilesSettings": {
15
+ "whenFileExists": "overwrite"
16
+ },
17
+ "copyFiles": [
18
+ {
19
+ "from": "./html/*",
20
+ "to": "./dist/"
21
+ },
22
+ {
23
+ "from": "../../node_modules/pict/dist/*",
24
+ "to": "./dist/"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,17 @@
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');
@@ -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 };