kosmio 0.1.2 → 0.1.3
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/README.md +30 -0
- package/dist/OfflineSyncContext-DWQu0vg_.js +40 -0
- package/dist/app.js +68 -57
- package/dist/context.js +1 -1
- package/dist/core.js +30 -28
- package/dist/formRegistry-CjW2-z6G.js +3622 -0
- package/dist/index.js +136 -133
- package/dist/{localizedRouter-BjT5yIzl.js → localizedRouter-CNO61cBH.js} +1 -1
- package/dist/offlineWriteQueue-BIJHFYuO.js +352 -0
- package/dist/styles.css +1 -1
- package/dist/ui.js +52 -51
- package/package.json +1 -1
- package/types/app.d.ts +7 -1
- package/types/context.d.ts +3 -2
- package/types/core.d.ts +7 -3
- package/types/ui.d.ts +15 -1
- package/dist/OfflineSyncContext-CRwPM5kh.js +0 -34
- package/dist/formRegistry-C5VIE7xu.js +0 -3469
- package/dist/offlineWriteQueue-C31IjyB_.js +0 -275
package/README.md
CHANGED
|
@@ -35,3 +35,33 @@ Kosmio ships default CSS variables and expects each app to override them as need
|
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Every component style uses the public `--kosmio-*` contract.
|
|
38
|
+
|
|
39
|
+
## App Runtime
|
|
40
|
+
|
|
41
|
+
`createKosmioApp` accepts the application's platform adapters, router policies, native appearance and offline queue scope resolver. Auth and tenant identity stay owned by the application:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const app = createKosmioApp({
|
|
45
|
+
app: { id: "my-app", androidScheme: "site.example.app" },
|
|
46
|
+
offlineQueue: {
|
|
47
|
+
resolveScope: () => ({ userId: auth.user.id, tenantId: auth.tenant?.id }),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const queryClient = app.configure();
|
|
52
|
+
await app.startOfflineSync();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The resolver must return a non-empty `userId`; `tenantId` may be empty for user-level work. Returning `null` or throwing makes queue writes fail closed and stops that sync attempt without selecting a queue. Applications should pass the same active scope to `OfflineSyncProvider` and pause queue sync around session or tenant changes with `pauseOfflineWriteQueueSync()`.
|
|
56
|
+
|
|
57
|
+
The offline queue and query client are module singletons. Configure one Kosmio app runtime per JavaScript application.
|
|
58
|
+
|
|
59
|
+
## Agent Skill
|
|
60
|
+
|
|
61
|
+
Kosmio's agent skill helps coding agents integrate the library using its public components, styles, tokens, and runtime APIs. Install it from the public GitHub repository with the [Vercel Skills CLI](https://www.skills.sh/docs/cli):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx skills add steven-mendoza-z/kosmio --skill pkg
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The CLI can install it for a detected agent or agents selected during setup. The skill is maintained at `.agents/skills/pkg` in this repository.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useSyncExternalStore as a, useMemo as S, useContext as y, createContext as O } from "react";
|
|
3
|
+
import { g, k as m, a as p } from "./offlineWriteQueue-BIJHFYuO.js";
|
|
4
|
+
const d = {
|
|
5
|
+
isOnline: !0,
|
|
6
|
+
isSyncing: !1,
|
|
7
|
+
pendingSyncCount: 0,
|
|
8
|
+
hasPendingSync: !1,
|
|
9
|
+
scopeKey: null
|
|
10
|
+
}, i = {
|
|
11
|
+
isOnline: !0,
|
|
12
|
+
isSyncing: !1,
|
|
13
|
+
pendingSyncCount: 0,
|
|
14
|
+
hasPendingSync: !1
|
|
15
|
+
}, o = O(d), T = () => y(o);
|
|
16
|
+
function P({
|
|
17
|
+
children: r,
|
|
18
|
+
scope: n,
|
|
19
|
+
scopeKey: c,
|
|
20
|
+
getQueueState: s = p,
|
|
21
|
+
subscribeQueue: l = m
|
|
22
|
+
}) {
|
|
23
|
+
const e = n ? String(n.userId ?? "").trim() ? g(n) : null : c ?? null, t = a(
|
|
24
|
+
l,
|
|
25
|
+
() => e ? s(e) : i,
|
|
26
|
+
() => e ? s(e) : i
|
|
27
|
+
), u = S(
|
|
28
|
+
() => ({
|
|
29
|
+
...t,
|
|
30
|
+
scopeKey: e
|
|
31
|
+
}),
|
|
32
|
+
[e, t]
|
|
33
|
+
);
|
|
34
|
+
return /* @__PURE__ */ f(o.Provider, { value: u, children: r });
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
d as D,
|
|
38
|
+
P as O,
|
|
39
|
+
T as u
|
|
40
|
+
};
|
package/dist/app.js
CHANGED
|
@@ -1,84 +1,95 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { c as
|
|
3
|
-
import { M as
|
|
4
|
-
import { N as
|
|
5
|
-
import { q as
|
|
6
|
-
import { j as
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { c as N, b as w, A as C, m as P } from "./systemBars-C3QiEL7z.js";
|
|
3
|
+
import { M as g } from "./MobileRouteTransition-C16D4K5c.js";
|
|
4
|
+
import { N as O } from "./NativeBackButtonHandler-CcLHewdm.js";
|
|
5
|
+
import { q as p } from "./queryClient-ZtNrT-lA.js";
|
|
6
|
+
import { j as U, c as H, O as S, g as h } from "./offlineWriteQueue-BIJHFYuO.js";
|
|
7
|
+
const L = "/auth/callback";
|
|
8
|
+
let m = null;
|
|
9
|
+
function I(e = {}) {
|
|
10
|
+
const a = e.colors ?? {}, o = e.statusBarColors ?? (a.light?.statusBar || a.dark?.statusBar ? {
|
|
10
11
|
light: a.light?.statusBar,
|
|
11
12
|
dark: a.dark?.statusBar
|
|
12
|
-
} : void 0),
|
|
13
|
+
} : void 0), r = e.navigationBarColors ?? (a.light?.navigationBar || a.dark?.navigationBar ? {
|
|
13
14
|
light: a.light?.navigationBar,
|
|
14
15
|
dark: a.dark?.navigationBar
|
|
15
16
|
} : void 0);
|
|
16
17
|
return {
|
|
17
|
-
statusBarColors:
|
|
18
|
-
navigationBarColors:
|
|
18
|
+
statusBarColors: o,
|
|
19
|
+
navigationBarColors: r
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
const a = e.disabledRouteKeys ?? [],
|
|
23
|
-
return [...a.map((
|
|
24
|
-
id: `${
|
|
25
|
-
routeKey:
|
|
22
|
+
function M(e = {}) {
|
|
23
|
+
const a = e.disabledRouteKeys ?? [], o = e.rules ?? [];
|
|
24
|
+
return [...a.map((n) => ({
|
|
25
|
+
id: `${n}-no-transition`,
|
|
26
|
+
routeKey: n,
|
|
26
27
|
enabled: !1
|
|
27
|
-
})), ...
|
|
28
|
+
})), ...o];
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
+
function $(e = {}) {
|
|
30
31
|
return typeof e.resolveScopeKey == "function" ? e.resolveScopeKey : async () => {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
if (typeof e.resolveScope == "function") {
|
|
33
|
+
const r = await e.resolveScope();
|
|
34
|
+
if (!r || !String(r.userId ?? "").trim())
|
|
35
|
+
throw new S();
|
|
36
|
+
return h(r);
|
|
37
|
+
}
|
|
38
|
+
const a = typeof e.resolveUser == "function" ? await e.resolveUser() : e.userId, o = typeof e.resolveTenant == "function" ? await e.resolveTenant() : e.tenantId;
|
|
39
|
+
if (!String(a ?? "").trim())
|
|
40
|
+
throw new S();
|
|
41
|
+
return h({
|
|
33
42
|
userId: a,
|
|
34
|
-
tenantId:
|
|
43
|
+
tenantId: o
|
|
35
44
|
});
|
|
36
45
|
};
|
|
37
46
|
}
|
|
38
|
-
function
|
|
39
|
-
const a = e.capacitor?.runtime ?? e.capacitor, r = e.capacitor?.app,
|
|
40
|
-
capacitor:
|
|
47
|
+
function W(e = {}) {
|
|
48
|
+
const a = /* @__PURE__ */ Symbol("kosmio-app-runtime"), o = e.capacitor?.runtime ?? e.capacitor, r = e.capacitor?.app, n = e.capacitor?.registerPlugin, d = e.app?.id ?? "kosmio", y = N({
|
|
49
|
+
capacitor: o,
|
|
41
50
|
androidAppScheme: e.app?.androidScheme ?? e.app?.androidAppScheme ?? "app",
|
|
42
|
-
authCallbackPath: e.auth?.callbackPath ??
|
|
51
|
+
authCallbackPath: e.auth?.callbackPath ?? L,
|
|
43
52
|
nativeAuthHost: e.auth?.nativeHost,
|
|
44
53
|
nativeAuthPath: e.auth?.nativePath
|
|
45
|
-
}), i =
|
|
46
|
-
registerPlugin:
|
|
54
|
+
}), i = y.isNativeApp(), s = e.mobileTransitions ?? {}, u = s.stateKey ?? `${d}MobileTransitionDirection`, v = M(s), B = e.router?.matchLocalizedRoute ?? e.matchRoute, { statusBarColors: R, navigationBarColors: f } = I(e.systemBars), l = w({
|
|
55
|
+
registerPlugin: n,
|
|
47
56
|
isNative: i,
|
|
48
57
|
pluginName: e.systemBars?.pluginName,
|
|
49
|
-
pluginKey: e.systemBars?.pluginKey ?? `__${
|
|
50
|
-
statusBarColors:
|
|
51
|
-
navigationBarColors:
|
|
58
|
+
pluginKey: e.systemBars?.pluginKey ?? `__${d}SystemBarsPlugin`,
|
|
59
|
+
statusBarColors: R,
|
|
60
|
+
navigationBarColors: f
|
|
52
61
|
});
|
|
53
|
-
function
|
|
54
|
-
|
|
62
|
+
function b() {
|
|
63
|
+
if (m && m !== a)
|
|
64
|
+
throw new Error("Only one Kosmio app runtime may configure the offline queue per application.");
|
|
65
|
+
return e.offlineQueue && H({
|
|
55
66
|
storagePrefix: e.offlineQueue.storagePrefix,
|
|
56
|
-
resolveScopeKey:
|
|
57
|
-
invalidateQueries: e.offlineQueue.invalidateQueries ?? (() =>
|
|
67
|
+
resolveScopeKey: $(e.offlineQueue),
|
|
68
|
+
invalidateQueries: e.offlineQueue.invalidateQueries ?? (() => p.invalidateQueries()),
|
|
58
69
|
appStateAdapter: e.offlineQueue.appStateAdapter ?? (i ? r : null)
|
|
59
|
-
}), m;
|
|
70
|
+
}), m = a, p;
|
|
60
71
|
}
|
|
61
|
-
function
|
|
62
|
-
return
|
|
72
|
+
function A() {
|
|
73
|
+
return U();
|
|
63
74
|
}
|
|
64
|
-
function
|
|
75
|
+
function T(t) {
|
|
65
76
|
return /* @__PURE__ */ c(
|
|
66
|
-
|
|
77
|
+
C,
|
|
67
78
|
{
|
|
68
79
|
app: t?.app ?? r,
|
|
69
80
|
isNative: t?.isNative ?? i,
|
|
70
|
-
mapUrlToRoute: t?.mapUrlToRoute ?? e.mapAppUrlToRoute ??
|
|
81
|
+
mapUrlToRoute: t?.mapUrlToRoute ?? e.mapAppUrlToRoute ?? P
|
|
71
82
|
}
|
|
72
83
|
);
|
|
73
84
|
}
|
|
74
|
-
function
|
|
85
|
+
function K(t) {
|
|
75
86
|
return /* @__PURE__ */ c(
|
|
76
|
-
|
|
87
|
+
O,
|
|
77
88
|
{
|
|
78
89
|
app: t?.app ?? r,
|
|
79
90
|
isNative: t?.isNative ?? i,
|
|
80
91
|
router: t?.router ?? e.router,
|
|
81
|
-
mainRouteKeys: t?.mainRouteKeys ??
|
|
92
|
+
mainRouteKeys: t?.mainRouteKeys ?? s.mainRouteKeys,
|
|
82
93
|
transitionStateKey: t?.transitionStateKey ?? u,
|
|
83
94
|
closeableSelectSelectors: t?.closeableSelectSelectors,
|
|
84
95
|
selectSheetBackdropSelector: t?.selectSheetBackdropSelector,
|
|
@@ -87,37 +98,37 @@ function D(e = {}) {
|
|
|
87
98
|
}
|
|
88
99
|
);
|
|
89
100
|
}
|
|
90
|
-
function
|
|
101
|
+
function k(t) {
|
|
91
102
|
return /* @__PURE__ */ c(
|
|
92
|
-
|
|
103
|
+
g,
|
|
93
104
|
{
|
|
94
105
|
...t,
|
|
95
106
|
router: t?.router ?? e.router,
|
|
96
|
-
matchRoute: t?.matchRoute ??
|
|
97
|
-
rules: t?.rules ??
|
|
107
|
+
matchRoute: t?.matchRoute ?? B,
|
|
108
|
+
rules: t?.rules ?? v,
|
|
98
109
|
stateKey: t?.stateKey ?? u,
|
|
99
|
-
defaultTransition: t?.defaultTransition ??
|
|
110
|
+
defaultTransition: t?.defaultTransition ?? s.defaultTransition
|
|
100
111
|
}
|
|
101
112
|
);
|
|
102
113
|
}
|
|
103
114
|
return {
|
|
104
|
-
...
|
|
105
|
-
AppUrlListener:
|
|
106
|
-
MobileRouteTransition:
|
|
107
|
-
NativeBackButtonHandler:
|
|
108
|
-
configure:
|
|
109
|
-
queryClient:
|
|
110
|
-
startOfflineSync:
|
|
115
|
+
...y,
|
|
116
|
+
AppUrlListener: T,
|
|
117
|
+
MobileRouteTransition: k,
|
|
118
|
+
NativeBackButtonHandler: K,
|
|
119
|
+
configure: b,
|
|
120
|
+
queryClient: p,
|
|
121
|
+
startOfflineSync: A,
|
|
111
122
|
systemBars: l,
|
|
112
123
|
getSystemBarsPlugin: l.getSystemBarsPlugin,
|
|
113
124
|
markNativeAppReady: l.markNativeAppReady,
|
|
114
125
|
syncSystemBarsTheme: l.syncSystemBarsTheme,
|
|
115
126
|
mobileTransitions: {
|
|
116
|
-
rules:
|
|
127
|
+
rules: v,
|
|
117
128
|
stateKey: u
|
|
118
129
|
}
|
|
119
130
|
};
|
|
120
131
|
}
|
|
121
132
|
export {
|
|
122
|
-
|
|
133
|
+
W as createKosmioApp
|
|
123
134
|
};
|
package/dist/context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { F as o, a, P as s, V as i, c as t, u, b as n, d as F, e as p } from "./ViewportContext-z-ZwlTIZ.js";
|
|
2
|
-
import { D as c, O as d, u as f } from "./OfflineSyncContext-
|
|
2
|
+
import { D as c, O as d, u as f } from "./OfflineSyncContext-DWQu0vg_.js";
|
|
3
3
|
export {
|
|
4
4
|
c as DEFAULT_OFFLINE_SYNC_STATE,
|
|
5
5
|
o as FloatingActionsProvider,
|
package/dist/core.js
CHANGED
|
@@ -1,55 +1,57 @@
|
|
|
1
1
|
import { c as s } from "./classNames-CcykAxZN.js";
|
|
2
|
-
import { A as r, E as i, a as u, F as o, b as l, c as n, d as f, e as c, f as y, g as
|
|
3
|
-
import { c as
|
|
4
|
-
import {
|
|
5
|
-
import { c as
|
|
2
|
+
import { A as r, E as i, a as u, F as o, b as l, c as n, d as f, e as c, f as y, g as p, i as m, k as d, h as Q, m as O, j as S, l as g, r as k, t as W, n as h, o as b } from "./localizedRouter-CNO61cBH.js";
|
|
3
|
+
import { c as E, a as T, b as R, g as x, i as q, d as v, m as M, n as F, p as H, r as K, s as A, v as j } from "./shortcuts-n31uRPcv.js";
|
|
4
|
+
import { O as D, c as P, e as w, g as L, a as U, i as B, b as G, d as I, f as J, p as N, r as V, h as X, s as Y, j as Z, k as _ } from "./offlineWriteQueue-BIJHFYuO.js";
|
|
5
|
+
import { c as ee, q as ae } from "./queryClient-ZtNrT-lA.js";
|
|
6
6
|
export {
|
|
7
7
|
r as ApiClient,
|
|
8
8
|
i as Entity,
|
|
9
9
|
u as EntityModelFactory,
|
|
10
10
|
o as Field,
|
|
11
11
|
l as FieldTypes,
|
|
12
|
+
D as OfflineQueueScopeUnavailableError,
|
|
12
13
|
n as buildRoutePath,
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
E as clamp,
|
|
15
|
+
P as configureOfflineWriteQueue,
|
|
15
16
|
f as createEntityModels,
|
|
16
17
|
c as createEntityResource,
|
|
17
18
|
y as createEnumType,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
ee as createKosmioQueryClient,
|
|
20
|
+
p as createLocalizedRouter,
|
|
21
|
+
T as createShortcutMatcher,
|
|
21
22
|
R as createStaggerDelay,
|
|
22
23
|
s as cx,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
w as enqueueOfflineWrite,
|
|
25
|
+
L as getOfflineWriteQueueScopeKey,
|
|
26
|
+
U as getOfflineWriteQueueState,
|
|
26
27
|
x as getRevealStyle,
|
|
27
28
|
q as isEditableTarget,
|
|
28
|
-
|
|
29
|
+
m as isEnumType,
|
|
29
30
|
B as isOfflineQueueCanceledResult,
|
|
30
31
|
G as isOfflineQueueHandledResult,
|
|
31
32
|
I as isOfflineQueueQueuedResult,
|
|
32
33
|
J as isQueueableWriteRequest,
|
|
33
|
-
|
|
34
|
+
v as isTypingTarget,
|
|
34
35
|
d as keysToCamel,
|
|
35
36
|
Q as keysToSnake,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
O as makeCrudHooks,
|
|
38
|
+
S as makeMutationHook,
|
|
39
|
+
g as makeQueryHook,
|
|
40
|
+
M as motion,
|
|
40
41
|
F as normalizeShortcutKey,
|
|
41
42
|
H as parseShortcutKeys,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
N as pauseOfflineWriteQueueSync,
|
|
44
|
+
ae as queryClient,
|
|
45
|
+
V as registerOfflineWriteClient,
|
|
46
|
+
X as requestOfflineWriteQueueSync,
|
|
47
|
+
k as resolveTypeDescriptor,
|
|
46
48
|
K as rowAppearStyle,
|
|
47
49
|
A as shortcutMatches,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
Y as shouldQueueOfflineWrite,
|
|
51
|
+
Z as startOfflineWriteQueueSync,
|
|
52
|
+
_ as subscribeOfflineWriteQueue,
|
|
53
|
+
W as toCamel,
|
|
54
|
+
h as toPascalCase,
|
|
55
|
+
b as toSnake,
|
|
54
56
|
j as variants
|
|
55
57
|
};
|