@elice/material-exercise 1.260514.1 → 1.260515.1

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 (37) hide show
  1. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialog.d.ts +10 -0
  2. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialog.js +213 -0
  3. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialogNativeMock.d.ts +3 -0
  4. package/cjs/components/material-exercise/exercise-runner/arduino/{ArduinoConnectionGuideDialogNativeMock.js → ArduinoConnectionPreflightDialogNativeMock.js} +5 -5
  5. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialogSteps.d.ts +3 -0
  6. package/cjs/components/material-exercise/exercise-runner/arduino/{ArduinoConnectionGuideDialogSteps.js → ArduinoConnectionPreflightDialogSteps.js} +5 -5
  7. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoControllerActionUpload.js +18 -20
  8. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoControllerStatusMessage.js +6 -15
  9. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoProvider.js +102 -19
  10. package/cjs/components/material-exercise/exercise-runner/arduino/_context.d.ts +6 -4
  11. package/cjs/components/material-exercise/exercise-runner/locales/en.json.js +1 -1
  12. package/cjs/components/material-exercise/exercise-runner/locales/ja.json.js +1 -1
  13. package/cjs/components/material-exercise/exercise-runner/locales/ko.json.js +1 -1
  14. package/cjs/components/material-exercise/exercise-runner/locales/th.json.js +1 -1
  15. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialog.d.ts +10 -0
  16. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialog.js +194 -0
  17. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialogNativeMock.d.ts +3 -0
  18. package/es/components/material-exercise/exercise-runner/arduino/{ArduinoConnectionGuideDialogNativeMock.js → ArduinoConnectionPreflightDialogNativeMock.js} +5 -5
  19. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionPreflightDialogSteps.d.ts +3 -0
  20. package/es/components/material-exercise/exercise-runner/arduino/{ArduinoConnectionGuideDialogSteps.js → ArduinoConnectionPreflightDialogSteps.js} +5 -5
  21. package/es/components/material-exercise/exercise-runner/arduino/ArduinoControllerActionUpload.js +18 -20
  22. package/es/components/material-exercise/exercise-runner/arduino/ArduinoControllerStatusMessage.js +6 -15
  23. package/es/components/material-exercise/exercise-runner/arduino/ArduinoProvider.js +104 -21
  24. package/es/components/material-exercise/exercise-runner/arduino/_context.d.ts +6 -4
  25. package/es/components/material-exercise/exercise-runner/locales/en.json.js +1 -1
  26. package/es/components/material-exercise/exercise-runner/locales/ja.json.js +1 -1
  27. package/es/components/material-exercise/exercise-runner/locales/ko.json.js +1 -1
  28. package/es/components/material-exercise/exercise-runner/locales/th.json.js +1 -1
  29. package/package.json +7 -5
  30. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialog.d.ts +0 -3
  31. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialog.js +0 -156
  32. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialogNativeMock.d.ts +0 -3
  33. package/cjs/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialogSteps.d.ts +0 -3
  34. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialog.d.ts +0 -3
  35. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialog.js +0 -141
  36. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialogNativeMock.d.ts +0 -3
  37. package/es/components/material-exercise/exercise-runner/arduino/ArduinoConnectionGuideDialogSteps.d.ts +0 -3
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { DialogProps } from '@mui/material';
3
+ import type { ArduinoConnectionIntent } from './_context';
4
+ interface ArduinoConnectionPreflightDialogProps extends DialogProps {
5
+ intent: ArduinoConnectionIntent;
6
+ onConfirm: () => void;
7
+ onSaveDontShowAgain?: () => void;
8
+ }
9
+ declare const ArduinoConnectionPreflightDialog: React.FC<ArduinoConnectionPreflightDialogProps>;
10
+ export default ArduinoConnectionPreflightDialog;
@@ -0,0 +1,213 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
8
+ var intl = require('@elice/intl');
9
+ var ArrowUpwardIcon = require('@mui/icons-material/ArrowUpward');
10
+ var Alert = require('@mui/material/Alert');
11
+ var Button = require('@mui/material/Button');
12
+ var Checkbox = require('@mui/material/Checkbox');
13
+ var Dialog = require('@mui/material/Dialog');
14
+ var DialogActions = require('@mui/material/DialogActions');
15
+ var DialogContent = require('@mui/material/DialogContent');
16
+ var DialogTitle = require('@mui/material/DialogTitle');
17
+ var FormControlLabel = require('@mui/material/FormControlLabel');
18
+ var Stack = require('@mui/material/Stack');
19
+ var Typography = require('@mui/material/Typography');
20
+ var ArduinoConnectionPreflightDialogNativeMock = require('./ArduinoConnectionPreflightDialogNativeMock.js');
21
+ var ArduinoConnectionPreflightDialogSteps = require('./ArduinoConnectionPreflightDialogSteps.js');
22
+
23
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
24
+
25
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
26
+ var ArrowUpwardIcon__default = /*#__PURE__*/_interopDefaultCompat(ArrowUpwardIcon);
27
+ var Alert__default = /*#__PURE__*/_interopDefaultCompat(Alert);
28
+ var Button__default = /*#__PURE__*/_interopDefaultCompat(Button);
29
+ var Checkbox__default = /*#__PURE__*/_interopDefaultCompat(Checkbox);
30
+ var Dialog__default = /*#__PURE__*/_interopDefaultCompat(Dialog);
31
+ var DialogActions__default = /*#__PURE__*/_interopDefaultCompat(DialogActions);
32
+ var DialogContent__default = /*#__PURE__*/_interopDefaultCompat(DialogContent);
33
+ var DialogTitle__default = /*#__PURE__*/_interopDefaultCompat(DialogTitle);
34
+ var FormControlLabel__default = /*#__PURE__*/_interopDefaultCompat(FormControlLabel);
35
+ var Stack__default = /*#__PURE__*/_interopDefaultCompat(Stack);
36
+ var Typography__default = /*#__PURE__*/_interopDefaultCompat(Typography);
37
+
38
+ //
39
+ //
40
+ //
41
+ var ArduinoConnectionPreflightDialog = function ArduinoConnectionPreflightDialog(_ref) {
42
+ var open = _ref.open,
43
+ intent = _ref.intent,
44
+ onConfirm = _ref.onConfirm,
45
+ onSaveDontShowAgain = _ref.onSaveDontShowAgain,
46
+ onClose = _ref.onClose,
47
+ onTransitionExited = _ref.onTransitionExited;
48
+ var intl$1 = intl.useRawEliceIntl();
49
+ var _React$useState = React__default.default.useState(false),
50
+ _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
51
+ dontShowAgain = _React$useState2[0],
52
+ setDontShowAgain = _React$useState2[1];
53
+ var isUpload = intent === 'upload';
54
+ /**
55
+ *
56
+ */
57
+ var handleCancelClick = function handleCancelClick(e) {
58
+ onClose === null || onClose === void 0 ? void 0 : onClose(e, 'escapeKeyDown');
59
+ };
60
+ /**
61
+ *
62
+ */
63
+ var handleConfirmClick = function handleConfirmClick() {
64
+ if (dontShowAgain) {
65
+ onSaveDontShowAgain === null || onSaveDontShowAgain === void 0 ? void 0 : onSaveDontShowAgain();
66
+ }
67
+ onConfirm();
68
+ };
69
+ /**
70
+ *
71
+ */
72
+ var renderTitle = function renderTitle() {
73
+ return intl$1.formatMessage({
74
+ id: isUpload ? 'exerciseRunner.arduino.preflight.title.upload' : 'exerciseRunner.arduino.preflight.title.connect'
75
+ });
76
+ };
77
+ /**
78
+ *
79
+ */
80
+ var renderUploadNotice = function renderUploadNotice() {
81
+ if (!isUpload) {
82
+ return null;
83
+ }
84
+ return jsxRuntime.jsx(Alert__default.default, {
85
+ severity: "info",
86
+ children: intl$1.formatMessage({
87
+ id: 'exerciseRunner.arduino.preflight.upload.note'
88
+ })
89
+ });
90
+ };
91
+ /**
92
+ *
93
+ */
94
+ var renderPreview = function renderPreview() {
95
+ return jsxRuntime.jsxs(Stack__default.default, {
96
+ alignItems: "center",
97
+ spacing: 1.25,
98
+ sx: {
99
+ bgcolor: function bgcolor(theme) {
100
+ return theme.palette.background.paper;
101
+ },
102
+ border: function border(theme) {
103
+ return "1px solid ".concat(theme.palette.divider);
104
+ },
105
+ borderRadius: '10px',
106
+ p: '14px'
107
+ },
108
+ children: [jsxRuntime.jsxs(Stack__default.default, {
109
+ direction: "row",
110
+ spacing: 0.75,
111
+ alignItems: "center",
112
+ children: [jsxRuntime.jsx(ArrowUpwardIcon__default.default, {
113
+ sx: {
114
+ fontSize: 11
115
+ }
116
+ }), jsxRuntime.jsx(Typography__default.default, {
117
+ color: "primary.main",
118
+ sx: {
119
+ fontSize: 12,
120
+ fontWeight: 700,
121
+ letterSpacing: '-.01em'
122
+ },
123
+ children: intl$1.formatMessage({
124
+ id: 'exerciseRunner.arduino.preflight.preview.label'
125
+ })
126
+ })]
127
+ }), jsxRuntime.jsx(ArduinoConnectionPreflightDialogNativeMock.default, {})]
128
+ });
129
+ };
130
+ /**
131
+ *
132
+ */
133
+ var renderActionsDontShowAgain = function renderActionsDontShowAgain() {
134
+ return jsxRuntime.jsx(FormControlLabel__default.default, {
135
+ control: jsxRuntime.jsx(Checkbox__default.default, {
136
+ size: "small",
137
+ checked: dontShowAgain,
138
+ onChange: function onChange(e) {
139
+ return setDontShowAgain(e.target.checked);
140
+ }
141
+ }),
142
+ label: intl$1.formatMessage({
143
+ id: 'exerciseRunner.arduino.help.dontShowAgain'
144
+ })
145
+ });
146
+ };
147
+ /**
148
+ *
149
+ */
150
+ var renderActionsButtons = function renderActionsButtons() {
151
+ return jsxRuntime.jsxs(Stack__default.default, {
152
+ direction: "row",
153
+ spacing: 1,
154
+ children: [jsxRuntime.jsx(Button__default.default, {
155
+ color: "inherit",
156
+ onClick: handleCancelClick,
157
+ children: intl$1.formatMessage({
158
+ id: 'exerciseRunner.arduino.preflight.action.cancel'
159
+ })
160
+ }), jsxRuntime.jsx(Button__default.default, {
161
+ variant: "contained",
162
+ onClick: handleConfirmClick,
163
+ children: intl$1.formatMessage({
164
+ id: 'exerciseRunner.arduino.preflight.action.confirm'
165
+ })
166
+ })]
167
+ });
168
+ };
169
+ //
170
+ //
171
+ //
172
+ return jsxRuntime.jsxs(Dialog__default.default, {
173
+ fullWidth: true,
174
+ maxWidth: "sm",
175
+ open: open,
176
+ PaperProps: {
177
+ sx: {
178
+ maxHeight: 'calc(100vh - 32px)'
179
+ }
180
+ },
181
+ onClose: onClose,
182
+ onTransitionExited: onTransitionExited,
183
+ children: [jsxRuntime.jsx(DialogTitle__default.default, {
184
+ children: renderTitle()
185
+ }), jsxRuntime.jsx(DialogContent__default.default, {
186
+ children: jsxRuntime.jsxs(Stack__default.default, {
187
+ spacing: 2,
188
+ children: [renderUploadNotice(), jsxRuntime.jsx(Typography__default.default, {
189
+ variant: "body2",
190
+ color: "text.secondary",
191
+ children: intl$1.formatMessage({
192
+ id: 'exerciseRunner.arduino.preflight.body'
193
+ })
194
+ }), renderPreview(), jsxRuntime.jsx(ArduinoConnectionPreflightDialogSteps.default, {}), jsxRuntime.jsx(Typography__default.default, {
195
+ variant: "caption",
196
+ color: "text.secondary",
197
+ children: intl$1.formatMessage({
198
+ id: 'exerciseRunner.arduino.preflight.footer'
199
+ })
200
+ })]
201
+ })
202
+ }), jsxRuntime.jsxs(DialogActions__default.default, {
203
+ sx: {
204
+ justifyContent: 'space-between',
205
+ px: 3,
206
+ py: 2
207
+ },
208
+ children: [renderActionsDontShowAgain(), renderActionsButtons()]
209
+ })]
210
+ });
211
+ };
212
+
213
+ exports.default = ArduinoConnectionPreflightDialog;
@@ -0,0 +1,3 @@
1
+ import type React from 'react';
2
+ declare const ArduinoConnectionPreflightDialogNativeMock: React.VFC;
3
+ export default ArduinoConnectionPreflightDialogNativeMock;
@@ -37,7 +37,7 @@ var SYSTEM_FONT = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-s
37
37
  //
38
38
  //
39
39
  //
40
- var ArduinoConnectionGuideDialogNativeMock = function ArduinoConnectionGuideDialogNativeMock() {
40
+ var ArduinoConnectionPreflightDialogNativeMock = function ArduinoConnectionPreflightDialogNativeMock() {
41
41
  var intl$1 = intl.useRawEliceIntl();
42
42
  /**
43
43
  *
@@ -67,7 +67,7 @@ var ArduinoConnectionGuideDialogNativeMock = function ArduinoConnectionGuideDial
67
67
  color: MOCK_TEXT
68
68
  },
69
69
  children: intl$1.formatMessage({
70
- id: 'exerciseRunner.arduino.connectGuide.preview.host'
70
+ id: 'exerciseRunner.arduino.preflight.preview.host'
71
71
  }, {
72
72
  host: window.location.host
73
73
  })
@@ -153,7 +153,7 @@ var ArduinoConnectionGuideDialogNativeMock = function ArduinoConnectionGuideDial
153
153
  bgcolor: 'transparent'
154
154
  }),
155
155
  children: intl$1.formatMessage({
156
- id: 'exerciseRunner.arduino.connectGuide.preview.cancel'
156
+ id: 'exerciseRunner.arduino.preflight.preview.cancel'
157
157
  })
158
158
  }), jsxRuntime.jsx(Box__default.default, {
159
159
  sx: Object.assign(Object.assign({}, btnBaseSx), {
@@ -162,7 +162,7 @@ var ArduinoConnectionGuideDialogNativeMock = function ArduinoConnectionGuideDial
162
162
  color: MOCK_BTN_PRIMARY_TEXT
163
163
  }),
164
164
  children: intl$1.formatMessage({
165
- id: 'exerciseRunner.arduino.connectGuide.preview.connect'
165
+ id: 'exerciseRunner.arduino.preflight.preview.connect'
166
166
  })
167
167
  })]
168
168
  });
@@ -185,4 +185,4 @@ var ArduinoConnectionGuideDialogNativeMock = function ArduinoConnectionGuideDial
185
185
  });
186
186
  };
187
187
 
188
- exports.default = ArduinoConnectionGuideDialogNativeMock;
188
+ exports.default = ArduinoConnectionPreflightDialogNativeMock;
@@ -0,0 +1,3 @@
1
+ import type React from 'react';
2
+ declare const ArduinoConnectionPreflightDialogSteps: React.VFC;
3
+ export default ArduinoConnectionPreflightDialogSteps;
@@ -21,7 +21,7 @@ var STEP_KEYS = [1, 2, 3];
21
21
  //
22
22
  //
23
23
  //
24
- var ArduinoConnectionGuideDialogSteps = function ArduinoConnectionGuideDialogSteps() {
24
+ var ArduinoConnectionPreflightDialogSteps = function ArduinoConnectionPreflightDialogSteps() {
25
25
  var intl$1 = intl.useRawEliceIntl();
26
26
  /**
27
27
  *
@@ -104,15 +104,15 @@ var ArduinoConnectionGuideDialogSteps = function ArduinoConnectionGuideDialogSte
104
104
  whiteSpace: 'pre-line'
105
105
  },
106
106
  children: intl$1.formatMessage({
107
- id: "exerciseRunner.arduino.connectGuide.steps.".concat(step)
107
+ id: "exerciseRunner.arduino.preflight.steps.".concat(step)
108
108
  }, {
109
109
  usbmodem: renderInlineCode('usbmodem'),
110
110
  usbserial: renderInlineCode('usbserial'),
111
111
  connect: renderStrong(intl$1.formatMessage({
112
- id: 'exerciseRunner.arduino.connectGuide.preview.connect'
112
+ id: 'exerciseRunner.arduino.preflight.preview.connect'
113
113
  })),
114
114
  cancel: renderStrong(intl$1.formatMessage({
115
- id: 'exerciseRunner.arduino.connectGuide.preview.cancel'
115
+ id: 'exerciseRunner.arduino.preflight.preview.cancel'
116
116
  }))
117
117
  })
118
118
  })]
@@ -129,4 +129,4 @@ var ArduinoConnectionGuideDialogSteps = function ArduinoConnectionGuideDialogSte
129
129
  });
130
130
  };
131
131
 
132
- exports.default = ArduinoConnectionGuideDialogSteps;
132
+ exports.default = ArduinoConnectionPreflightDialogSteps;
@@ -26,22 +26,22 @@ var ArduinoControllerActionUpload = function ArduinoControllerActionUpload() {
26
26
  isDisabled = _useControllerActionR.isDisabled,
27
27
  run = _useControllerActionR.run;
28
28
  var _useConnection = mcuBridge.useConnection(),
29
- status = _useConnection.status,
30
- connect = _useConnection.connect;
29
+ status = _useConnection.status;
31
30
  var isBrowserSupported = mcuBridge.useIsBrowserSupported();
32
31
  var _useArduinoBridge = _context.useArduinoBridge(),
33
32
  setPendingIntent = _useArduinoBridge.setPendingIntent,
34
33
  isPending = _useArduinoBridge.isPending,
35
34
  isFlashing = _useArduinoBridge.isFlashing,
36
- setConnectionIntent = _useArduinoBridge.setConnectionIntent;
35
+ openConnectionPreflight = _useArduinoBridge.openConnectionPreflight;
37
36
  var isUploadDisabled = isDisabled || isPending || isFlashing || !isBrowserSupported;
38
37
  var isUploadLoading = isPending || isFlashing;
39
38
  /**
40
39
  * Submit the Arduino sketch, then flash the compiled firmware to the board.
41
40
  */
42
41
  var upload = React__default.default.useCallback(/*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
42
+ var granted;
43
43
  return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
44
- while (1) switch (_context.p = _context.n) {
44
+ while (1) switch (_context.n) {
45
45
  case 0:
46
46
  if (!isUploadDisabled) {
47
47
  _context.n = 1;
@@ -50,29 +50,27 @@ var ArduinoControllerActionUpload = function ArduinoControllerActionUpload() {
50
50
  return _context.a(2);
51
51
  case 1:
52
52
  if (!(status !== 'connected')) {
53
- _context.n = 5;
53
+ _context.n = 3;
54
+ break;
55
+ }
56
+ _context.n = 2;
57
+ return openConnectionPreflight('upload');
58
+ case 2:
59
+ granted = _context.v;
60
+ if (granted) {
61
+ _context.n = 3;
54
62
  break;
55
63
  }
56
- setConnectionIntent('upload');
57
- _context.p = 2;
58
- _context.n = 3;
59
- return connect();
60
- case 3:
61
- _context.n = 5;
62
- break;
63
- case 4:
64
- _context.p = 4;
65
- _context.v;
66
64
  return _context.a(2);
67
- case 5:
65
+ case 3:
68
66
  setPendingIntent('upload');
69
- _context.n = 6;
67
+ _context.n = 4;
70
68
  return run();
71
- case 6:
69
+ case 4:
72
70
  return _context.a(2);
73
71
  }
74
- }, _callee, null, [[2, 4]]);
75
- })), [isUploadDisabled, status, connect, setConnectionIntent, setPendingIntent, run]);
72
+ }, _callee);
73
+ })), [isUploadDisabled, status, openConnectionPreflight, setPendingIntent, run]);
76
74
  //
77
75
  //
78
76
  //
@@ -48,12 +48,11 @@ var ArduinoControllerStatusMessage = function ArduinoControllerStatusMessage() {
48
48
  var intl$1 = intl.useRawEliceIntl();
49
49
  var _useConnection = mcuBridge.useConnection(),
50
50
  status = _useConnection.status,
51
- connect = _useConnection.connect,
52
51
  disconnect = _useConnection.disconnect;
53
52
  var session = mcuBridge.useSession();
54
53
  var _useArduinoBridge = _context.useArduinoBridge(),
55
54
  isFlashing = _useArduinoBridge.isFlashing,
56
- setConnectionIntent = _useArduinoBridge.setConnectionIntent;
55
+ openConnectionPreflight = _useArduinoBridge.openConnectionPreflight;
57
56
  var isBrowserSupported = mcuBridge.useIsBrowserSupported();
58
57
  var deviceName = (_a = session === null || session === void 0 ? void 0 : session.driver.board.name) !== null && _a !== void 0 ? _a : null;
59
58
  var isConnected = status === 'connected';
@@ -64,7 +63,7 @@ var ArduinoControllerStatusMessage = function ArduinoControllerStatusMessage() {
64
63
  var handleClick = /*#__PURE__*/function () {
65
64
  var _ref = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
66
65
  return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
67
- while (1) switch (_context.p = _context.n) {
66
+ while (1) switch (_context.n) {
68
67
  case 0:
69
68
  if (!isConnected) {
70
69
  _context.n = 2;
@@ -75,20 +74,12 @@ var ArduinoControllerStatusMessage = function ArduinoControllerStatusMessage() {
75
74
  case 1:
76
75
  return _context.a(2);
77
76
  case 2:
78
- setConnectionIntent('connect');
79
- _context.p = 3;
80
- _context.n = 4;
81
- return connect();
82
- case 4:
83
- _context.n = 6;
84
- break;
85
- case 5:
86
- _context.p = 5;
87
- _context.v;
88
- case 6:
77
+ _context.n = 3;
78
+ return openConnectionPreflight('connect');
79
+ case 3:
89
80
  return _context.a(2);
90
81
  }
91
- }, _callee, null, [[3, 5]]);
82
+ }, _callee);
92
83
  }));
93
84
  return function handleClick() {
94
85
  return _ref.apply(this, arguments);
@@ -6,9 +6,11 @@ var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabel
6
6
  var tslib = require('tslib');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
  var React = require('react');
9
+ var intl = require('@elice/intl');
9
10
  var mcuBridge = require('@elice/mcu-bridge');
11
+ var overlayKit = require('overlay-kit');
10
12
  var _context = require('./_context.js');
11
- var ArduinoConnectionGuideDialog = require('./ArduinoConnectionGuideDialog.js');
13
+ var ArduinoConnectionPreflightDialog = require('./ArduinoConnectionPreflightDialog.js');
12
14
  var ArduinoErrorDialog = require('./ArduinoErrorDialog.js');
13
15
  var ArduinoHelpDialog = require('./ArduinoHelpDialog.js');
14
16
  var ArduinoProviderApiBinder = require('./ArduinoProviderApiBinder.js');
@@ -20,6 +22,11 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
20
22
 
21
23
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
22
24
 
25
+ //
26
+ //
27
+ //
28
+ var PREFLIGHT_DISMISS_KEY = 'elice-material-exercise-arduino-preflight-dialog-dont-show-again';
29
+ var PREFLIGHT_DISMISS_VALUE = 'true';
23
30
  //
24
31
  //
25
32
  //
@@ -27,38 +34,115 @@ var ArduinoBridgeProvider = function ArduinoBridgeProvider(_ref) {
27
34
  var xtermRef = _ref.xtermRef,
28
35
  apiRef = _ref.apiRef,
29
36
  children = _ref.children;
37
+ var intl$1 = intl.useRawEliceIntl();
30
38
  var _useFlash = mcuBridge.useFlash(),
31
39
  isFlashing = _useFlash.isFlashing;
40
+ var _useConnection = mcuBridge.useConnection(),
41
+ connect = _useConnection.connect;
32
42
  var _useArduinoRunIntent = useArduinoRunIntent.useArduinoRunIntent(),
33
43
  pendingIntent = _useArduinoRunIntent.pendingIntent,
34
44
  pendingIntentRef = _useArduinoRunIntent.pendingIntentRef,
35
45
  setRunIntent = _useArduinoRunIntent.setRunIntent,
36
46
  clearRunIntent = _useArduinoRunIntent.clearRunIntent;
37
- var permissionPhase = mcuBridge.usePermissionPhase();
38
- var _React$useState = React__default.default.useState(null),
47
+ var connectRef = React__default.default.useRef(connect);
48
+ connectRef.current = connect;
49
+ var _React$useState = React__default.default.useState(false),
39
50
  _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
40
- connectionIntent = _React$useState2[0],
41
- setConnectionIntent = _React$useState2[1];
42
- var _React$useState3 = React__default.default.useState(false),
43
- _React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
44
- isHelpDialogOpen = _React$useState4[0],
45
- setHelpDialogOpen = _React$useState4[1];
51
+ isHelpDialogOpen = _React$useState2[0],
52
+ setHelpDialogOpen = _React$useState2[1];
53
+ /**
54
+ *
55
+ */
46
56
  var openHelpDialog = React__default.default.useCallback(function () {
47
57
  return setHelpDialogOpen(true);
48
58
  }, []);
59
+ /**
60
+ *
61
+ */
49
62
  var closeHelpDialog = React__default.default.useCallback(function () {
50
63
  return setHelpDialogOpen(false);
51
64
  }, []);
65
+ /**
66
+ *
67
+ */
68
+ var openConnectionPreflight = React__default.default.useCallback(/*#__PURE__*/function () {
69
+ var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2(intent) {
70
+ var runConnect, confirmed;
71
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
72
+ while (1) switch (_context2.n) {
73
+ case 0:
74
+ runConnect = /*#__PURE__*/function () {
75
+ var _ref3 = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
76
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
77
+ while (1) switch (_context.p = _context.n) {
78
+ case 0:
79
+ _context.p = 0;
80
+ _context.n = 1;
81
+ return connectRef.current();
82
+ case 1:
83
+ return _context.a(2, true);
84
+ case 2:
85
+ _context.p = 2;
86
+ _context.v;
87
+ return _context.a(2, false);
88
+ }
89
+ }, _callee, null, [[0, 2]]);
90
+ }));
91
+ return function runConnect() {
92
+ return _ref3.apply(this, arguments);
93
+ };
94
+ }();
95
+ if (!(sessionStorage.getItem(PREFLIGHT_DISMISS_KEY) === PREFLIGHT_DISMISS_VALUE)) {
96
+ _context2.n = 1;
97
+ break;
98
+ }
99
+ return _context2.a(2, runConnect());
100
+ case 1:
101
+ _context2.n = 2;
102
+ return overlayKit.overlay.openAsync(function (_ref4) {
103
+ var isOpen = _ref4.isOpen,
104
+ close = _ref4.close,
105
+ unmount = _ref4.unmount;
106
+ return jsxRuntime.jsx(intl.RawEliceIntlProvider, {
107
+ value: intl$1,
108
+ children: jsxRuntime.jsx(ArduinoConnectionPreflightDialog.default, {
109
+ open: isOpen,
110
+ intent: intent,
111
+ onClose: function onClose() {
112
+ return close(false);
113
+ },
114
+ onConfirm: function onConfirm() {
115
+ return close(true);
116
+ },
117
+ onTransitionExited: unmount,
118
+ onSaveDontShowAgain: function onSaveDontShowAgain() {
119
+ sessionStorage.setItem(PREFLIGHT_DISMISS_KEY, PREFLIGHT_DISMISS_VALUE);
120
+ }
121
+ })
122
+ });
123
+ });
124
+ case 2:
125
+ confirmed = _context2.v;
126
+ if (confirmed) {
127
+ _context2.n = 3;
128
+ break;
129
+ }
130
+ return _context2.a(2, false);
131
+ case 3:
132
+ return _context2.a(2, runConnect());
133
+ }
134
+ }, _callee2);
135
+ }));
136
+ return function (_x) {
137
+ return _ref2.apply(this, arguments);
138
+ };
139
+ }(), [intl$1]);
140
+ //
141
+ // setup the MCU Bridge once on mount
142
+ //
52
143
  React.useEffect(function () {
53
144
  mcuBridge.setupMCUBridge([mcuBridge.ArduinoUnoDriver, mcuBridge.ArduinoMegaDriver]);
54
145
  }, []);
55
- // Clear the variant tag once the picker resolves so it can't bleed into
56
- // an unrelated future connect flow.
57
- React.useEffect(function () {
58
- if (permissionPhase === 'granted') {
59
- setConnectionIntent(null);
60
- }
61
- }, [permissionPhase]);
62
146
  //
63
147
  //
64
148
  //
@@ -67,8 +151,7 @@ var ArduinoBridgeProvider = function ArduinoBridgeProvider(_ref) {
67
151
  setPendingIntent: setRunIntent,
68
152
  isPending: pendingIntent !== null,
69
153
  isFlashing: isFlashing,
70
- connectionIntent: connectionIntent,
71
- setConnectionIntent: setConnectionIntent,
154
+ openConnectionPreflight: openConnectionPreflight,
72
155
  isHelpDialogOpen: isHelpDialogOpen,
73
156
  openHelpDialog: openHelpDialog,
74
157
  closeHelpDialog: closeHelpDialog
@@ -82,7 +165,7 @@ var ArduinoBridgeProvider = function ArduinoBridgeProvider(_ref) {
82
165
  xtermRef: xtermRef,
83
166
  pendingIntentRef: pendingIntentRef,
84
167
  clearRunIntent: clearRunIntent
85
- }), jsxRuntime.jsx(ArduinoConnectionGuideDialog.default, {}), jsxRuntime.jsx(ArduinoHelpDialog.default, {}), jsxRuntime.jsx(ArduinoErrorDialog.default, {})]
168
+ }), jsxRuntime.jsx(ArduinoHelpDialog.default, {}), jsxRuntime.jsx(ArduinoErrorDialog.default, {})]
86
169
  });
87
170
  };
88
171
  //
@@ -16,11 +16,13 @@ interface ArduinoBridgeContextValue {
16
16
  /** Readback for the button group to know when a flash is in flight. */
17
17
  isFlashing: boolean;
18
18
  /**
19
- * Picks the connection-guide dialog's copy variant. The guide's open state
20
- * is derived from `permissionStore.phase`; this only chooses the wording.
19
+ * Show the preflight guide dialog, then trigger the native port picker after
20
+ * the student confirms. Resolves `true` once the picker grants a port,
21
+ * `false` if the student cancels or the picker fails. When the
22
+ * "don't show again" flag is set in sessionStorage, the dialog is skipped
23
+ * and the picker fires immediately.
21
24
  */
22
- connectionIntent: ArduinoConnectionIntent | null;
23
- setConnectionIntent: (intent: ArduinoConnectionIntent | null) => void;
25
+ openConnectionPreflight: (intent: ArduinoConnectionIntent) => Promise<boolean>;
24
26
  /**
25
27
  * Help dialog opened by the controller-area help button (and auto-opened
26
28
  * once on first visit). Only the open flag lives here — the dialog owns
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var messageEn = {"exerciseRunner.arduino.error.close":"Close","exerciseRunner.arduino.error.title":"Arduino connection error","exerciseRunner.arduino.help.button":"Help","exerciseRunner.arduino.help.title":"🤖 Welcome to the Arduino Lab!","exerciseRunner.arduino.help.greeting":"Write code in here to make a real Arduino board do things. Follow the steps below in order.","exerciseRunner.arduino.help.checklist.1.title":"Plug your Arduino board into the computer","exerciseRunner.arduino.help.checklist.1.body":"Connect the board with a USB cable, then click the [Connect] button next to the menu.","exerciseRunner.arduino.help.checklist.2.title":"Write code and press [Verify]","exerciseRunner.arduino.help.checklist.2.body":"Verify checks your code for problems before sending it.","exerciseRunner.arduino.help.checklist.3.title":"Press [Upload] to send it to the board","exerciseRunner.arduino.help.checklist.3.body":"Your program is sent to the Arduino board. Watch the serial window below for the results.","exerciseRunner.arduino.help.checklist.4.title":"If it works, press [Submit]!","exerciseRunner.arduino.help.checklist.4.body":"Submitting grades your code automatically and shows your score.","exerciseRunner.arduino.help.manual.title":"Need a usage guide?","exerciseRunner.arduino.help.manual.detail":"See the official manual for usage details.","exerciseRunner.arduino.help.dontShowAgain":"Don't show again","exerciseRunner.arduino.help.close":"Close","exerciseRunner.arduino.connectGuide.body":"For security, the browser shows the board picker directly. Find the small window under the address bar at the top-left of the screen and pick your Arduino board.","exerciseRunner.arduino.connectGuide.footer":"Don't see the window? Check the lock icon next to the address bar.","exerciseRunner.arduino.connectGuide.preview.cancel":"Cancel","exerciseRunner.arduino.connectGuide.preview.connect":"Connect","exerciseRunner.arduino.connectGuide.preview.host":"{host} wants to connect to a serial port","exerciseRunner.arduino.connectGuide.preview.label":"It will look like this","exerciseRunner.arduino.connectGuide.steps.1":"Click the entry whose name starts with {usbmodem} or {usbserial}.","exerciseRunner.arduino.connectGuide.steps.2":"Press the {connect} button at the bottom right to connect.","exerciseRunner.arduino.connectGuide.steps.3":"If you click {cancel} by mistake, you can try again.","exerciseRunner.arduino.connectGuide.title.connect":"Select your board in the browser","exerciseRunner.arduino.connectGuide.title.upload":"Let's connect the board first","exerciseRunner.arduino.connectGuide.upload.note":"Connecting the board is required to upload. Once connected, the upload will start automatically.","exerciseRunner.arduino.terminal.board.notConnected":"/* Arduino is not connected. Please connect and try again. */\n","exerciseRunner.arduino.terminal.compile.done":"/* Compile complete. */\n","exerciseRunner.arduino.terminal.firmware.readFail":"/* Failed to read the firmware file. */\n","exerciseRunner.arduino.terminal.session.connected":"/* [connected] {device} */\n","exerciseRunner.arduino.terminal.session.disconnected":"/* [disconnected] */\n","exerciseRunner.arduino.terminal.session.reconnected":"/* [reconnected] {device} */\n","exerciseRunner.arduino.terminal.upload.done":"/* Upload complete. */\n","exerciseRunner.arduino.terminal.upload.error":"/* Error: {error} */\n","exerciseRunner.arduino.terminal.upload.errorUnknown":"Unknown","exerciseRunner.arduino.terminal.upload.progress":"/* Uploading... ({percent}%) */\r","exerciseRunner.arduino.terminal.upload.start":"/* Starting upload. */\n","exerciseRunner.arduino.terminal.upload.verifying":"/* Verifying... */\n","exerciseRunner.controller.arduino.boardStatus.connected":"{device} connected","exerciseRunner.controller.arduino.boardStatus.connectedNoName":"Board connected","exerciseRunner.controller.arduino.boardStatus.disconnected":"Disconnected","exerciseRunner.controller.arduino.boardStatus.idle":"Arduino board not connected","exerciseRunner.controller.arduino.boardStatus.reconnecting":"Reconnecting","exerciseRunner.controller.arduino.button.compile":"Compile","exerciseRunner.controller.arduino.button.connect":"Connect","exerciseRunner.controller.arduino.button.disconnect":"Disconnect","exerciseRunner.controller.arduino.button.upload":"Upload","exerciseRunner.controller.arduino.button.verify":"Verify","exerciseRunner.controller.buttonGroup.button.helpRequest":"Ask about the dragged code","exerciseRunner.controller.buttonGroup.button.run":"Run","exerciseRunner.controller.buttonGroup.button.stop":"Stop","exerciseRunner.controller.buttonGroup.button.submit":"Submit","exerciseRunner.controller.buttonGroup.button.submit.tooltip.noSubmit":"Exercise without submission","exerciseRunner.controller.buttonGroup.button.syncRequest":"Sync code","exerciseRunner.controller.runningInfo.error.fetch":"An error occurred while fetching running info","exerciseRunner.controller.runningInfo.lastRunningDatetime":"Last running datetime","exerciseRunner.controller.runningInfo.lastSubmitDatetime":"Last submit datetime","exerciseRunner.controller.runningInfo.lastSubmitScore":"Last submit score","exerciseRunner.controller.runningInfo.score":"{score}","exerciseRunner.controller.statusMessage.closed":"Editor disconnected","exerciseRunner.controller.statusMessage.connecting":"Connecting to editor...","exerciseRunner.controller.statusMessage.open":"Editor connected","exerciseRunner.controller.timer.runningRemainingTime":"Remaining: {remainingTime}","exerciseRunner.controller.tooltip.closed":"The connection to the code server is currently unstable, so your edits may not be saved.\nPlease check your network and try again.","exerciseRunner.submitErrorDialog.action.confirm":"OK","exerciseRunner.submitErrorDialog.action.reload":"Reload page","exerciseRunner.submitErrorDialog.body.commonError":"An error occurred while running the code.\nPlease refresh and try again.","exerciseRunner.submitErrorDialog.body.exceedSubmitGradeLimit":"You have exceeded the allowed number of lab submissions.","exerciseRunner.submitErrorDialog.body.expiredExerciseImage":"The exercise image has been updated.\nPlease refresh and try again.","exerciseRunner.submitErrorDialog.body.networkError":"An error occurred while running the code.\nPlease refresh and try again.\nIf the problem persists, please check the network status.","exerciseRunner.submitErrorDialog.body.notForSubmitGrade":"This exercise is not allowed to be submitted.","exerciseRunner.submitErrorDialog.body.notPreparedRoom":"The exercise room is being prepared.\nPlease try again later.","exerciseRunner.submitErrorDialog.body.roomIsBusy":"The exercise room is running.\nPlease wait a moment.","exerciseRunner.submitErrorDialog.body.unknown":"An error occurred while running the code.\nPlease try again later.","exerciseRunner.submitErrorDialog.title":"Unable to run the code"};
5
+ var messageEn = {"exerciseRunner.arduino.error.close":"Close","exerciseRunner.arduino.error.title":"Arduino connection error","exerciseRunner.arduino.help.button":"Help","exerciseRunner.arduino.help.title":"🤖 Welcome to the Arduino Lab!","exerciseRunner.arduino.help.greeting":"Write code in here to make a real Arduino board do things. Follow the steps below in order.","exerciseRunner.arduino.help.checklist.1.title":"Plug your Arduino board into the computer","exerciseRunner.arduino.help.checklist.1.body":"Connect the board with a USB cable, then click the [Connect] button next to the menu.","exerciseRunner.arduino.help.checklist.2.title":"Write code and press [Verify]","exerciseRunner.arduino.help.checklist.2.body":"Verify checks your code for problems before sending it.","exerciseRunner.arduino.help.checklist.3.title":"Press [Upload] to send it to the board","exerciseRunner.arduino.help.checklist.3.body":"Your program is sent to the Arduino board. Watch the serial window below for the results.","exerciseRunner.arduino.help.checklist.4.title":"If it works, press [Submit]!","exerciseRunner.arduino.help.checklist.4.body":"Submitting grades your code automatically and shows your score.","exerciseRunner.arduino.help.manual.title":"Need a usage guide?","exerciseRunner.arduino.help.manual.detail":"See the official manual for usage details.","exerciseRunner.arduino.help.dontShowAgain":"Don't show again","exerciseRunner.arduino.help.close":"Close","exerciseRunner.arduino.preflight.action.cancel":"Cancel","exerciseRunner.arduino.preflight.action.confirm":"Connect","exerciseRunner.arduino.preflight.body":"For security, the browser shows the board picker directly. Find the small window under the address bar at the top-left of the screen and pick your Arduino board.","exerciseRunner.arduino.preflight.footer":"Don't see the window? Check the lock icon next to the address bar.","exerciseRunner.arduino.preflight.preview.cancel":"Cancel","exerciseRunner.arduino.preflight.preview.connect":"Connect","exerciseRunner.arduino.preflight.preview.host":"{host} wants to connect to a serial port","exerciseRunner.arduino.preflight.preview.label":"It will look like this","exerciseRunner.arduino.preflight.steps.1":"Click the entry whose name starts with {usbmodem} or {usbserial}.","exerciseRunner.arduino.preflight.steps.2":"Press the {connect} button at the bottom right to connect.","exerciseRunner.arduino.preflight.steps.3":"If you click {cancel} by mistake, you can try again.","exerciseRunner.arduino.preflight.title.connect":"Select your board in the browser","exerciseRunner.arduino.preflight.title.upload":"Let's connect the board first","exerciseRunner.arduino.preflight.upload.note":"Connecting the board is required to upload. Once connected, the upload will start automatically.","exerciseRunner.arduino.terminal.board.notConnected":"/* Arduino is not connected. Please connect and try again. */\n","exerciseRunner.arduino.terminal.compile.done":"/* Compile complete. */\n","exerciseRunner.arduino.terminal.firmware.readFail":"/* Failed to read the firmware file. */\n","exerciseRunner.arduino.terminal.session.connected":"/* [connected] {device} */\n","exerciseRunner.arduino.terminal.session.disconnected":"/* [disconnected] */\n","exerciseRunner.arduino.terminal.session.reconnected":"/* [reconnected] {device} */\n","exerciseRunner.arduino.terminal.upload.done":"/* Upload complete. */\n","exerciseRunner.arduino.terminal.upload.error":"/* Error: {error} */\n","exerciseRunner.arduino.terminal.upload.errorUnknown":"Unknown","exerciseRunner.arduino.terminal.upload.progress":"/* Uploading... ({percent}%) */\r","exerciseRunner.arduino.terminal.upload.start":"/* Starting upload. */\n","exerciseRunner.arduino.terminal.upload.verifying":"/* Verifying... */\n","exerciseRunner.controller.arduino.boardStatus.connected":"{device} connected","exerciseRunner.controller.arduino.boardStatus.connectedNoName":"Board connected","exerciseRunner.controller.arduino.boardStatus.disconnected":"Disconnected","exerciseRunner.controller.arduino.boardStatus.idle":"Arduino board not connected","exerciseRunner.controller.arduino.boardStatus.reconnecting":"Reconnecting","exerciseRunner.controller.arduino.button.compile":"Compile","exerciseRunner.controller.arduino.button.connect":"Connect","exerciseRunner.controller.arduino.button.disconnect":"Disconnect","exerciseRunner.controller.arduino.button.upload":"Upload","exerciseRunner.controller.arduino.button.verify":"Verify","exerciseRunner.controller.buttonGroup.button.helpRequest":"Ask about the dragged code","exerciseRunner.controller.buttonGroup.button.run":"Run","exerciseRunner.controller.buttonGroup.button.stop":"Stop","exerciseRunner.controller.buttonGroup.button.submit":"Submit","exerciseRunner.controller.buttonGroup.button.submit.tooltip.noSubmit":"Exercise without submission","exerciseRunner.controller.buttonGroup.button.syncRequest":"Sync code","exerciseRunner.controller.runningInfo.error.fetch":"An error occurred while fetching running info","exerciseRunner.controller.runningInfo.lastRunningDatetime":"Last running datetime","exerciseRunner.controller.runningInfo.lastSubmitDatetime":"Last submit datetime","exerciseRunner.controller.runningInfo.lastSubmitScore":"Last submit score","exerciseRunner.controller.runningInfo.score":"{score}","exerciseRunner.controller.statusMessage.closed":"Editor disconnected","exerciseRunner.controller.statusMessage.connecting":"Connecting to editor...","exerciseRunner.controller.statusMessage.open":"Editor connected","exerciseRunner.controller.timer.runningRemainingTime":"Remaining: {remainingTime}","exerciseRunner.controller.tooltip.closed":"The connection to the code server is currently unstable, so your edits may not be saved.\nPlease check your network and try again.","exerciseRunner.submitErrorDialog.action.confirm":"OK","exerciseRunner.submitErrorDialog.action.reload":"Reload page","exerciseRunner.submitErrorDialog.body.commonError":"An error occurred while running the code.\nPlease refresh and try again.","exerciseRunner.submitErrorDialog.body.exceedSubmitGradeLimit":"You have exceeded the allowed number of lab submissions.","exerciseRunner.submitErrorDialog.body.expiredExerciseImage":"The exercise image has been updated.\nPlease refresh and try again.","exerciseRunner.submitErrorDialog.body.networkError":"An error occurred while running the code.\nPlease refresh and try again.\nIf the problem persists, please check the network status.","exerciseRunner.submitErrorDialog.body.notForSubmitGrade":"This exercise is not allowed to be submitted.","exerciseRunner.submitErrorDialog.body.notPreparedRoom":"The exercise room is being prepared.\nPlease try again later.","exerciseRunner.submitErrorDialog.body.roomIsBusy":"The exercise room is running.\nPlease wait a moment.","exerciseRunner.submitErrorDialog.body.unknown":"An error occurred while running the code.\nPlease try again later.","exerciseRunner.submitErrorDialog.title":"Unable to run the code"};
6
6
 
7
7
  exports.default = messageEn;