proto-sudoku-wc 0.0.689 → 0.0.691

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 (38) hide show
  1. package/dist/cjs/{index-4683daff.js → index-af8bf740.js} +15 -4
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/proto-sudoku-wc.cjs.js +2 -2
  4. package/dist/cjs/proto-sudoku.cjs.entry.js +352 -352
  5. package/dist/collection/collection-manifest.json +1 -1
  6. package/dist/collection/components/proto-sudoku/alert.js +2 -2
  7. package/dist/collection/components/proto-sudoku/alerts.js +3 -3
  8. package/dist/collection/components/proto-sudoku/alien.js +5 -5
  9. package/dist/collection/components/proto-sudoku/button.js +10 -10
  10. package/dist/collection/components/proto-sudoku/cell.js +20 -20
  11. package/dist/collection/components/proto-sudoku/eswat2-io.js +1 -1
  12. package/dist/collection/components/proto-sudoku/fingerprint.js +5 -5
  13. package/dist/collection/components/proto-sudoku/header.js +1 -1
  14. package/dist/collection/components/proto-sudoku/keys.js +10 -10
  15. package/dist/collection/components/proto-sudoku/proto-sudoku.js +62 -62
  16. package/dist/collection/components/proto-sudoku/spinner.js +5 -5
  17. package/dist/collection/components/proto-sudoku/sudoku-board.js +6 -6
  18. package/dist/collection/components/proto-sudoku/tool-bar.js +8 -8
  19. package/dist/collection/components/proto-sudoku/tw-label.js +1 -1
  20. package/dist/collection/utils/bag.js +23 -23
  21. package/dist/collection/utils/store.js +209 -209
  22. package/dist/collection/utils/tw.js +1 -1
  23. package/dist/esm/{index-3ccc3f4a.js → index-e105e4de.js} +15 -4
  24. package/dist/esm/loader.js +2 -2
  25. package/dist/esm/proto-sudoku-wc.js +3 -3
  26. package/dist/esm/proto-sudoku.entry.js +352 -352
  27. package/dist/proto-sudoku-wc/{p-4ab7e5a2.js → p-5c418b3c.js} +1 -1
  28. package/dist/proto-sudoku-wc/{p-4a14cce4.entry.js → p-c8bb72eb.entry.js} +1 -1
  29. package/dist/proto-sudoku-wc/proto-sudoku-wc.esm.js +1 -1
  30. package/dist/types/components/proto-sudoku/alert.d.ts +3 -3
  31. package/dist/types/components/proto-sudoku/button.d.ts +3 -3
  32. package/dist/types/components/proto-sudoku/cell.d.ts +4 -4
  33. package/dist/types/components/proto-sudoku/proto-sudoku.d.ts +4 -4
  34. package/dist/types/stencil-public-runtime.d.ts +8 -0
  35. package/dist/types/utils/bag.d.ts +10 -10
  36. package/dist/types/utils/store.d.ts +5 -5
  37. package/dist/types/utils/types.d.ts +33 -33
  38. package/package.json +5 -5
@@ -3,279 +3,279 @@ import ky from "ky";
3
3
  import { bag } from "./bag";
4
4
  // --------------------------------------------------------[ mutable store ]
5
5
  const storeDef = {
6
- list: [],
7
- keys: [],
8
- locs: [],
9
- loading: false,
10
- solved: false,
11
- error: undefined,
12
- pick: undefined,
13
- data: undefined,
6
+ list: [],
7
+ keys: [],
8
+ locs: [],
9
+ loading: false,
10
+ solved: false,
11
+ error: undefined,
12
+ pick: undefined,
13
+ data: undefined,
14
14
  };
15
15
  const { state } = createStore(storeDef);
16
16
  // --------------------------------------------------------[ geometry ]
17
17
  // NOTE: by using Sets here, we don't have to worry about clearing geometry...
18
18
  const geometry = new Map([
19
- ['row', new Map()],
20
- ['column', new Map()],
21
- ['box', new Map()],
19
+ ['row', new Map()],
20
+ ['column', new Map()],
21
+ ['box', new Map()],
22
22
  ]);
23
23
  const keyValues = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
24
24
  const computeBox = (row, column) => {
25
- if (column < 3) {
26
- return row < 3 ? 0 : row < 6 ? 3 : 6;
27
- }
28
- else {
29
- if (column < 6) {
30
- return row < 3 ? 1 : row < 6 ? 4 : 7;
25
+ if (column < 3) {
26
+ return row < 3 ? 0 : row < 6 ? 3 : 6;
31
27
  }
32
28
  else {
33
- return row < 3 ? 2 : row < 6 ? 5 : 8;
29
+ if (column < 6) {
30
+ return row < 3 ? 1 : row < 6 ? 4 : 7;
31
+ }
32
+ else {
33
+ return row < 3 ? 2 : row < 6 ? 5 : 8;
34
+ }
34
35
  }
35
- }
36
36
  };
37
37
  const computeLocs = (index, row, column, box) => {
38
- const data = new Map([
39
- ['row', row],
40
- ['column', column],
41
- ['box', box],
42
- ]);
43
- const locs = new Set();
44
- data.forEach((value, key) => {
45
- geometry
46
- .get(key)
47
- .get(value)
48
- .forEach(indx => {
49
- indx !== index && locs.add(indx);
38
+ const data = new Map([
39
+ ['row', row],
40
+ ['column', column],
41
+ ['box', box],
42
+ ]);
43
+ const locs = new Set();
44
+ data.forEach((value, key) => {
45
+ geometry
46
+ .get(key)
47
+ .get(value)
48
+ .forEach(indx => {
49
+ indx !== index && locs.add(indx);
50
+ });
50
51
  });
51
- });
52
- return Array.from(locs);
52
+ return Array.from(locs);
53
53
  };
54
54
  const computeKeys = locs => {
55
- const { list } = state;
56
- const found = new Set();
57
- locs.map(indx => {
58
- const { key } = list[indx];
59
- if (key != '.') {
60
- found.add(key);
61
- }
62
- });
63
- const keys = keyValues.filter(key => !found.has(key));
64
- return keys;
55
+ const { list } = state;
56
+ const found = new Set();
57
+ locs.map(indx => {
58
+ const { key } = list[indx];
59
+ if (key != '.') {
60
+ found.add(key);
61
+ }
62
+ });
63
+ const keys = keyValues.filter(key => !found.has(key));
64
+ return keys;
65
65
  };
66
66
  const updateGeometry = (index, row, column, box) => {
67
- const data = new Map([
68
- ['row', row],
69
- ['column', column],
70
- ['box', box],
71
- ]);
72
- data.forEach((value, key) => {
73
- const map = geometry.get(key);
74
- if (map.has(value)) {
75
- // looking at the set specification, it should be sufficient to just call add
76
- // https://tc39.es/ecma262/#sec-set.prototype.add
77
- map.get(value).add(index);
78
- }
79
- else {
80
- map.set(value, new Set([index]));
81
- }
82
- });
67
+ const data = new Map([
68
+ ['row', row],
69
+ ['column', column],
70
+ ['box', box],
71
+ ]);
72
+ data.forEach((value, key) => {
73
+ const map = geometry.get(key);
74
+ if (map.has(value)) {
75
+ // looking at the set specification, it should be sufficient to just call add
76
+ // https://tc39.es/ecma262/#sec-set.prototype.add
77
+ map.get(value).add(index);
78
+ }
79
+ else {
80
+ map.set(value, new Set([index]));
81
+ }
82
+ });
83
83
  };
84
84
  const updateFromInputs = list => {
85
- const inputs = bag.inputs.get();
86
- inputs.forEach((key, indx) => {
87
- const cell = list[indx];
88
- const { isClue } = cell;
89
- if (!isClue) {
90
- cell.key = key;
91
- }
92
- });
85
+ const inputs = bag.inputs.get();
86
+ inputs.forEach((key, indx) => {
87
+ const cell = list[indx];
88
+ const { isClue } = cell;
89
+ if (!isClue) {
90
+ cell.key = key;
91
+ }
92
+ });
93
93
  };
94
94
  // --------------------------------------------------------[ process ]
95
95
  const processData = (next) => {
96
- if (next) {
97
- const { puzzle, ref } = next;
98
- const cells = puzzle ? [...puzzle] : [];
99
- const line = ref ? atob(ref) : undefined; // decrypt the solution... [ base64 ]
100
- const solution = line ? [...line] : [];
101
- const list = cells.map((key, indx) => {
102
- const value = solution[indx];
103
- const isClue = key === value;
104
- const row = Math.floor(indx / 9);
105
- const column = indx % 9;
106
- const box = computeBox(row, column);
107
- updateGeometry(indx, row, column, box);
108
- return { key, isClue, value, indx, row, column, box };
109
- });
110
- // NOTE: this only happens once on data change...
111
- updateFromInputs(list);
112
- state.data = next;
113
- state.list = list;
114
- }
115
- else {
116
- state.data = undefined;
117
- state.list = [];
118
- }
96
+ if (next) {
97
+ const { puzzle, ref } = next;
98
+ const cells = puzzle ? [...puzzle] : [];
99
+ const line = ref ? atob(ref) : undefined; // decrypt the solution... [ base64 ]
100
+ const solution = line ? [...line] : [];
101
+ const list = cells.map((key, indx) => {
102
+ const value = solution[indx];
103
+ const isClue = key === value;
104
+ const row = Math.floor(indx / 9);
105
+ const column = indx % 9;
106
+ const box = computeBox(row, column);
107
+ updateGeometry(indx, row, column, box);
108
+ return { key, isClue, value, indx, row, column, box };
109
+ });
110
+ // NOTE: this only happens once on data change...
111
+ updateFromInputs(list);
112
+ state.data = next;
113
+ state.list = list;
114
+ }
115
+ else {
116
+ state.data = undefined;
117
+ state.list = [];
118
+ }
119
119
  };
120
120
  const processPick = (next) => {
121
- if (next !== undefined && next.indx != state.pick) {
122
- const { isClue, indx, row, column, box } = next;
123
- const locs = computeLocs(indx, row, column, box);
124
- const keys = isClue ? [] : computeKeys(locs);
125
- state.pick = indx;
126
- state.keys = keys;
127
- state.locs = locs;
128
- // NOTE: we could auto-pick if there's only one key...
129
- // (keys.length === 1) && next.key = keys[0];
130
- }
131
- else {
132
- state.pick = undefined;
133
- state.keys = [];
134
- state.locs = [];
135
- }
136
- savePick(state.pick);
121
+ if (next !== undefined && next.indx != state.pick) {
122
+ const { isClue, indx, row, column, box } = next;
123
+ const locs = computeLocs(indx, row, column, box);
124
+ const keys = isClue ? [] : computeKeys(locs);
125
+ state.pick = indx;
126
+ state.keys = keys;
127
+ state.locs = locs;
128
+ // NOTE: we could auto-pick if there's only one key...
129
+ // (keys.length === 1) && next.key = keys[0];
130
+ }
131
+ else {
132
+ state.pick = undefined;
133
+ state.keys = [];
134
+ state.locs = [];
135
+ }
136
+ savePick(state.pick);
137
137
  };
138
138
  // --------------------------------------------------------[ utils ]
139
139
  let api = undefined;
140
140
  const platformPrefix = {
141
- netlify: '/.netlify/functions',
142
- vercel: 'https://sudoku-rust-api.vercel.app/api',
141
+ netlify: '/.netlify/functions',
142
+ vercel: 'https://sudoku-rust-api.vercel.app/api',
143
143
  };
144
144
  const getPrefixFor = (platform) => {
145
- const keys = Object.keys(platformPrefix);
146
- const target = keys.includes(platform) ? platform : 'vercel';
147
- return platformPrefix[target];
145
+ const keys = Object.keys(platformPrefix);
146
+ const target = keys.includes(platform) ? platform : 'vercel';
147
+ return platformPrefix[target];
148
148
  };
149
149
  const initApi = (platform) => {
150
- const prefix = getPrefixFor(platform);
151
- api = ky.extend({
152
- hooks: {
153
- beforeRequest: [
154
- request => {
155
- request.headers.set('X-Requested-With', 'ky');
156
- request.headers.set('X-Custom-Header', 'foobar');
150
+ const prefix = getPrefixFor(platform);
151
+ api = ky.extend({
152
+ hooks: {
153
+ beforeRequest: [
154
+ request => {
155
+ request.headers.set('X-Requested-With', 'ky');
156
+ request.headers.set('X-Custom-Header', 'foobar');
157
+ },
158
+ ],
157
159
  },
158
- ],
159
- },
160
- prefixUrl: prefix,
161
- timeout: 10000,
162
- });
160
+ prefixUrl: prefix,
161
+ timeout: 10000,
162
+ });
163
163
  };
164
164
  const saveInputs = (inputs) => {
165
- bag.inputs.store(inputs);
165
+ bag.inputs.store(inputs);
166
166
  };
167
167
  const savePick = (pick) => {
168
- bag.pick.store(pick);
168
+ bag.pick.store(pick);
169
169
  };
170
170
  const clearStore = (loading = false) => {
171
- state.list = [];
172
- state.keys = [];
173
- state.locs = [];
174
- state.loading = loading;
175
- state.solved = false;
176
- state.error = undefined;
177
- state.pick = undefined;
178
- state.data = undefined;
171
+ state.list = [];
172
+ state.keys = [];
173
+ state.locs = [];
174
+ state.loading = loading;
175
+ state.solved = false;
176
+ state.error = undefined;
177
+ state.pick = undefined;
178
+ state.data = undefined;
179
179
  };
180
180
  const updateStore = (data, save = true) => {
181
- const { puzzle, ref } = data;
182
- if (save) {
183
- bag.inputs.store([]);
184
- bag.store(data);
185
- }
186
- processData({ puzzle, ref });
181
+ const { puzzle, ref } = data;
182
+ if (save) {
183
+ bag.inputs.store([]);
184
+ bag.store(data);
185
+ }
186
+ processData({ puzzle, ref });
187
187
  };
188
188
  // --------------------------------------------------------[ actions ]
189
189
  const initApp = (platform) => {
190
- initApi(platform);
191
- clearStore();
192
- // this retrieves the last data we stored in the bag...
193
- const data = bag.get();
194
- const pick = bag.pick.get();
195
- if (data) {
196
- updateStore(data, false);
197
- if (pick >= 0) {
198
- const { list } = state;
199
- const cell = list[pick];
200
- processPick(cell);
190
+ initApi(platform);
191
+ clearStore();
192
+ // this retrieves the last data we stored in the bag...
193
+ const data = bag.get();
194
+ const pick = bag.pick.get();
195
+ if (data) {
196
+ updateStore(data, false);
197
+ if (pick >= 0) {
198
+ const { list } = state;
199
+ const cell = list[pick];
200
+ processPick(cell);
201
+ }
201
202
  }
202
- }
203
203
  };
204
204
  const refresh = async () => {
205
- clearStore(true);
206
- saveInputs([]);
207
- savePick(state.pick);
208
- try {
209
- // fetch a new puzzle from the api...
210
- const data = await api.get('puzzle').json();
211
- updateStore(data);
212
- }
213
- catch (err) {
214
- // handle error...
215
- const { message } = err;
216
- console.log('-- ', message);
217
- console.log(err);
218
- state.error = message;
219
- }
220
- finally {
221
- // always executed
222
- state.loading = false;
223
- }
205
+ clearStore(true);
206
+ saveInputs([]);
207
+ savePick(state.pick);
208
+ try {
209
+ // fetch a new puzzle from the api...
210
+ const data = await api.get('puzzle').json();
211
+ updateStore(data);
212
+ }
213
+ catch (err) {
214
+ // handle error...
215
+ const { message } = err;
216
+ console.log('-- ', message);
217
+ console.log(err);
218
+ state.error = message;
219
+ }
220
+ finally {
221
+ // always executed
222
+ state.loading = false;
223
+ }
224
224
  };
225
225
  const select = (cell) => {
226
- processPick(cell);
226
+ processPick(cell);
227
227
  };
228
228
  const redraw = (list) => {
229
- state.list = [...list];
230
- list.length = 0;
229
+ state.list = [...list];
230
+ list.length = 0;
231
231
  };
232
232
  const check = () => {
233
- const { list } = state;
234
- const inputs = [];
235
- let errors = 0;
236
- let found = 0;
237
- let clues = 0;
238
- list.forEach(cell => {
239
- const { key, value, isClue } = cell;
240
- if (!isClue) {
241
- if (key !== '.') {
242
- if (key !== value) {
243
- errors = errors + 1;
244
- cell.key = '.';
233
+ const { list } = state;
234
+ const inputs = [];
235
+ let errors = 0;
236
+ let found = 0;
237
+ let clues = 0;
238
+ list.forEach(cell => {
239
+ const { key, value, isClue } = cell;
240
+ if (!isClue) {
241
+ if (key !== '.') {
242
+ if (key !== value) {
243
+ errors = errors + 1;
244
+ cell.key = '.';
245
+ }
246
+ else {
247
+ found = found + 1;
248
+ }
249
+ }
245
250
  }
246
251
  else {
247
- found = found + 1;
252
+ clues = clues + 1;
248
253
  }
249
- }
254
+ inputs.push(cell.key);
255
+ });
256
+ const total = clues + found;
257
+ found ? saveInputs(inputs) : saveInputs([]);
258
+ if (errors > 0) {
259
+ redraw(list);
250
260
  }
251
261
  else {
252
- clues = clues + 1;
253
- }
254
- inputs.push(cell.key);
255
- });
256
- const total = clues + found;
257
- found ? saveInputs(inputs) : saveInputs([]);
258
- if (errors > 0) {
259
- redraw(list);
260
- }
261
- else {
262
- if (total === 81) {
263
- state.solved = true;
262
+ if (total === 81) {
263
+ state.solved = true;
264
+ }
264
265
  }
265
- }
266
266
  };
267
267
  const input = (key) => {
268
- const { pick, list } = state;
269
- const cell = list[pick];
270
- cell.key = key;
271
- redraw(list);
268
+ const { pick, list } = state;
269
+ const cell = list[pick];
270
+ cell.key = key;
271
+ redraw(list);
272
272
  };
273
273
  const actions = {
274
- initApp,
275
- refresh,
276
- select,
277
- check,
278
- input,
274
+ initApp,
275
+ refresh,
276
+ select,
277
+ check,
278
+ input,
279
279
  };
280
280
  export { state, actions };
281
281
  export default state;
@@ -1,5 +1,5 @@
1
1
  const tw = (...classes) => {
2
- return classes.filter(Boolean).join(' ');
2
+ return classes.filter(Boolean).join(' ');
3
3
  };
4
4
  export { tw };
5
5
  export default tw;
@@ -446,7 +446,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
446
446
  elm[memberName] = newValue;
447
447
  }
448
448
  }
449
- catch (e) { }
449
+ catch (e) {
450
+ /**
451
+ * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
452
+ */
453
+ }
450
454
  }
451
455
  if (newValue == null || newValue === false) {
452
456
  if (newValue !== false || elm.getAttribute(memberName) === '') {
@@ -465,6 +469,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
465
469
  }
466
470
  };
467
471
  const parseClassListRegex = /\s/;
472
+ /**
473
+ * Parsed a string of classnames into an array
474
+ * @param value className string, e.g. "foo bar baz"
475
+ * @returns list of classes, e.g. ["foo", "bar", "baz"]
476
+ */
468
477
  const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
469
478
  const CAPTURE_EVENT_SUFFIX = 'Capture';
470
479
  const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
@@ -1204,10 +1213,10 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1204
1213
  */
1205
1214
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1206
1215
  var _a;
1216
+ const prototype = Cstr.prototype;
1207
1217
  if (cmpMeta.$members$) {
1208
1218
  // It's better to have a const than two Object.entries()
1209
1219
  const members = Object.entries(cmpMeta.$members$);
1210
- const prototype = Cstr.prototype;
1211
1220
  members.map(([memberName, [memberFlags]]) => {
1212
1221
  if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1213
1222
  ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
@@ -1230,6 +1239,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1230
1239
  const attrNameToPropName = new Map();
1231
1240
  prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1232
1241
  plt.jmp(() => {
1242
+ var _a;
1233
1243
  const propName = attrNameToPropName.get(attrName);
1234
1244
  // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1235
1245
  // in the case where an attribute was set inline.
@@ -1285,11 +1295,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1285
1295
  // 1. The instance is ready
1286
1296
  // 2. The watchers are ready
1287
1297
  // 3. The value has changed
1288
- if (!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1298
+ if (flags &&
1299
+ !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1289
1300
  flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1290
1301
  newValue !== oldValue) {
1291
1302
  const instance = hostRef.$lazyInstance$ ;
1292
- const entry = cmpMeta.$watchers$[attrName];
1303
+ const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1293
1304
  entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1294
1305
  if (instance[callbackName] != null) {
1295
1306
  instance[callbackName].call(instance, newValue, oldValue, attrName);
@@ -1,5 +1,5 @@
1
- import { b as bootstrapLazy } from './index-3ccc3f4a.js';
2
- export { s as setNonce } from './index-3ccc3f4a.js';
1
+ import { b as bootstrapLazy } from './index-e105e4de.js';
2
+ export { s as setNonce } from './index-e105e4de.js';
3
3
 
4
4
  const defineCustomElements = (win, options) => {
5
5
  if (typeof window === 'undefined') return undefined;
@@ -1,8 +1,8 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-3ccc3f4a.js';
2
- export { s as setNonce } from './index-3ccc3f4a.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-e105e4de.js';
2
+ export { s as setNonce } from './index-e105e4de.js';
3
3
 
4
4
  /*
5
- Stencil Client Patch Browser v4.7.2 | MIT Licensed | https://stenciljs.com
5
+ Stencil Client Patch Browser v4.8.0 | MIT Licensed | https://stenciljs.com
6
6
  */
7
7
  const patchBrowser = () => {
8
8
  const importMeta = import.meta.url;