alinea 2.0.0-preview.2 → 2.0.0-preview.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.
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +157 -103
- package/dist/adapter/next/DevRemote.js +10 -2
- package/dist/adapter/next/previews.js +4 -1
- package/dist/adapter/next/previews.spec.d.ts +1 -0
- package/dist/backend/Handler.js +14 -7
- package/dist/backend/api/BasicAuth.d.ts +1 -1
- package/dist/backend/api/BasicAuth.js +14 -14
- package/dist/backend/api/OAuth2.d.ts +3 -3
- package/dist/backend/api/OAuth2.js +7 -4
- package/dist/bundled.d.ts +159 -42
- package/dist/chunks/{chunk-Y7XOMJOC.js → chunk-CFNRVI3Y.js} +220 -247
- package/dist/chunks/chunk-D6UJHBJJ.js +183 -0
- package/dist/chunks/chunk-TIJTT5ZI.js +228 -0
- package/dist/chunks/{chunk-UVOEM4AH.js → chunk-XMOVGDFI.js} +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/serve/LocalAuth.js +1 -1
- package/dist/cloud/AuthResult.d.ts +2 -0
- package/dist/cloud/CloudHandshake.d.ts +7 -0
- package/dist/cloud/CloudHandshake.js +64 -0
- package/dist/cloud/CloudRemote.d.ts +4 -1
- package/dist/cloud/CloudRemote.js +21 -3
- package/dist/components/Breadcrumbs.js +2 -2
- package/dist/components/Calendar.js +6 -6
- package/dist/components/Checkbox.js +3 -3
- package/dist/components/ComboBox.js +11 -11
- package/dist/components/DateField.js +3 -3
- package/dist/components/DatePicker.js +4 -4
- package/dist/components/DateRangePicker.js +6 -6
- package/dist/components/Disclosure.js +8 -8
- package/dist/components/Label.js +5 -5
- package/dist/components/List.js +34 -34
- package/dist/components/Menu.js +4 -4
- package/dist/components/Modal.js +3 -3
- package/dist/components/MultipleSelect.js +25 -25
- package/dist/components/NumberField.js +6 -6
- package/dist/components/ProgressCircle.js +2 -2
- package/dist/components/RadioGroup.js +2 -2
- package/dist/components/SearchField.js +3 -3
- package/dist/components/Select.js +7 -7
- package/dist/components/Surface.js +2 -2
- package/dist/components/Table.js +7 -7
- package/dist/components/Tabs.js +4 -4
- package/dist/components/TagGroup.js +2 -2
- package/dist/components/TextField.js +6 -6
- package/dist/components/TimeField.js +2 -2
- package/dist/components/Toggle.d.ts +1 -1
- package/dist/components/Toggle.js +2 -2
- package/dist/components/Toolbar.js +2 -2
- package/dist/components/Tooltip.js +3 -3
- package/dist/components/Tree.d.ts +4 -2
- package/dist/components/Tree.js +18 -4
- package/dist/core/Connection.d.ts +7 -4
- package/dist/core/Entry.d.ts +6 -0
- package/dist/core/Entry.js +10 -0
- package/dist/core/Graph.d.ts +1 -1
- package/dist/core/Id.d.ts +1 -0
- package/dist/core/Id.js +8 -0
- package/dist/core/Infer.d.ts +8 -1
- package/dist/core/db/EntryAliases.js +1 -4
- package/dist/core/db/EntryResolver.js +6 -6
- package/dist/core/db/EntryTransaction.js +1 -0
- package/dist/core/db/Operation.d.ts +2 -2
- package/dist/core/db/Operation.js +15 -4
- package/dist/dashboard/App.js +37 -17
- package/dist/dashboard/StoryProvider.js +2 -2
- package/dist/dashboard/app/AccessDenied.d.ts +16 -1
- package/dist/dashboard/app/AccessDenied.js +21 -12
- package/dist/dashboard/app/ActivityStatus.js +19 -19
- package/dist/dashboard/app/AppearanceToggle.d.ts +1 -0
- package/dist/dashboard/app/AppearanceToggle.js +43 -0
- package/dist/dashboard/app/AuthView.d.ts +1 -1
- package/dist/dashboard/app/AuthView.js +16 -18
- package/dist/dashboard/app/Badge.js +2 -2
- package/dist/dashboard/app/CompactField.js +17 -17
- package/dist/dashboard/app/DashboardErrorBoundary.js +22 -10
- package/dist/dashboard/app/DashboardLayout.js +15 -8
- package/dist/dashboard/app/DashboardMeta.d.ts +2 -1
- package/dist/dashboard/app/DashboardMeta.js +20 -5
- package/dist/dashboard/app/EntryFields.js +6 -6
- package/dist/dashboard/app/EntryHeader.js +25 -25
- package/dist/dashboard/app/EntryReferences.js +16 -16
- package/dist/dashboard/app/EntrySidebar.js +26 -26
- package/dist/dashboard/app/EntrySidebarPreview.js +61 -34
- package/dist/dashboard/app/EntrySidebarPreview.story.d.ts +6 -1
- package/dist/dashboard/app/EntryTranslationBanner.js +8 -8
- package/dist/dashboard/app/Explorer.d.ts +2 -1
- package/dist/dashboard/app/Explorer.js +79 -67
- package/dist/dashboard/app/ExplorerCards.js +62 -66
- package/dist/dashboard/app/ExplorerFileCard.js +20 -20
- package/dist/dashboard/app/ExplorerList.js +22 -22
- package/dist/dashboard/app/ExplorerModal.js +3 -3
- package/dist/dashboard/app/ExplorerPickerContent.js +2 -2
- package/dist/dashboard/app/ExplorerTable.js +68 -68
- package/dist/dashboard/app/ImagePicker.js +7 -7
- package/dist/dashboard/app/LinkPicker.js +44 -24
- package/dist/dashboard/app/LocaleMenu.js +5 -7
- package/dist/dashboard/app/SidebarLayout.js +7 -7
- package/dist/dashboard/app/SidebarTree.js +66 -74
- package/dist/dashboard/app/WorkspaceMenu.d.ts +10 -3
- package/dist/dashboard/app/WorkspaceMenu.js +85 -64
- package/dist/dashboard/app/WorkspaceMenu.stories.d.ts +2 -0
- package/dist/dashboard/app/WorkspaceRoots.d.ts +3 -1
- package/dist/dashboard/app/WorkspaceRoots.js +82 -107
- package/dist/dashboard/app/editor/FileEditor.js +31 -31
- package/dist/dashboard/app/editor/FilePreview.js +4 -4
- package/dist/dashboard/app/editor/MediaAltField.view.js +4 -4
- package/dist/dashboard/app/modals/CreateEntry.js +14 -14
- package/dist/dashboard/app/pages/EntryPage.js +28 -30
- package/dist/dashboard/app/pages/RootPage.js +4 -4
- package/dist/dashboard/app/pages/SplashPage.d.ts +3 -0
- package/dist/dashboard/app/pages/SplashPage.js +414 -0
- package/dist/dashboard/app/pages/UsersPage.js +35 -35
- package/dist/dashboard/app/ui/DashboardModal.js +19 -19
- package/dist/dashboard/app/ui/Rail.js +3 -3
- package/dist/dashboard/atoms/ReactiveNode.js +1 -1
- package/dist/dashboard/atoms/activity.js +2 -3
- package/dist/dashboard/atoms/auth.d.ts +2 -0
- package/dist/dashboard/atoms/auth.js +6 -2
- package/dist/dashboard/atoms/config.js +1 -1
- package/dist/dashboard/atoms/core.js +2 -2
- package/dist/dashboard/atoms/create.js +1 -1
- package/dist/dashboard/atoms/dashboard.js +2 -2
- package/dist/dashboard/atoms/editor.js +1 -1
- package/dist/dashboard/atoms/entry.js +2 -2
- package/dist/dashboard/atoms/explorer.d.ts +1 -3
- package/dist/dashboard/atoms/explorer.js +7 -9
- package/dist/dashboard/atoms/graph.d.ts +1 -0
- package/dist/dashboard/atoms/graph.js +7 -2
- package/dist/dashboard/atoms/link.js +2 -2
- package/dist/dashboard/atoms/nav.d.ts +4 -3
- package/dist/dashboard/atoms/nav.js +10 -5
- package/dist/dashboard/atoms/preview.js +1 -1
- package/dist/dashboard/atoms/root.js +2 -2
- package/dist/dashboard/atoms/upload.js +1 -1
- package/dist/dashboard/atoms/user.d.ts +1 -1
- package/dist/dashboard/atoms/user.js +8 -6
- package/dist/dashboard/atoms/utils.js +2 -2
- package/dist/dashboard/boot/Boot.js +2 -4
- package/dist/dashboard/boot/DashboardWorker.js +34 -29
- package/dist/dashboard/editor/UseField.js +6 -6
- package/dist/dashboard/fixture/cms.d.ts +12 -0
- package/dist/dashboard/fixture/cms.js +53 -2
- package/dist/dashboard/hook/UseGraph.js +4 -4
- package/dist/dashboard/hook/UseRoot.js +4 -4
- package/dist/dashboard/hooks.js +16 -16
- package/dist/field/check/CheckField.view.js +2 -2
- package/dist/field/code/CodeField.view.js +15 -15
- package/dist/field/link/EntryLink.d.ts +1 -1
- package/dist/field/link/EntryLink.js +1 -0
- package/dist/field/link/Link.js +1 -0
- package/dist/field/link/LinkField.d.ts +5 -0
- package/dist/field/link/LinkField.view.js +81 -64
- package/dist/field/list/ListField.view.js +26 -26
- package/dist/field/localiser/LocalisedField.view.js +76 -5
- package/dist/field/metadata/MetadataField.d.ts +2 -0
- package/dist/field/metadata/MetadataField.js +2 -1
- package/dist/field/metadata/MetadataField.view.js +20 -20
- package/dist/field/richtext/PickTextLink.js +6 -6
- package/dist/field/richtext/RichTextBlock.js +6 -6
- package/dist/field/richtext/RichTextBlocks.js +1 -1
- package/dist/field/richtext/RichTextExtensions.js +23 -23
- package/dist/field/richtext/RichTextField.view.js +9 -9
- package/dist/field/richtext/RichTextState.js +1 -1
- package/dist/field/text/TextField.view.js +2 -2
- package/dist/index.css +436 -28
- package/dist/preview/PreviewMessage.d.ts +3 -0
- package/dist/preview/PreviewMessage.js +1 -0
- package/dist/preview/RegisterPreview.d.ts +1 -1
- package/dist/preview/RegisterPreview.js +28 -10
- package/dist/preview/react.d.ts +5 -1
- package/dist/preview/react.js +12 -9
- package/dist/preview/widget.js +6 -12
- package/dist/query.d.ts +7 -7
- package/package.json +1 -1
- package/dist/chunks/chunk-STAJCW4Z.js +0 -322
- package/dist/chunks/chunk-U4VOHNR2.js +0 -210
package/dist/preview/widget.js
CHANGED
|
@@ -3,7 +3,7 @@ import "../chunks/chunk-CQ52GEHY.js";
|
|
|
3
3
|
// src/preview/widget.ts
|
|
4
4
|
function registerPreviewWidget() {
|
|
5
5
|
if (customElements.get("alinea-preview")) return;
|
|
6
|
-
const observedAttributes = ["
|
|
6
|
+
const observedAttributes = ["adminurl", "editurl", "livepreview"];
|
|
7
7
|
const template = `
|
|
8
8
|
<div class="previews">
|
|
9
9
|
<div class="inner">
|
|
@@ -142,15 +142,15 @@ function registerPreviewWidget() {
|
|
|
142
142
|
disconnectedCallback() {
|
|
143
143
|
this.#disconnect();
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
attributeChangedCallback(name, _oldValue, value) {
|
|
146
146
|
switch (name) {
|
|
147
|
-
case "
|
|
147
|
+
case "adminurl":
|
|
148
148
|
if (this.#adminButton) this.#adminButton.href = value ?? "";
|
|
149
149
|
return;
|
|
150
|
-
case "
|
|
150
|
+
case "editurl":
|
|
151
151
|
if (this.#editButton) this.#editButton.href = value ?? "";
|
|
152
152
|
return;
|
|
153
|
-
case "
|
|
153
|
+
case "livepreview":
|
|
154
154
|
this.#previews?.classList.toggle("is-loading", value === "loading");
|
|
155
155
|
this.#previews?.classList.toggle(
|
|
156
156
|
"is-connected",
|
|
@@ -160,9 +160,6 @@ function registerPreviewWidget() {
|
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
164
|
-
this.setAttribute(name, newValue);
|
|
165
|
-
}
|
|
166
163
|
connectedCallback() {
|
|
167
164
|
const shadow = this.attachShadow({ mode: "open" });
|
|
168
165
|
const style = document.createElement("style");
|
|
@@ -177,10 +174,7 @@ function registerPreviewWidget() {
|
|
|
177
174
|
this.#adminButton = previews.querySelector("#btn-admin");
|
|
178
175
|
this.#editButton = previews.querySelector("#btn-edit");
|
|
179
176
|
for (const attr of AlineaPreview.observedAttributes)
|
|
180
|
-
this.
|
|
181
|
-
this.attributeChangedCallback = (name, oldValue, newValue) => {
|
|
182
|
-
this.setAttribute(name, newValue);
|
|
183
|
-
};
|
|
177
|
+
this.attributeChangedCallback(attr, null, this.getAttribute(attr));
|
|
184
178
|
let xPosition = 0.5;
|
|
185
179
|
previews.addEventListener("mousedown", startDrag);
|
|
186
180
|
function startDrag(event) {
|
package/dist/query.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function children<Selection extends SelectionGuard = undefined, T
|
|
|
24
24
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
25
25
|
path?: import("./core/Filter").Condition<string>;
|
|
26
26
|
url?: import("./core/Filter").Condition<string>;
|
|
27
|
-
alias?: string
|
|
27
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
28
28
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
29
29
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
30
30
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
|
@@ -59,7 +59,7 @@ export declare function parents<Selection extends SelectionGuard = undefined, Ty
|
|
|
59
59
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
60
60
|
path?: import("./core/Filter").Condition<string>;
|
|
61
61
|
url?: import("./core/Filter").Condition<string>;
|
|
62
|
-
alias?: string
|
|
62
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
63
63
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
64
64
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
65
65
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
|
@@ -94,7 +94,7 @@ export declare function translations<Selection extends SelectionGuard = undefine
|
|
|
94
94
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
95
95
|
path?: import("./core/Filter").Condition<string>;
|
|
96
96
|
url?: import("./core/Filter").Condition<string>;
|
|
97
|
-
alias?: string
|
|
97
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
98
98
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
99
99
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
100
100
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
|
@@ -129,7 +129,7 @@ export declare function siblings<Selection extends SelectionGuard = undefined, T
|
|
|
129
129
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
130
130
|
path?: import("./core/Filter").Condition<string>;
|
|
131
131
|
url?: import("./core/Filter").Condition<string>;
|
|
132
|
-
alias?: string
|
|
132
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
133
133
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
134
134
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
135
135
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
|
@@ -162,7 +162,7 @@ export declare function parent<Selection extends SelectionGuard = undefined, Typ
|
|
|
162
162
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
163
163
|
path?: import("./core/Filter").Condition<string>;
|
|
164
164
|
url?: import("./core/Filter").Condition<string>;
|
|
165
|
-
alias?: string
|
|
165
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
166
166
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
167
167
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
168
168
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
|
@@ -194,7 +194,7 @@ export declare function next<Selection extends SelectionGuard = undefined, Type
|
|
|
194
194
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
195
195
|
path?: import("./core/Filter").Condition<string>;
|
|
196
196
|
url?: import("./core/Filter").Condition<string>;
|
|
197
|
-
alias?: string
|
|
197
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
198
198
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
199
199
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
200
200
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
|
@@ -226,7 +226,7 @@ export declare function previous<Selection extends SelectionGuard = undefined, T
|
|
|
226
226
|
parentId?: import("./core/Filter").Condition<string | null>;
|
|
227
227
|
path?: import("./core/Filter").Condition<string>;
|
|
228
228
|
url?: import("./core/Filter").Condition<string>;
|
|
229
|
-
alias?: string
|
|
229
|
+
alias?: import("./core/Filter").Condition<string>;
|
|
230
230
|
createdAt?: import("./core/Filter").Condition<number | null>;
|
|
231
231
|
updatedAt?: import("./core/Filter").Condition<number | null>;
|
|
232
232
|
workspace?: import("./core/Filter").Condition<string> | import("./types").Workspace;
|
package/package.json
CHANGED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
atom
|
|
3
|
-
} from "./chunk-Y7XOMJOC.js";
|
|
4
|
-
|
|
5
|
-
// node_modules/jotai/esm/vanilla/utils.mjs
|
|
6
|
-
var RESET = /* @__PURE__ */ Symbol(
|
|
7
|
-
(import.meta.env ? "production" : void 0) !== "production" ? "RESET" : ""
|
|
8
|
-
);
|
|
9
|
-
var didWarnDeprecation$1 = false;
|
|
10
|
-
function atomFamily(initializeAtom, areEqual) {
|
|
11
|
-
if ((import.meta.env ? "production" : void 0) !== "production" && !didWarnDeprecation$1) {
|
|
12
|
-
console.warn(
|
|
13
|
-
"[DEPRECATED] atomFamily is deprecated and will be removed in v3. Please use the `jotai-family` package instead: https://github.com/jotaijs/jotai-family"
|
|
14
|
-
);
|
|
15
|
-
didWarnDeprecation$1 = true;
|
|
16
|
-
}
|
|
17
|
-
let shouldRemove = null;
|
|
18
|
-
const atoms = /* @__PURE__ */ new Map();
|
|
19
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
20
|
-
const createAtom = (param) => {
|
|
21
|
-
let item;
|
|
22
|
-
if (areEqual === void 0) {
|
|
23
|
-
item = atoms.get(param);
|
|
24
|
-
} else {
|
|
25
|
-
for (const [key, value] of atoms) {
|
|
26
|
-
if (areEqual(key, param)) {
|
|
27
|
-
item = value;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (item !== void 0) {
|
|
33
|
-
if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) {
|
|
34
|
-
createAtom.remove(param);
|
|
35
|
-
} else {
|
|
36
|
-
return item[0];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const newAtom = initializeAtom(param);
|
|
40
|
-
atoms.set(param, [newAtom, Date.now()]);
|
|
41
|
-
notifyListeners("CREATE", param, newAtom);
|
|
42
|
-
return newAtom;
|
|
43
|
-
};
|
|
44
|
-
const notifyListeners = (type, param, atom2) => {
|
|
45
|
-
for (const listener of listeners) {
|
|
46
|
-
listener({ type, param, atom: atom2 });
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
createAtom.unstable_listen = (callback) => {
|
|
50
|
-
listeners.add(callback);
|
|
51
|
-
return () => {
|
|
52
|
-
listeners.delete(callback);
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
createAtom.getParams = () => atoms.keys();
|
|
56
|
-
createAtom.remove = (param) => {
|
|
57
|
-
if (areEqual === void 0) {
|
|
58
|
-
if (!atoms.has(param)) return;
|
|
59
|
-
const [atom2] = atoms.get(param);
|
|
60
|
-
atoms.delete(param);
|
|
61
|
-
notifyListeners("REMOVE", param, atom2);
|
|
62
|
-
} else {
|
|
63
|
-
for (const [key, [atom2]] of atoms) {
|
|
64
|
-
if (areEqual(key, param)) {
|
|
65
|
-
atoms.delete(key);
|
|
66
|
-
notifyListeners("REMOVE", key, atom2);
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
createAtom.setShouldRemove = (fn) => {
|
|
73
|
-
shouldRemove = fn;
|
|
74
|
-
if (!shouldRemove) return;
|
|
75
|
-
for (const [key, [atom2, createdAt]] of atoms) {
|
|
76
|
-
if (shouldRemove(createdAt, key)) {
|
|
77
|
-
atoms.delete(key);
|
|
78
|
-
notifyListeners("REMOVE", key, atom2);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
return createAtom;
|
|
83
|
-
}
|
|
84
|
-
var getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);
|
|
85
|
-
var cache1$3 = /* @__PURE__ */ new WeakMap();
|
|
86
|
-
var memo3 = (create, dep1, dep2, dep3) => {
|
|
87
|
-
const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1);
|
|
88
|
-
const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2);
|
|
89
|
-
return getCached$2(create, cache3, dep3);
|
|
90
|
-
};
|
|
91
|
-
function selectAtom(anAtom, selector, equalityFn = Object.is) {
|
|
92
|
-
return memo3(
|
|
93
|
-
() => {
|
|
94
|
-
const EMPTY = /* @__PURE__ */ Symbol();
|
|
95
|
-
const selectValue = ([value, prevSlice]) => {
|
|
96
|
-
if (prevSlice === EMPTY) {
|
|
97
|
-
return selector(value);
|
|
98
|
-
}
|
|
99
|
-
const slice = selector(value, prevSlice);
|
|
100
|
-
return equalityFn(prevSlice, slice) ? prevSlice : slice;
|
|
101
|
-
};
|
|
102
|
-
const derivedAtom = atom((get) => {
|
|
103
|
-
const prev = get(derivedAtom);
|
|
104
|
-
const value = get(anAtom);
|
|
105
|
-
return selectValue([value, prev]);
|
|
106
|
-
});
|
|
107
|
-
derivedAtom.init = EMPTY;
|
|
108
|
-
return derivedAtom;
|
|
109
|
-
},
|
|
110
|
-
anAtom,
|
|
111
|
-
selector,
|
|
112
|
-
equalityFn
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
var isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
116
|
-
function createJSONStorage(getStringStorage = () => {
|
|
117
|
-
try {
|
|
118
|
-
return window.localStorage;
|
|
119
|
-
} catch (e) {
|
|
120
|
-
if ((import.meta.env ? "production" : void 0) !== "production") {
|
|
121
|
-
if (typeof window !== "undefined") {
|
|
122
|
-
console.warn(e);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return void 0;
|
|
126
|
-
}
|
|
127
|
-
}, options) {
|
|
128
|
-
var _a;
|
|
129
|
-
let lastStr;
|
|
130
|
-
let lastValue;
|
|
131
|
-
const storage = {
|
|
132
|
-
getItem: (key, initialValue) => {
|
|
133
|
-
var _a2, _b;
|
|
134
|
-
const parse = (str2) => {
|
|
135
|
-
str2 = str2 || "";
|
|
136
|
-
if (lastStr !== str2) {
|
|
137
|
-
try {
|
|
138
|
-
lastValue = JSON.parse(str2, options == null ? void 0 : options.reviver);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
return initialValue;
|
|
141
|
-
}
|
|
142
|
-
lastStr = str2;
|
|
143
|
-
}
|
|
144
|
-
return lastValue;
|
|
145
|
-
};
|
|
146
|
-
const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;
|
|
147
|
-
if (isPromiseLike$2(str)) {
|
|
148
|
-
return str.then(parse);
|
|
149
|
-
}
|
|
150
|
-
return parse(str);
|
|
151
|
-
},
|
|
152
|
-
setItem: (key, newValue) => {
|
|
153
|
-
var _a2;
|
|
154
|
-
return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(
|
|
155
|
-
key,
|
|
156
|
-
JSON.stringify(newValue, options == null ? void 0 : options.replacer)
|
|
157
|
-
);
|
|
158
|
-
},
|
|
159
|
-
removeItem: (key) => {
|
|
160
|
-
var _a2;
|
|
161
|
-
return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {
|
|
165
|
-
let newValue;
|
|
166
|
-
try {
|
|
167
|
-
newValue = JSON.parse(v || "", options == null ? void 0 : options.reviver);
|
|
168
|
-
} catch (e) {
|
|
169
|
-
newValue = initialValue;
|
|
170
|
-
}
|
|
171
|
-
callback(newValue);
|
|
172
|
-
});
|
|
173
|
-
let subscriber;
|
|
174
|
-
try {
|
|
175
|
-
subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;
|
|
176
|
-
} catch (e) {
|
|
177
|
-
}
|
|
178
|
-
if (!subscriber && typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage) {
|
|
179
|
-
subscriber = (key, callback) => {
|
|
180
|
-
if (!(getStringStorage() instanceof window.Storage)) {
|
|
181
|
-
return () => {
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
const storageEventCallback = (e) => {
|
|
185
|
-
if (e.storageArea === getStringStorage() && e.key === key) {
|
|
186
|
-
callback(e.newValue);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
window.addEventListener("storage", storageEventCallback);
|
|
190
|
-
return () => {
|
|
191
|
-
window.removeEventListener("storage", storageEventCallback);
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
if (subscriber) {
|
|
196
|
-
storage.subscribe = createHandleSubscribe(subscriber);
|
|
197
|
-
}
|
|
198
|
-
return storage;
|
|
199
|
-
}
|
|
200
|
-
var defaultStorage = createJSONStorage();
|
|
201
|
-
function atomWithStorage(key, initialValue, storage = defaultStorage, options) {
|
|
202
|
-
const getOnInit = options == null ? void 0 : options.getOnInit;
|
|
203
|
-
const baseAtom = atom(
|
|
204
|
-
getOnInit ? storage.getItem(key, initialValue) : initialValue
|
|
205
|
-
);
|
|
206
|
-
if ((import.meta.env ? "production" : void 0) !== "production") {
|
|
207
|
-
baseAtom.debugPrivate = true;
|
|
208
|
-
}
|
|
209
|
-
baseAtom.onMount = (setAtom) => {
|
|
210
|
-
var _a;
|
|
211
|
-
setAtom(storage.getItem(key, initialValue));
|
|
212
|
-
return (_a = storage.subscribe) == null ? void 0 : _a.call(storage, key, setAtom, initialValue);
|
|
213
|
-
};
|
|
214
|
-
const anAtom = atom(
|
|
215
|
-
(get) => get(baseAtom),
|
|
216
|
-
(get, set, update) => {
|
|
217
|
-
const nextValue = typeof update === "function" ? update(get(baseAtom)) : update;
|
|
218
|
-
if (nextValue === RESET) {
|
|
219
|
-
set(baseAtom, initialValue);
|
|
220
|
-
return storage.removeItem(key);
|
|
221
|
-
}
|
|
222
|
-
if (isPromiseLike$2(nextValue)) {
|
|
223
|
-
return nextValue.then((resolvedValue) => {
|
|
224
|
-
set(baseAtom, resolvedValue);
|
|
225
|
-
return storage.setItem(key, resolvedValue);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
set(baseAtom, nextValue);
|
|
229
|
-
return storage.setItem(key, nextValue);
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
return anAtom;
|
|
233
|
-
}
|
|
234
|
-
var getCached = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);
|
|
235
|
-
var cache1$1 = /* @__PURE__ */ new WeakMap();
|
|
236
|
-
var memo2 = (create, dep1, dep2) => {
|
|
237
|
-
const cache2 = getCached(() => /* @__PURE__ */ new WeakMap(), cache1$1, dep1);
|
|
238
|
-
return getCached(create, cache2, dep2);
|
|
239
|
-
};
|
|
240
|
-
var isPromiseLike = (p) => typeof (p == null ? void 0 : p.then) === "function";
|
|
241
|
-
var defaultFallback = () => void 0;
|
|
242
|
-
function unwrap(anAtom, fallback = defaultFallback) {
|
|
243
|
-
return memo2(
|
|
244
|
-
() => {
|
|
245
|
-
const promiseErrorCache = /* @__PURE__ */ new WeakMap();
|
|
246
|
-
const promiseResultCache = /* @__PURE__ */ new WeakMap();
|
|
247
|
-
const refreshAtom = atom(0);
|
|
248
|
-
const triggerRefreshAtom = atom([]);
|
|
249
|
-
triggerRefreshAtom.INTERNAL_onInit = (store) => {
|
|
250
|
-
store.set(triggerRefreshAtom, [
|
|
251
|
-
() => store.set(refreshAtom, (c) => c + 1)
|
|
252
|
-
]);
|
|
253
|
-
};
|
|
254
|
-
if ((import.meta.env ? "production" : void 0) !== "production") {
|
|
255
|
-
refreshAtom.debugPrivate = true;
|
|
256
|
-
triggerRefreshAtom.debugPrivate = true;
|
|
257
|
-
}
|
|
258
|
-
const promiseAndValueAtom = atom((get) => {
|
|
259
|
-
get(refreshAtom);
|
|
260
|
-
let prev;
|
|
261
|
-
try {
|
|
262
|
-
prev = get(promiseAndValueAtom);
|
|
263
|
-
} catch (e) {
|
|
264
|
-
}
|
|
265
|
-
const promise = get(anAtom);
|
|
266
|
-
if (!isPromiseLike(promise)) {
|
|
267
|
-
return { v: promise };
|
|
268
|
-
}
|
|
269
|
-
if (promise !== (prev == null ? void 0 : prev.p)) {
|
|
270
|
-
promise.then(
|
|
271
|
-
(v) => {
|
|
272
|
-
promiseResultCache.set(promise, v);
|
|
273
|
-
const [triggerRefresh] = get(triggerRefreshAtom);
|
|
274
|
-
triggerRefresh();
|
|
275
|
-
},
|
|
276
|
-
(e) => {
|
|
277
|
-
promiseErrorCache.set(promise, e);
|
|
278
|
-
const [triggerRefresh] = get(triggerRefreshAtom);
|
|
279
|
-
triggerRefresh();
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
if (promiseErrorCache.has(promise)) {
|
|
284
|
-
throw promiseErrorCache.get(promise);
|
|
285
|
-
}
|
|
286
|
-
if (promiseResultCache.has(promise)) {
|
|
287
|
-
return {
|
|
288
|
-
p: promise,
|
|
289
|
-
v: promiseResultCache.get(promise)
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
if (prev && "v" in prev) {
|
|
293
|
-
return { p: promise, f: fallback(prev.v), v: prev.v };
|
|
294
|
-
}
|
|
295
|
-
return { p: promise, f: fallback() };
|
|
296
|
-
});
|
|
297
|
-
promiseAndValueAtom.init = void 0;
|
|
298
|
-
if ((import.meta.env ? "production" : void 0) !== "production") {
|
|
299
|
-
promiseAndValueAtom.debugPrivate = true;
|
|
300
|
-
}
|
|
301
|
-
return atom(
|
|
302
|
-
(get) => {
|
|
303
|
-
const state = get(promiseAndValueAtom);
|
|
304
|
-
if ("f" in state) {
|
|
305
|
-
return state.f;
|
|
306
|
-
}
|
|
307
|
-
return state.v;
|
|
308
|
-
},
|
|
309
|
-
(_get, set, ...args) => set(anAtom, ...args)
|
|
310
|
-
);
|
|
311
|
-
},
|
|
312
|
-
anAtom,
|
|
313
|
-
fallback
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export {
|
|
318
|
-
atomFamily,
|
|
319
|
-
selectAtom,
|
|
320
|
-
atomWithStorage,
|
|
321
|
-
unwrap
|
|
322
|
-
};
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createStore,
|
|
3
|
-
getBuildingBlocks,
|
|
4
|
-
getDefaultStore
|
|
5
|
-
} from "./chunk-Y7XOMJOC.js";
|
|
6
|
-
|
|
7
|
-
// node_modules/jotai/esm/react.mjs
|
|
8
|
-
import React, { createContext, useContext, useRef, createElement, useReducer, useEffect, useDebugValue, useCallback } from "react";
|
|
9
|
-
var StoreContext = createContext(
|
|
10
|
-
void 0
|
|
11
|
-
);
|
|
12
|
-
function useStore(options) {
|
|
13
|
-
const store = useContext(StoreContext);
|
|
14
|
-
return (options == null ? void 0 : options.store) || store || getDefaultStore();
|
|
15
|
-
}
|
|
16
|
-
function Provider({
|
|
17
|
-
children,
|
|
18
|
-
store
|
|
19
|
-
}) {
|
|
20
|
-
const storeRef = useRef(null);
|
|
21
|
-
if (store) {
|
|
22
|
-
return createElement(StoreContext.Provider, { value: store }, children);
|
|
23
|
-
}
|
|
24
|
-
if (storeRef.current === null) {
|
|
25
|
-
storeRef.current = createStore();
|
|
26
|
-
}
|
|
27
|
-
return createElement(
|
|
28
|
-
StoreContext.Provider,
|
|
29
|
-
{
|
|
30
|
-
// TODO: If this is not a false positive, consider using useState instead of useRef like https://github.com/pmndrs/jotai/pull/2771
|
|
31
|
-
// eslint-disable-next-line react-hooks/refs
|
|
32
|
-
value: storeRef.current
|
|
33
|
-
},
|
|
34
|
-
children
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
var isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
38
|
-
var attachPromiseStatus = (promise) => {
|
|
39
|
-
if (!promise.status) {
|
|
40
|
-
promise.status = "pending";
|
|
41
|
-
promise.then(
|
|
42
|
-
(v) => {
|
|
43
|
-
promise.status = "fulfilled";
|
|
44
|
-
promise.value = v;
|
|
45
|
-
},
|
|
46
|
-
(e) => {
|
|
47
|
-
promise.status = "rejected";
|
|
48
|
-
promise.reason = e;
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var use = React.use || // A shim for older React versions
|
|
54
|
-
((promise) => {
|
|
55
|
-
if (promise.status === "pending") {
|
|
56
|
-
throw promise;
|
|
57
|
-
} else if (promise.status === "fulfilled") {
|
|
58
|
-
return promise.value;
|
|
59
|
-
} else if (promise.status === "rejected") {
|
|
60
|
-
throw promise.reason;
|
|
61
|
-
} else {
|
|
62
|
-
attachPromiseStatus(promise);
|
|
63
|
-
throw promise;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
var continuablePromiseMap = /* @__PURE__ */ new WeakMap();
|
|
67
|
-
var createContinuablePromise = (store, promise, getValue) => {
|
|
68
|
-
const buildingBlocks = getBuildingBlocks(store);
|
|
69
|
-
const registerAbortHandler = buildingBlocks[26];
|
|
70
|
-
let continuablePromise = continuablePromiseMap.get(promise);
|
|
71
|
-
if (!continuablePromise) {
|
|
72
|
-
continuablePromise = new Promise((resolve, reject) => {
|
|
73
|
-
let curr = promise;
|
|
74
|
-
const onFulfilled = (me) => (v) => {
|
|
75
|
-
if (curr === me) {
|
|
76
|
-
resolve(v);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const onRejected = (me) => (e) => {
|
|
80
|
-
if (curr === me) {
|
|
81
|
-
reject(e);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const onAbort = () => {
|
|
85
|
-
try {
|
|
86
|
-
const nextValue = getValue();
|
|
87
|
-
if (isPromiseLike(nextValue)) {
|
|
88
|
-
continuablePromiseMap.set(nextValue, continuablePromise);
|
|
89
|
-
curr = nextValue;
|
|
90
|
-
nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
|
|
91
|
-
registerAbortHandler(buildingBlocks, store, nextValue, onAbort);
|
|
92
|
-
} else {
|
|
93
|
-
resolve(nextValue);
|
|
94
|
-
}
|
|
95
|
-
} catch (e) {
|
|
96
|
-
reject(e);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
promise.then(onFulfilled(promise), onRejected(promise));
|
|
100
|
-
registerAbortHandler(buildingBlocks, store, promise, onAbort);
|
|
101
|
-
});
|
|
102
|
-
continuablePromiseMap.set(promise, continuablePromise);
|
|
103
|
-
}
|
|
104
|
-
return continuablePromise;
|
|
105
|
-
};
|
|
106
|
-
function useAtomValue(atom, options) {
|
|
107
|
-
const { delay, unstable_promiseStatus: promiseStatus = !React.use } = options || {};
|
|
108
|
-
const store = useStore(options);
|
|
109
|
-
const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = useReducer(
|
|
110
|
-
(prev) => {
|
|
111
|
-
const nextValue = store.get(atom);
|
|
112
|
-
if (Object.is(prev[0], nextValue) && prev[1] === store && prev[2] === atom) {
|
|
113
|
-
return prev;
|
|
114
|
-
}
|
|
115
|
-
return [nextValue, store, atom];
|
|
116
|
-
},
|
|
117
|
-
void 0,
|
|
118
|
-
() => [store.get(atom), store, atom]
|
|
119
|
-
);
|
|
120
|
-
let value = valueFromReducer;
|
|
121
|
-
if (storeFromReducer !== store || atomFromReducer !== atom) {
|
|
122
|
-
rerender();
|
|
123
|
-
value = store.get(atom);
|
|
124
|
-
}
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
const unsub = store.sub(atom, () => {
|
|
127
|
-
if (promiseStatus) {
|
|
128
|
-
try {
|
|
129
|
-
const value2 = store.get(atom);
|
|
130
|
-
if (isPromiseLike(value2)) {
|
|
131
|
-
attachPromiseStatus(
|
|
132
|
-
createContinuablePromise(store, value2, () => store.get(atom))
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
} catch (e) {
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (typeof delay === "number") {
|
|
139
|
-
console.warn(`[DEPRECATED] delay option is deprecated and will be removed in v3.
|
|
140
|
-
|
|
141
|
-
Migration guide:
|
|
142
|
-
|
|
143
|
-
Create a custom hook like the following.
|
|
144
|
-
|
|
145
|
-
function useAtomValueWithDelay<Value>(
|
|
146
|
-
atom: Atom<Value>,
|
|
147
|
-
options: { delay: number },
|
|
148
|
-
): Value {
|
|
149
|
-
const { delay } = options
|
|
150
|
-
const store = useStore(options)
|
|
151
|
-
const [value, setValue] = useState(() => store.get(atom))
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
const unsub = store.sub(atom, () => {
|
|
154
|
-
setTimeout(() => setValue(store.get(atom)), delay)
|
|
155
|
-
})
|
|
156
|
-
return unsub
|
|
157
|
-
}, [store, atom, delay])
|
|
158
|
-
return value
|
|
159
|
-
}
|
|
160
|
-
`);
|
|
161
|
-
setTimeout(rerender, delay);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
rerender();
|
|
165
|
-
});
|
|
166
|
-
rerender();
|
|
167
|
-
return unsub;
|
|
168
|
-
}, [store, atom, delay, promiseStatus]);
|
|
169
|
-
useDebugValue(value);
|
|
170
|
-
if (isPromiseLike(value)) {
|
|
171
|
-
const promise = createContinuablePromise(
|
|
172
|
-
store,
|
|
173
|
-
value,
|
|
174
|
-
() => store.get(atom)
|
|
175
|
-
);
|
|
176
|
-
if (promiseStatus) {
|
|
177
|
-
attachPromiseStatus(promise);
|
|
178
|
-
}
|
|
179
|
-
return use(promise);
|
|
180
|
-
}
|
|
181
|
-
return value;
|
|
182
|
-
}
|
|
183
|
-
function useSetAtom(atom, options) {
|
|
184
|
-
const store = useStore(options);
|
|
185
|
-
const setAtom = useCallback(
|
|
186
|
-
(...args) => {
|
|
187
|
-
if ((import.meta.env ? "production" : void 0) !== "production" && !("write" in atom)) {
|
|
188
|
-
throw new Error("not writable atom");
|
|
189
|
-
}
|
|
190
|
-
return store.set(atom, ...args);
|
|
191
|
-
},
|
|
192
|
-
[store, atom]
|
|
193
|
-
);
|
|
194
|
-
return setAtom;
|
|
195
|
-
}
|
|
196
|
-
function useAtom(atom, options) {
|
|
197
|
-
return [
|
|
198
|
-
useAtomValue(atom, options),
|
|
199
|
-
// We do wrong type assertion here, which results in throwing an error.
|
|
200
|
-
useSetAtom(atom, options)
|
|
201
|
-
];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export {
|
|
205
|
-
useStore,
|
|
206
|
-
Provider,
|
|
207
|
-
useAtomValue,
|
|
208
|
-
useSetAtom,
|
|
209
|
-
useAtom
|
|
210
|
-
};
|