@inseefr/lunatic 2.7.1 → 2.7.2

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 (164) hide show
  1. package/README.md +45 -11
  2. package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
  3. package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +2 -1
  4. package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
  5. package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
  6. package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
  7. package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -2
  8. package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
  9. package/lib/components/checkbox/commons/checkbox-option.js +3 -1
  10. package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
  11. package/lib/components/commons/components/combo-box/combo-box.js +2 -2
  12. package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
  13. package/lib/components/commons/components/combo-box/selection/input.js +3 -1
  14. package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
  15. package/lib/components/commons/components/errors/errors.js +12 -10
  16. package/lib/components/commons/components/errors/errors.spec.js +6 -6
  17. package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
  18. package/lib/components/component-set/html/component-set.js +2 -2
  19. package/lib/components/datepicker/html/DatepickerField.js +47 -0
  20. package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +209 -17
  21. package/lib/components/datepicker/html/datepicker.js +104 -21
  22. package/lib/components/datepicker/html/datepicker.scss +19 -1
  23. package/lib/components/datepicker/html/datepicker.spec.js +71 -23
  24. package/lib/components/datepicker/lunatic-datepicker.js +5 -2
  25. package/lib/components/dropdown/lunatic-dropdown.js +2 -1
  26. package/lib/components/duration/duration.js +6 -7
  27. package/lib/components/duration/duration.scss +6 -14
  28. package/lib/components/duration/durationInput.js +14 -8
  29. package/lib/components/duration/durationUtils.js +38 -8
  30. package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
  31. package/lib/components/input/html/input.js +3 -3
  32. package/lib/components/input/lunatic-input.js +2 -1
  33. package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
  34. package/lib/components/input-number/html/input-number-thousand.js +4 -17
  35. package/lib/components/input-number/html/input-number.js +3 -5
  36. package/lib/components/input-number/lunatic-input-number.js +2 -3
  37. package/lib/components/loop/roster-for-loop/__snapshots__/roster-for-loop.spec.tsx.snap +88 -0
  38. package/lib/components/loop/roster-for-loop/roster-for-loop.js +7 -3
  39. package/lib/components/loop/roster-for-loop/roster-for-loop.spec.js +46 -0
  40. package/lib/components/lunatic-components.js +2 -11
  41. package/lib/components/radio/html/radio-group-content.js +4 -2
  42. package/lib/components/radio/html/radio-group.js +3 -3
  43. package/lib/components/radio/html/radio-option.js +3 -1
  44. package/lib/components/radio/lunatic-radio-group.js +2 -1
  45. package/lib/components/suggester/find-best-label/find-best-label.js +5 -5
  46. package/lib/components/suggester/idb-suggester/check-store.js +6 -3
  47. package/lib/components/suggester/idb-suggester/idb-suggester.js +8 -7
  48. package/lib/components/suggester/idb-suggester/suggester-status.js +1 -4
  49. package/lib/components/suggester/lunatic-suggester.js +7 -4
  50. package/lib/components/suggester/searching/create-searching.js +19 -42
  51. package/lib/components/switch/html/switch.js +2 -2
  52. package/lib/components/switch/lunatic-switch.js +2 -1
  53. package/lib/components/table/lunatic-table.js +2 -2
  54. package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
  55. package/lib/components/textarea/html/textarea.js +6 -4
  56. package/lib/components/textarea/lunatic-textarea.js +6 -3
  57. package/lib/hooks/use-auto-focus.js +26 -0
  58. package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
  59. package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
  60. package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
  61. package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
  62. package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
  63. package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
  64. package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
  65. package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
  66. package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
  67. package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
  68. package/lib/src/components/datepicker/html/DatepickerField.d.ts +12 -0
  69. package/lib/src/components/datepicker/html/datepicker.d.ts +4 -3
  70. package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -0
  71. package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
  72. package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
  73. package/lib/src/components/duration/durationInput.d.ts +6 -2
  74. package/lib/src/components/duration/durationUtils.d.ts +24 -7
  75. package/lib/src/components/input/html/input.d.ts +2 -2
  76. package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
  77. package/lib/src/components/input-number/html/input-number.d.ts +2 -3
  78. package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
  79. package/lib/src/components/radio/html/radio-group.d.ts +1 -1
  80. package/lib/src/components/radio/html/radio-option.d.ts +1 -0
  81. package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
  82. package/lib/src/components/suggester/html/suggester.d.ts +1 -1
  83. package/lib/src/components/suggester/idb-suggester/check-store.d.ts +5 -2
  84. package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
  85. package/lib/src/components/suggester/idb-suggester/suggester-status.d.ts +1 -4
  86. package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
  87. package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
  88. package/lib/src/components/switch/html/switch.d.ts +1 -1
  89. package/lib/src/components/textarea/html/textarea.d.ts +3 -2
  90. package/lib/src/components/type.d.ts +5 -3
  91. package/lib/src/hooks/use-auto-focus.d.ts +6 -0
  92. package/lib/src/use-lunatic/actions.d.ts +2 -0
  93. package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +383 -0
  94. package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +1 -1
  95. package/lib/src/use-lunatic/commons/fill-components/fill-component-value.spec.d.ts +1 -0
  96. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +20 -0
  97. package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +4 -0
  98. package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +1 -0
  99. package/lib/src/use-lunatic/type.d.ts +1 -0
  100. package/lib/src/use-lunatic/use-lunatic.d.ts +8 -3
  101. package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
  102. package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +2 -2
  103. package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
  104. package/lib/stories/behaviour/cleaning/source.json +151 -0
  105. package/lib/stories/behaviour/cleaning/test.stories.js +82 -0
  106. package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
  107. package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
  108. package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +3 -3
  109. package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +3 -3
  110. package/lib/stories/date-picker/datepicker.stories.js +32 -29
  111. package/lib/stories/duration/duration.stories.js +4 -4
  112. package/lib/stories/duration/{source.json → mois.json} +1 -1
  113. package/lib/stories/duration/{source1.json → time.json} +1 -1
  114. package/lib/use-lunatic/commons/fill-components/fill-component-required.js +23 -0
  115. package/lib/use-lunatic/commons/fill-components/fill-component-value.js +1 -1
  116. package/lib/use-lunatic/commons/fill-components/fill-component-value.spec.js +67 -0
  117. package/lib/use-lunatic/commons/fill-components/fill-components.js +2 -1
  118. package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
  119. package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +15 -0
  120. package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +9 -1
  121. package/lib/use-lunatic/initial-state.js +2 -1
  122. package/lib/use-lunatic/reducer/reduce-on-init.js +4 -2
  123. package/lib/use-lunatic/use-lunatic.js +7 -3
  124. package/lib/use-lunatic/use-suggesters.js +54 -37
  125. package/lib/utils/env.js +9 -1
  126. package/lib/utils/suggester-workers/append-to-index/create-append-task.js +5 -4
  127. package/lib/utils/suggester-workers/create-worker.js +10 -1
  128. package/lib/utils/suggester-workers/worker-path.js +29 -0
  129. package/package.json +24 -11
  130. package/scripts/build/add-workers-to-public.js +44 -0
  131. package/scripts/build/workers-paths.js +45 -0
  132. package/workers-release/lunatic-append-worker-0.3.0.js +2 -0
  133. package/workers-release/lunatic-append-worker-0.3.0.js.LICENSE.txt +34 -0
  134. package/workers-release/lunatic-label-worker-0.3.0.js +2 -0
  135. package/workers-release/lunatic-label-worker-0.3.0.js.LICENSE.txt +13 -0
  136. package/workers-release/lunatic-search-worker-0.3.0.js +2 -0
  137. package/workers-release/lunatic-search-worker-0.3.0.js.LICENSE.txt +34 -0
  138. package/lib/components/datepicker/html/datepicker-container.js +0 -17
  139. package/lib/components/datepicker/html/datepicker-input.js +0 -35
  140. package/lib/env.d.js +0 -1
  141. package/lib/src/components/datepicker/html/datepicker-container.d.ts +0 -3
  142. package/lib/src/components/datepicker/html/datepicker-input.d.ts +0 -13
  143. package/lib/src/utils/get-component-value.d.ts +0 -5
  144. package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
  145. package/lib/utils/get-component-value.js +0 -34
  146. package/lib/utils/get-component-value.test.js +0 -57
  147. package/lib/utils/store-tools/worker-path.js +0 -13
  148. package/lib/utils/suggester-workers/create-worker-ts.js +0 -54
  149. /package/lib/src/{utils/get-component-value.test.d.ts → components/loop/roster-for-loop/roster-for-loop.spec.d.ts} +0 -0
  150. /package/lib/src/utils/suggester-workers/{create-worker-ts.d.ts → create-worker.d.ts} +0 -0
  151. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
  152. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
  153. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
  154. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
  155. /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
  156. /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
  157. /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
  158. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
  159. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
  160. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
  161. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
  162. /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
  163. /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
  164. /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * Snowball JavaScript Library v0.3
3
+ * http://code.google.com/p/urim/
4
+ * http://snowball.tartarus.org/
5
+ *
6
+ * Copyright 2010, Oleg Mazko
7
+ * http://www.mozilla.org/MPL/
8
+ */
9
+
10
+ /*!
11
+ * array-last <https://github.com/jonschlinkert/array-last>
12
+ *
13
+ * Copyright (c) 2014-2017, Jon Schlinkert.
14
+ * Released under the MIT License.
15
+ */
16
+
17
+ /*!
18
+ * is-number <https://github.com/jonschlinkert/is-number>
19
+ *
20
+ * Copyright (c) 2014-2017, Jon Schlinkert.
21
+ * Released under the MIT License.
22
+ */
23
+
24
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
25
+
26
+ /**
27
+ * @license React
28
+ * react.production.min.js
29
+ *
30
+ * Copyright (c) Facebook, Inc. and its affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
- function DatepickerContainer(_ref) {
11
- var children = _ref.children;
12
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
13
- className: "lunatic-input",
14
- children: children
15
- });
16
- }
17
- var _default = exports["default"] = DatepickerContainer;
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _classnames = _interopRequireDefault(require("classnames"));
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
- function DatepickerInput(_ref) {
11
- var id = _ref.id,
12
- disabled = _ref.disabled,
13
- readOnly = _ref.readOnly,
14
- labelId = _ref.labelId,
15
- value = _ref.value,
16
- onChange = _ref.onChange,
17
- min = _ref.min,
18
- max = _ref.max;
19
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
20
- id: id,
21
- className: (0, _classnames["default"])('lunatic-datepicker', {
22
- disabled: disabled,
23
- readOnly: readOnly
24
- }),
25
- type: "date",
26
- "aria-labelledby": labelId,
27
- readOnly: readOnly,
28
- disabled: disabled,
29
- value: value,
30
- onChange: onChange,
31
- min: min,
32
- max: max
33
- });
34
- }
35
- var _default = exports["default"] = DatepickerInput;
package/lib/env.d.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,3 +0,0 @@
1
- import { type PropsWithChildren } from 'react';
2
- declare function DatepickerContainer({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
3
- export default DatepickerContainer;
@@ -1,13 +0,0 @@
1
- import { type ChangeEventHandler } from 'react';
2
- export type Props = {
3
- labelId: string;
4
- id?: string;
5
- disabled?: boolean;
6
- readOnly?: boolean;
7
- value?: string;
8
- onChange?: ChangeEventHandler<HTMLInputElement>;
9
- min?: string;
10
- max?: string;
11
- };
12
- declare function DatepickerInput({ id, disabled, readOnly, labelId, value, onChange, min, max, }: Props): import("react/jsx-runtime").JSX.Element;
13
- export default DatepickerInput;
@@ -1,5 +0,0 @@
1
- /**
2
- * Extract the value associated with a component
3
- * If the component expect multiple values (it has a responses property) then extract a map of values
4
- */
5
- export declare function getComponentValue(component: unknown, valueMap: Record<string, unknown>, rowIndex?: number): unknown;
@@ -1 +0,0 @@
1
- export declare function getWorkerPath(): string;
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getComponentValue = getComponentValue;
7
- var _component = require("../use-lunatic/commons/component");
8
- /**
9
- * Extract the value associated with a component
10
- * If the component expect multiple values (it has a responses property) then extract a map of values
11
- */
12
- function getComponentValue(component, valueMap, rowIndex) {
13
- if ((0, _component.hasResponse)(component)) {
14
- var value = valueMap[component.response.name];
15
- if (Array.isArray(value)) {
16
- return value[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0];
17
- }
18
- return value;
19
- }
20
-
21
- // For checkbox group we need to send the map of values
22
- if ((0, _component.hasResponses)(component)) {
23
- var _component$responses$, _component$responses;
24
- return Object.fromEntries((_component$responses$ = (_component$responses = component.responses) === null || _component$responses === void 0 ? void 0 : _component$responses.map(function (_ref) {
25
- var response = _ref.response;
26
- var value = valueMap[response.name];
27
- if (Array.isArray(value)) {
28
- return [response.name, value[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0]];
29
- }
30
- return [response.name, value];
31
- })) !== null && _component$responses$ !== void 0 ? _component$responses$ : []);
32
- }
33
- return undefined;
34
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _getComponentValue = require("./get-component-value");
5
- (0, _vitest.describe)('getComponentValue', function () {
6
- var componentWithResponse = {
7
- response: {
8
- name: 'prenom'
9
- }
10
- };
11
- var componentWithResponses = {
12
- responses: [componentWithResponse, {
13
- response: {
14
- name: 'nom'
15
- }
16
- }]
17
- };
18
- (0, _vitest.it)('Should work with simple response', function () {
19
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {
20
- prenom: 'John'
21
- })).toBe('John');
22
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {})).toBe(undefined);
23
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)({}, {
24
- prenom: 'John'
25
- })).toBe(undefined);
26
- });
27
- (0, _vitest.it)('Should work with simple response as Array', function () {
28
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {
29
- prenom: ['John', 'Renaud']
30
- }, 1)).toBe('Renaud');
31
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponse, {
32
- prenom: ['John', 'Renaud']
33
- }, 3)).toBe(undefined);
34
- });
35
- (0, _vitest.it)('Should work with responses', function () {
36
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponses, {
37
- prenom: 'John'
38
- })).toMatchObject({
39
- prenom: 'John',
40
- nom: undefined
41
- });
42
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponses, {
43
- prenom: ['John', 'Renaud'],
44
- nom: ['Insee', 'Metallica']
45
- }, 1)).toMatchObject({
46
- prenom: 'Renaud',
47
- nom: 'Metallica'
48
- });
49
- (0, _vitest.expect)((0, _getComponentValue.getComponentValue)(componentWithResponses, {
50
- prenom: ['John', 'Renaud'],
51
- nom: 'Insee'
52
- }, 1)).toMatchObject({
53
- prenom: 'Renaud',
54
- nom: 'Insee'
55
- });
56
- });
57
- });
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWorkerPath = getWorkerPath;
7
- function getWorkerPath() {
8
- var _ref, _import$meta$env$LUNA;
9
- if ('LUNATIC_WORKER_PATH' in window) {
10
- return window.LUNATIC_WORKER_PATH;
11
- }
12
- return (_ref = (_import$meta$env$LUNA = import.meta.env.LUNATIC_LOADER_WORKER_PATH) !== null && _import$meta$env$LUNA !== void 0 ? _import$meta$env$LUNA : import.meta.env.REACT_APP_LUNATIC_LOADER_WORKER_PATH) !== null && _ref !== void 0 ? _ref : 'workers/lunatic-loader-worker-0.1.0.js';
13
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createWorker = void 0;
7
- var _logger = require("../logger");
8
- // Enable cross domain workers
9
-
10
- var testSameOrigin = function testSameOrigin(url) {
11
- var loc = window.location;
12
- var a = document.createElement('a');
13
- a.href = url;
14
- return a.hostname === loc.hostname && a.port === loc.port && a.protocol === loc.protocol;
15
- };
16
- var createWorkerFallback = function createWorkerFallback(workerUrl) {
17
- _logger.Logger.info('Create worker for MFE');
18
- var worker = null;
19
- try {
20
- var blob;
21
- try {
22
- blob = new Blob(["importScripts('".concat(workerUrl, "');")], {
23
- type: 'application/javascript'
24
- });
25
- } catch (e) {
26
- var blobBuilder = new (window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder)();
27
- blobBuilder.append("importScripts('".concat(workerUrl, "');"));
28
- blob = blobBuilder.getBlob('application/javascript');
29
- }
30
- var url = window.URL || window.webkitURL;
31
- var blobUrl = url.createObjectURL(blob);
32
- worker = new Worker(blobUrl);
33
- } catch (e1) {
34
- console.error("Lunatic-worker : Failed to load web worker : ".concat(workerUrl));
35
- }
36
- return worker;
37
- };
38
- var createWorker = exports.createWorker = function createWorker(workerUrl) {
39
- var worker = null;
40
- try {
41
- if (testSameOrigin(workerUrl)) {
42
- worker = new Worker(workerUrl);
43
- worker.onerror = function (event) {
44
- event.preventDefault();
45
- worker = createWorkerFallback(workerUrl);
46
- };
47
- } else {
48
- worker = createWorkerFallback(workerUrl);
49
- }
50
- } catch (e) {
51
- worker = createWorkerFallback(workerUrl);
52
- }
53
- return worker;
54
- };