skillet-shared 0.5.0 → 0.7.0

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/css/base.css ADDED
@@ -0,0 +1,35 @@
1
+ *,
2
+ *::before,
3
+ *::after {
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ @media (prefers-reduced-motion: reduce) {
8
+ *,
9
+ *::before,
10
+ *::after {
11
+ animation-duration: 0.01ms !important;
12
+ animation-iteration-count: 1 !important;
13
+ transition-duration: 0.01ms !important;
14
+ }
15
+ }
16
+
17
+ body {
18
+ margin: 0;
19
+ }
20
+
21
+ button,
22
+ select,
23
+ input,
24
+ textarea {
25
+ font-family: inherit;
26
+ }
27
+
28
+ :where(button:not(:disabled)) {
29
+ cursor: pointer;
30
+ }
31
+
32
+ :focus-visible {
33
+ outline: 2px solid var(--fg2);
34
+ outline-offset: 1px;
35
+ }
@@ -0,0 +1,3 @@
1
+ export declare const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2
+ export declare function toBase64Url(bytes: readonly number[]): string;
3
+ export declare function fromBase64Url(text: string): number[];
@@ -0,0 +1,34 @@
1
+ export const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
2
+ export function toBase64Url(bytes) {
3
+ let out = '';
4
+ for (let i = 0; i < bytes.length; i += 3) {
5
+ const n = ((bytes[i] ?? 0) << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);
6
+ const left = bytes.length - i;
7
+ out += (B64[(n >> 18) & 63] ?? '') + (B64[(n >> 12) & 63] ?? '');
8
+ if (left > 1)
9
+ out += B64[(n >> 6) & 63] ?? '';
10
+ if (left > 2)
11
+ out += B64[n & 63] ?? '';
12
+ }
13
+ return out;
14
+ }
15
+ // Reads '+' and '/' as themselves. The first character outside the alphabet
16
+ // ends the board: '=' from an encoder that pads, or whatever the link picked up
17
+ // on its way here, such as the full stop of the sentence it was pasted into.
18
+ export function fromBase64Url(text) {
19
+ const bytes = [];
20
+ let acc = 0;
21
+ let bits = 0;
22
+ for (const ch of text) {
23
+ const v = B64.indexOf(ch === '+' ? '-' : ch === '/' ? '_' : ch);
24
+ if (v < 0)
25
+ break;
26
+ acc = (acc << 6) | v;
27
+ bits += 6;
28
+ if (bits >= 8) {
29
+ bits -= 8;
30
+ bytes.push((acc >> bits) & 0xff);
31
+ }
32
+ }
33
+ return bytes;
34
+ }
@@ -0,0 +1,9 @@
1
+ export declare const FIREBASE_CONFIG: {
2
+ apiKey: string;
3
+ authDomain: string;
4
+ projectId: string;
5
+ storageBucket: string;
6
+ messagingSenderId: string;
7
+ appId: string;
8
+ measurementId: string;
9
+ };
@@ -0,0 +1,13 @@
1
+ // A Firebase web config is a set of public identifiers, not credentials: it
2
+ // ships in every Firebase web app's bundle. The Firestore rules stop a stranger
3
+ // writing, and the authorized-domains list stops one using the project as their
4
+ // own auth backend.
5
+ export const FIREBASE_CONFIG = {
6
+ apiKey: 'AIzaSyBHZnQdnaDc5BEYbqwKO8zs0t_wyzLaGFo',
7
+ authDomain: 'ntscjs-d4f56.firebaseapp.com',
8
+ projectId: 'ntscjs-d4f56',
9
+ storageBucket: 'ntscjs-d4f56.firebasestorage.app',
10
+ messagingSenderId: '881016589781',
11
+ appId: '1:881016589781:web:9eabd469a30d89b6d7815c',
12
+ measurementId: 'G-ZFH59EM495',
13
+ };
@@ -0,0 +1,12 @@
1
+ export declare const SETTLE_MS = 5000;
2
+ export declare const MIN_GAP_MS = 10000;
3
+ export interface WriteGate {
4
+ query: string | null;
5
+ at: number;
6
+ }
7
+ export declare function nextWriteAt(gate: WriteGate, query: string, now: number): number | null;
8
+ export interface Opened {
9
+ query: string | null;
10
+ moved: boolean;
11
+ }
12
+ export declare function observe(opened: Opened, query: string | null): Opened;
@@ -0,0 +1,20 @@
1
+ export const SETTLE_MS = 5000;
2
+ export const MIN_GAP_MS = 10000;
3
+ // When a newly settled board may be written, or null when the account already
4
+ // has it. The debounce measures from now and the rate limit from the last write
5
+ // that landed, and the later of the two wins.
6
+ export function nextWriteAt(gate, query, now) {
7
+ if (query === gate.query)
8
+ return null;
9
+ return Math.max(now + SETTLE_MS, gate.at + MIN_GAP_MS);
10
+ }
11
+ // The first board a page shows is where it opened: the stock board from the
12
+ // home page's app button, or a finished one from a demo or a shared link. The
13
+ // session starts when the board first differs from it.
14
+ export function observe(opened, query) {
15
+ if (query === null || opened.moved)
16
+ return opened;
17
+ if (opened.query === null)
18
+ return { query, moved: false };
19
+ return query === opened.query ? opened : { ...opened, moved: true };
20
+ }
package/dist/tokens.css CHANGED
@@ -62,4 +62,9 @@
62
62
  /* A control's corner, and a pill's at any height. */
63
63
  --ctl-radius: 3px;
64
64
  --pill-radius: 999px;
65
+
66
+ --shadow-modal: 0 10px 30px #000b;
67
+ --shadow-pop: 0 8px 28px #000a;
68
+ --scrim: #000a;
69
+ --caps-track: 0.04em;
65
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillet-shared",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Code shared by bender and videoskillet",
5
5
  "license": "MIT",
6
6
  "author": "Colin Diesh",
@@ -40,6 +40,7 @@
40
40
  "./components/Footer.astro": "./components/Footer.astro",
41
41
  "./components/SocialMeta.astro": "./components/SocialMeta.astro",
42
42
  "./components/SignedInHint.astro": "./components/SignedInHint.astro",
43
+ "./base.css": "./css/base.css",
43
44
  "./site.css": "./css/site.css",
44
45
  "./footer.css": "./css/footer.css",
45
46
  "./saved-list": {
@@ -49,6 +50,18 @@
49
50
  "./cloud": {
50
51
  "types": "./dist/cloud.d.ts",
51
52
  "default": "./dist/cloud.js"
53
+ },
54
+ "./base64url": {
55
+ "types": "./dist/base64url.d.ts",
56
+ "default": "./dist/base64url.js"
57
+ },
58
+ "./session-gate": {
59
+ "types": "./dist/session-gate.d.ts",
60
+ "default": "./dist/session-gate.js"
61
+ },
62
+ "./firebase-config": {
63
+ "types": "./dist/firebase-config.d.ts",
64
+ "default": "./dist/firebase-config.js"
52
65
  }
53
66
  },
54
67
  "files": [