proto-sudoku-wc 0.0.485 → 0.0.487
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/dist/cjs/proto-sudoku.cjs.entry.js +472 -2921
- package/dist/collection/utils/store.js +22 -16
- package/dist/esm/proto-sudoku.entry.js +472 -2921
- package/dist/proto-sudoku-wc/p-ebff75e1.entry.js +2 -0
- package/dist/proto-sudoku-wc/proto-sudoku-wc.esm.js +1 -1
- package/dist/types/utils/store.d.ts +1 -1
- package/package.json +4 -4
- package/dist/proto-sudoku-wc/p-5fac1fa8.entry.js +0 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createStore } from '@stencil/store';
|
2
|
-
import
|
2
|
+
import ky from 'ky';
|
3
3
|
import { bag } from './bag';
|
4
4
|
// --------------------------------------------------------[ mutable store ]
|
5
5
|
const storeDef = {
|
@@ -136,10 +136,17 @@ const processPick = (next) => {
|
|
136
136
|
savePick(state.pick);
|
137
137
|
};
|
138
138
|
// --------------------------------------------------------[ utils ]
|
139
|
-
const api =
|
140
|
-
|
139
|
+
const api = ky.extend({
|
140
|
+
hooks: {
|
141
|
+
beforeRequest: [
|
142
|
+
request => {
|
143
|
+
request.headers.set('X-Requested-With', 'ky');
|
144
|
+
request.headers.set('X-Custom-Header', 'foobar');
|
145
|
+
},
|
146
|
+
],
|
147
|
+
},
|
148
|
+
prefixUrl: 'https://sudoku-rust-api.vercel.app/api',
|
141
149
|
timeout: 10000,
|
142
|
-
headers: { 'X-Custom-Header': 'foobar' },
|
143
150
|
});
|
144
151
|
const saveInputs = (inputs) => {
|
145
152
|
bag.inputs.store(inputs);
|
@@ -180,27 +187,26 @@ const initApp = () => {
|
|
180
187
|
}
|
181
188
|
}
|
182
189
|
};
|
183
|
-
const refresh = () => {
|
190
|
+
const refresh = async () => {
|
184
191
|
clearStore(true);
|
185
192
|
saveInputs([]);
|
186
193
|
savePick(state.pick);
|
187
|
-
|
188
|
-
|
189
|
-
.get('
|
190
|
-
.then(({ data }) => {
|
194
|
+
try {
|
195
|
+
// fetch a new puzzle from the api...
|
196
|
+
const data = await api.get('puzzle').json();
|
191
197
|
updateStore(data);
|
192
|
-
}
|
193
|
-
|
198
|
+
}
|
199
|
+
catch (err) {
|
194
200
|
// handle error...
|
195
|
-
const { message } =
|
201
|
+
const { message } = err;
|
196
202
|
console.log('-- ', message);
|
197
|
-
console.log(
|
203
|
+
console.log(err);
|
198
204
|
state.error = message;
|
199
|
-
}
|
200
|
-
|
205
|
+
}
|
206
|
+
finally {
|
201
207
|
// always executed
|
202
208
|
state.loading = false;
|
203
|
-
}
|
209
|
+
}
|
204
210
|
};
|
205
211
|
const select = (cell) => {
|
206
212
|
processPick(cell);
|