@satanwagen/reviewkit 0.1.2 → 0.1.4

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 (56) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +158 -64
  3. package/dist/activate.cjs +150 -0
  4. package/dist/activate.cjs.map +1 -0
  5. package/dist/activate.d.cts +59 -0
  6. package/dist/activate.d.ts +59 -0
  7. package/dist/activate.js +21 -0
  8. package/dist/activate.js.map +1 -0
  9. package/dist/{chunk-YWBFAV57.js → chunk-5MAFDRUI.js} +1161 -1555
  10. package/dist/chunk-5MAFDRUI.js.map +1 -0
  11. package/dist/{chunk-4YNLMSCK.js → chunk-DG6O5XIC.js} +36 -10
  12. package/dist/chunk-DG6O5XIC.js.map +1 -0
  13. package/dist/chunk-EOX3UJNP.js +36 -0
  14. package/dist/chunk-EOX3UJNP.js.map +1 -0
  15. package/dist/chunk-ETAGGIDN.js +119 -0
  16. package/dist/chunk-ETAGGIDN.js.map +1 -0
  17. package/dist/client/index.cjs +4834 -4244
  18. package/dist/client/index.cjs.map +1 -1
  19. package/dist/client/index.d.cts +1 -1
  20. package/dist/client/index.d.ts +1 -1
  21. package/dist/client/index.js +49 -3
  22. package/dist/client/index.js.map +1 -1
  23. package/dist/effects-EWKHKUDP.js +851 -0
  24. package/dist/effects-EWKHKUDP.js.map +1 -0
  25. package/dist/index-CWGkg1-E.d.cts +86 -0
  26. package/dist/index-DPsjkvaY.d.ts +86 -0
  27. package/dist/index.cjs +4852 -4267
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +35 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/lazy.cjs +9308 -0
  34. package/dist/lazy.cjs.map +1 -0
  35. package/dist/lazy.d.cts +7 -0
  36. package/dist/lazy.d.ts +7 -0
  37. package/dist/lazy.js +8 -0
  38. package/dist/lazy.js.map +1 -0
  39. package/dist/next.cjs +9309 -0
  40. package/dist/next.cjs.map +1 -0
  41. package/dist/next.d.cts +4 -0
  42. package/dist/next.d.ts +4 -0
  43. package/dist/next.js +9 -0
  44. package/dist/next.js.map +1 -0
  45. package/dist/schema.cjs +53 -16
  46. package/dist/schema.cjs.map +1 -1
  47. package/dist/schema.d.cts +20 -5
  48. package/dist/schema.d.ts +20 -5
  49. package/dist/schema.js +30 -2
  50. package/dist/schema.js.map +1 -1
  51. package/package.json +23 -8
  52. package/cli/emblema-sync.mjs +0 -675
  53. package/dist/chunk-4YNLMSCK.js.map +0 -1
  54. package/dist/chunk-YWBFAV57.js.map +0 -1
  55. package/dist/index-BbucFgZi.d.ts +0 -49
  56. package/dist/index-CBlJrKkm.d.cts +0 -49
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/activate.ts
21
+ var activate_exports = {};
22
+ __export(activate_exports, {
23
+ STICKY_KEY: () => STICKY_KEY,
24
+ clearSticky: () => clearSticky,
25
+ hostAllowed: () => hostAllowed,
26
+ isLocalHost: () => isLocalHost,
27
+ isStickyEnabled: () => isStickyEnabled,
28
+ reviewParam: () => reviewParam,
29
+ setSticky: () => setSticky,
30
+ shouldActivate: () => shouldActivate
31
+ });
32
+ module.exports = __toCommonJS(activate_exports);
33
+ var STICKY_KEY = "review-kit:sticky";
34
+ var STICKY_TTL_MS = 4 * 60 * 60 * 1e3;
35
+ function safeRemove(storage, key) {
36
+ try {
37
+ storage().removeItem(key);
38
+ } catch {
39
+ }
40
+ }
41
+ function readSticky() {
42
+ try {
43
+ const raw = window.sessionStorage.getItem(STICKY_KEY);
44
+ if (!raw) return null;
45
+ const parsed = JSON.parse(raw);
46
+ if (typeof parsed === "object" && parsed !== null && typeof parsed.token === "string" && typeof parsed.until === "number") {
47
+ return parsed;
48
+ }
49
+ } catch {
50
+ }
51
+ return null;
52
+ }
53
+ function isStickyEnabled(token) {
54
+ if (token === void 0 || token === "") return false;
55
+ const sticky = readSticky();
56
+ if (!sticky) return false;
57
+ if (sticky.until < Date.now() || sticky.token !== token) {
58
+ safeRemove(() => window.sessionStorage, STICKY_KEY);
59
+ return false;
60
+ }
61
+ return true;
62
+ }
63
+ function setSticky(token, on) {
64
+ try {
65
+ if (on && token !== void 0 && token !== "") {
66
+ const value = { token, until: Date.now() + STICKY_TTL_MS };
67
+ window.sessionStorage.setItem(STICKY_KEY, JSON.stringify(value));
68
+ } else {
69
+ window.sessionStorage.removeItem(STICKY_KEY);
70
+ }
71
+ } catch {
72
+ }
73
+ }
74
+ function clearSticky() {
75
+ safeRemove(() => window.sessionStorage, STICKY_KEY);
76
+ }
77
+ function reviewParam() {
78
+ try {
79
+ return new URLSearchParams(window.location.search).get("review");
80
+ } catch {
81
+ return null;
82
+ }
83
+ }
84
+ function hostAllowed(allowedHosts) {
85
+ if (!allowedHosts || allowedHosts.length === 0) return true;
86
+ let host = "";
87
+ try {
88
+ host = window.location.hostname.toLowerCase();
89
+ } catch {
90
+ return false;
91
+ }
92
+ return allowedHosts.some((pattern) => {
93
+ const regex = new RegExp(
94
+ "^" + pattern.toLowerCase().split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*") + "$"
95
+ );
96
+ return regex.test(host);
97
+ });
98
+ }
99
+ function isLocalHost() {
100
+ try {
101
+ const host = window.location.hostname.toLowerCase();
102
+ return host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host.endsWith(".localhost");
103
+ } catch {
104
+ return false;
105
+ }
106
+ }
107
+ var warnedNoToken = false;
108
+ var warnedMismatch = false;
109
+ function shouldActivate(options = {}) {
110
+ if (typeof window === "undefined") return false;
111
+ if (options.enabled === false) return false;
112
+ if (!hostAllowed(options.allowedHosts)) return false;
113
+ const param = reviewParam();
114
+ if (param === "off") {
115
+ clearSticky();
116
+ return false;
117
+ }
118
+ if (options.devAutoOn === true) return true;
119
+ const token = options.token;
120
+ if (token === void 0 || token === "") {
121
+ if (param !== null && param !== "" && !warnedNoToken) {
122
+ warnedNoToken = true;
123
+ console.warn(
124
+ "[review-kit] `?review` is present but no `token` is configured; the layer stays off. Pass `token` to <ReviewKit /> (or `devAutoOn` for local development)."
125
+ );
126
+ }
127
+ return false;
128
+ }
129
+ if (param !== null && param !== "") {
130
+ if (param === token) return true;
131
+ if (!warnedMismatch) {
132
+ warnedMismatch = true;
133
+ console.warn("[review-kit] `?review` token does not match the configured token; staying inactive.");
134
+ }
135
+ return false;
136
+ }
137
+ return isStickyEnabled(token);
138
+ }
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ STICKY_KEY,
142
+ clearSticky,
143
+ hostAllowed,
144
+ isLocalHost,
145
+ isStickyEnabled,
146
+ reviewParam,
147
+ setSticky,
148
+ shouldActivate
149
+ });
150
+ //# sourceMappingURL=activate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/activate.ts"],"sourcesContent":["/**\n * `@satanwagen/reviewkit/activate` — the activation decision, React-free.\n *\n * Hosts that lazy-load the review layer need to know BEFORE importing any\n * React code whether this page load should show the layer at all. This\n * module is that decision, and the only supported way to read ReviewKit's\n * persisted opt-in state (the sessionStorage format is private and may\n * change; `shouldActivate` will not).\n *\n * Rules (no exceptions, no environment sniffing):\n *\n * - `enabled: false` → never.\n * - hostname ∉ `allowedHosts` → never (when an allowlist is given).\n * - `?review=off` → never; also clears the in-tab opt-in.\n * - no `token` configured → never. `?review=x` without a token logs\n * a warning and stays off.\n * - `?review=<token>` → yes.\n * - valid in-tab sticky session → yes (started by an earlier `?review=<token>`\n * load in this tab, bound to the token,\n * ~4 h sliding expiry).\n * - `devAutoOn: true` → yes, regardless of URL/token. The host\n * decides when (e.g. `import.meta.env.DEV`);\n * the library never reads NODE_ENV.\n */\n\nexport interface ActivationOptions {\n /** The review token. Without it the layer never activates (except `devAutoOn`). */\n token?: string;\n /** Master switch. `false` short-circuits everything. Default `true`. */\n enabled?: boolean;\n /** Hostname allowlist with `*` wildcards. Unset = any host. */\n allowedHosts?: string[];\n /** Force the layer on for this page load (dev convenience; host-controlled). */\n devAutoOn?: boolean;\n}\n\n/** @internal sessionStorage key of the per-tab opt-in. Format is private. */\nexport const STICKY_KEY = 'review-kit:sticky';\nconst STICKY_TTL_MS = 4 * 60 * 60 * 1000;\n\ninterface Sticky {\n token: string;\n until: number;\n}\n\nfunction safeRemove(storage: () => Storage, key: string): void {\n try {\n storage().removeItem(key);\n } catch {\n /* storage unavailable */\n }\n}\n\nfunction readSticky(): Sticky | null {\n try {\n const raw = window.sessionStorage.getItem(STICKY_KEY);\n if (!raw) return null;\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === 'object' &&\n parsed !== null &&\n typeof (parsed as Sticky).token === 'string' &&\n typeof (parsed as Sticky).until === 'number'\n ) {\n return parsed as Sticky;\n }\n } catch {\n /* unreadable */\n }\n return null;\n}\n\n/** @internal Is the per-tab opt-in present, unexpired and bound to `token`? */\nexport function isStickyEnabled(token: string | undefined): boolean {\n if (token === undefined || token === '') return false;\n const sticky = readSticky();\n if (!sticky) return false;\n if (sticky.until < Date.now() || sticky.token !== token) {\n safeRemove(() => window.sessionStorage, STICKY_KEY);\n return false;\n }\n return true;\n}\n\n/** @internal Start / renew / end the per-tab opt-in. No-op without a token. */\nexport function setSticky(token: string | undefined, on: boolean): void {\n try {\n if (on && token !== undefined && token !== '') {\n const value: Sticky = { token, until: Date.now() + STICKY_TTL_MS };\n window.sessionStorage.setItem(STICKY_KEY, JSON.stringify(value));\n } else {\n window.sessionStorage.removeItem(STICKY_KEY);\n }\n } catch {\n /* storage unavailable — the choice just won't persist */\n }\n}\n\n/** @internal Clear the per-tab opt-in. */\nexport function clearSticky(): void {\n safeRemove(() => window.sessionStorage, STICKY_KEY);\n}\n\n/** @internal The raw `?review` value of the current URL, or null. */\nexport function reviewParam(): string | null {\n try {\n return new URLSearchParams(window.location.search).get('review');\n } catch {\n return null;\n }\n}\n\n/** Does the current hostname match one of the allowed patterns?\n * '*' matches any characters ('*.dev.example' → a.dev.example, a.b.dev.example). */\nexport function hostAllowed(allowedHosts: string[] | undefined): boolean {\n if (!allowedHosts || allowedHosts.length === 0) return true;\n let host = '';\n try {\n host = window.location.hostname.toLowerCase();\n } catch {\n return false;\n }\n return allowedHosts.some((pattern) => {\n const regex = new RegExp(\n '^' +\n pattern\n .toLowerCase()\n .split('*')\n .map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*') +\n '$',\n );\n return regex.test(host);\n });\n}\n\n/** Loopback hosts where a missing allowlist is expected, not a smell. */\nexport function isLocalHost(): boolean {\n try {\n const host = window.location.hostname.toLowerCase();\n return host === 'localhost' || host === '127.0.0.1' || host === '[::1]' || host.endsWith('.localhost');\n } catch {\n return false;\n }\n}\n\nlet warnedNoToken = false;\nlet warnedMismatch = false;\n\n/**\n * Should the review layer be active for this page load?\n *\n * Read-only except for one deliberate side effect: `?review=off` clears the\n * in-tab opt-in, so a host that gates a lazy import on this function still\n * honours \"off\" on the next load. Safe to call on the server (returns false).\n */\nexport function shouldActivate(options: ActivationOptions = {}): boolean {\n if (typeof window === 'undefined') return false;\n if (options.enabled === false) return false;\n if (!hostAllowed(options.allowedHosts)) return false;\n\n const param = reviewParam();\n if (param === 'off') {\n clearSticky();\n return false;\n }\n if (options.devAutoOn === true) return true;\n\n const token = options.token;\n if (token === undefined || token === '') {\n if (param !== null && param !== '' && !warnedNoToken) {\n warnedNoToken = true;\n console.warn(\n '[review-kit] `?review` is present but no `token` is configured; the layer stays off. ' +\n 'Pass `token` to <ReviewKit /> (or `devAutoOn` for local development).',\n );\n }\n return false;\n }\n if (param !== null && param !== '') {\n if (param === token) return true;\n if (!warnedMismatch) {\n warnedMismatch = true;\n console.warn('[review-kit] `?review` token does not match the configured token; staying inactive.');\n }\n return false;\n }\n return isStickyEnabled(token);\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `@satanwagen/reviewkit/activate` — the activation decision, React-free.
3
+ *
4
+ * Hosts that lazy-load the review layer need to know BEFORE importing any
5
+ * React code whether this page load should show the layer at all. This
6
+ * module is that decision, and the only supported way to read ReviewKit's
7
+ * persisted opt-in state (the sessionStorage format is private and may
8
+ * change; `shouldActivate` will not).
9
+ *
10
+ * Rules (no exceptions, no environment sniffing):
11
+ *
12
+ * - `enabled: false` → never.
13
+ * - hostname ∉ `allowedHosts` → never (when an allowlist is given).
14
+ * - `?review=off` → never; also clears the in-tab opt-in.
15
+ * - no `token` configured → never. `?review=x` without a token logs
16
+ * a warning and stays off.
17
+ * - `?review=<token>` → yes.
18
+ * - valid in-tab sticky session → yes (started by an earlier `?review=<token>`
19
+ * load in this tab, bound to the token,
20
+ * ~4 h sliding expiry).
21
+ * - `devAutoOn: true` → yes, regardless of URL/token. The host
22
+ * decides when (e.g. `import.meta.env.DEV`);
23
+ * the library never reads NODE_ENV.
24
+ */
25
+ interface ActivationOptions {
26
+ /** The review token. Without it the layer never activates (except `devAutoOn`). */
27
+ token?: string;
28
+ /** Master switch. `false` short-circuits everything. Default `true`. */
29
+ enabled?: boolean;
30
+ /** Hostname allowlist with `*` wildcards. Unset = any host. */
31
+ allowedHosts?: string[];
32
+ /** Force the layer on for this page load (dev convenience; host-controlled). */
33
+ devAutoOn?: boolean;
34
+ }
35
+ /** @internal sessionStorage key of the per-tab opt-in. Format is private. */
36
+ declare const STICKY_KEY = "review-kit:sticky";
37
+ /** @internal Is the per-tab opt-in present, unexpired and bound to `token`? */
38
+ declare function isStickyEnabled(token: string | undefined): boolean;
39
+ /** @internal Start / renew / end the per-tab opt-in. No-op without a token. */
40
+ declare function setSticky(token: string | undefined, on: boolean): void;
41
+ /** @internal Clear the per-tab opt-in. */
42
+ declare function clearSticky(): void;
43
+ /** @internal The raw `?review` value of the current URL, or null. */
44
+ declare function reviewParam(): string | null;
45
+ /** Does the current hostname match one of the allowed patterns?
46
+ * '*' matches any characters ('*.dev.example' → a.dev.example, a.b.dev.example). */
47
+ declare function hostAllowed(allowedHosts: string[] | undefined): boolean;
48
+ /** Loopback hosts where a missing allowlist is expected, not a smell. */
49
+ declare function isLocalHost(): boolean;
50
+ /**
51
+ * Should the review layer be active for this page load?
52
+ *
53
+ * Read-only except for one deliberate side effect: `?review=off` clears the
54
+ * in-tab opt-in, so a host that gates a lazy import on this function still
55
+ * honours "off" on the next load. Safe to call on the server (returns false).
56
+ */
57
+ declare function shouldActivate(options?: ActivationOptions): boolean;
58
+
59
+ export { type ActivationOptions, STICKY_KEY, clearSticky, hostAllowed, isLocalHost, isStickyEnabled, reviewParam, setSticky, shouldActivate };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `@satanwagen/reviewkit/activate` — the activation decision, React-free.
3
+ *
4
+ * Hosts that lazy-load the review layer need to know BEFORE importing any
5
+ * React code whether this page load should show the layer at all. This
6
+ * module is that decision, and the only supported way to read ReviewKit's
7
+ * persisted opt-in state (the sessionStorage format is private and may
8
+ * change; `shouldActivate` will not).
9
+ *
10
+ * Rules (no exceptions, no environment sniffing):
11
+ *
12
+ * - `enabled: false` → never.
13
+ * - hostname ∉ `allowedHosts` → never (when an allowlist is given).
14
+ * - `?review=off` → never; also clears the in-tab opt-in.
15
+ * - no `token` configured → never. `?review=x` without a token logs
16
+ * a warning and stays off.
17
+ * - `?review=<token>` → yes.
18
+ * - valid in-tab sticky session → yes (started by an earlier `?review=<token>`
19
+ * load in this tab, bound to the token,
20
+ * ~4 h sliding expiry).
21
+ * - `devAutoOn: true` → yes, regardless of URL/token. The host
22
+ * decides when (e.g. `import.meta.env.DEV`);
23
+ * the library never reads NODE_ENV.
24
+ */
25
+ interface ActivationOptions {
26
+ /** The review token. Without it the layer never activates (except `devAutoOn`). */
27
+ token?: string;
28
+ /** Master switch. `false` short-circuits everything. Default `true`. */
29
+ enabled?: boolean;
30
+ /** Hostname allowlist with `*` wildcards. Unset = any host. */
31
+ allowedHosts?: string[];
32
+ /** Force the layer on for this page load (dev convenience; host-controlled). */
33
+ devAutoOn?: boolean;
34
+ }
35
+ /** @internal sessionStorage key of the per-tab opt-in. Format is private. */
36
+ declare const STICKY_KEY = "review-kit:sticky";
37
+ /** @internal Is the per-tab opt-in present, unexpired and bound to `token`? */
38
+ declare function isStickyEnabled(token: string | undefined): boolean;
39
+ /** @internal Start / renew / end the per-tab opt-in. No-op without a token. */
40
+ declare function setSticky(token: string | undefined, on: boolean): void;
41
+ /** @internal Clear the per-tab opt-in. */
42
+ declare function clearSticky(): void;
43
+ /** @internal The raw `?review` value of the current URL, or null. */
44
+ declare function reviewParam(): string | null;
45
+ /** Does the current hostname match one of the allowed patterns?
46
+ * '*' matches any characters ('*.dev.example' → a.dev.example, a.b.dev.example). */
47
+ declare function hostAllowed(allowedHosts: string[] | undefined): boolean;
48
+ /** Loopback hosts where a missing allowlist is expected, not a smell. */
49
+ declare function isLocalHost(): boolean;
50
+ /**
51
+ * Should the review layer be active for this page load?
52
+ *
53
+ * Read-only except for one deliberate side effect: `?review=off` clears the
54
+ * in-tab opt-in, so a host that gates a lazy import on this function still
55
+ * honours "off" on the next load. Safe to call on the server (returns false).
56
+ */
57
+ declare function shouldActivate(options?: ActivationOptions): boolean;
58
+
59
+ export { type ActivationOptions, STICKY_KEY, clearSticky, hostAllowed, isLocalHost, isStickyEnabled, reviewParam, setSticky, shouldActivate };
@@ -0,0 +1,21 @@
1
+ import {
2
+ STICKY_KEY,
3
+ clearSticky,
4
+ hostAllowed,
5
+ isLocalHost,
6
+ isStickyEnabled,
7
+ reviewParam,
8
+ setSticky,
9
+ shouldActivate
10
+ } from "./chunk-ETAGGIDN.js";
11
+ export {
12
+ STICKY_KEY,
13
+ clearSticky,
14
+ hostAllowed,
15
+ isLocalHost,
16
+ isStickyEnabled,
17
+ reviewParam,
18
+ setSticky,
19
+ shouldActivate
20
+ };
21
+ //# sourceMappingURL=activate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}