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 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 b, b as K, A as k, m as f } from "./systemBars-C3QiEL7z.js";
3
- import { M as N } from "./MobileRouteTransition-C16D4K5c.js";
4
- import { N as C } from "./NativeBackButtonHandler-CcLHewdm.js";
5
- import { q as m } from "./queryClient-ZtNrT-lA.js";
6
- import { j as P, c as U, g } from "./offlineWriteQueue-C31IjyB_.js";
7
- const H = "/auth/callback";
8
- function L(e = {}) {
9
- const a = e.colors ?? {}, r = e.statusBarColors ?? (a.light?.statusBar || a.dark?.statusBar ? {
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), o = e.navigationBarColors ?? (a.light?.navigationBar || a.dark?.navigationBar ? {
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: r,
18
- navigationBarColors: o
18
+ statusBarColors: o,
19
+ navigationBarColors: r
19
20
  };
20
21
  }
21
- function O(e = {}) {
22
- const a = e.disabledRouteKeys ?? [], r = e.rules ?? [];
23
- return [...a.map((s) => ({
24
- id: `${s}-no-transition`,
25
- routeKey: s,
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
- })), ...r];
28
+ })), ...o];
28
29
  }
29
- function M(e = {}) {
30
+ function $(e = {}) {
30
31
  return typeof e.resolveScopeKey == "function" ? e.resolveScopeKey : async () => {
31
- const a = typeof e.resolveUser == "function" ? await e.resolveUser() : e.userId, r = typeof e.resolveTenant == "function" ? await e.resolveTenant() : e.tenantId;
32
- return g({
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: r
43
+ tenantId: o
35
44
  });
36
45
  };
37
46
  }
38
- function D(e = {}) {
39
- const a = e.capacitor?.runtime ?? e.capacitor, r = e.capacitor?.app, o = e.capacitor?.registerPlugin, s = e.app?.id ?? "kosmio", p = b({
40
- capacitor: a,
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 ?? H,
51
+ authCallbackPath: e.auth?.callbackPath ?? L,
43
52
  nativeAuthHost: e.auth?.nativeHost,
44
53
  nativeAuthPath: e.auth?.nativePath
45
- }), i = p.isNativeApp(), n = e.mobileTransitions ?? {}, u = n.stateKey ?? `${s}MobileTransitionDirection`, d = O(n), y = e.router?.matchLocalizedRoute ?? e.matchRoute, { statusBarColors: v, navigationBarColors: S } = L(e.systemBars), l = K({
46
- registerPlugin: o,
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 ?? `__${s}SystemBarsPlugin`,
50
- statusBarColors: v,
51
- navigationBarColors: S
58
+ pluginKey: e.systemBars?.pluginKey ?? `__${d}SystemBarsPlugin`,
59
+ statusBarColors: R,
60
+ navigationBarColors: f
52
61
  });
53
- function B() {
54
- return e.offlineQueue && U({
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: M(e.offlineQueue),
57
- invalidateQueries: e.offlineQueue.invalidateQueries ?? (() => m.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 h() {
62
- return P();
72
+ function A() {
73
+ return U();
63
74
  }
64
- function R(t) {
75
+ function T(t) {
65
76
  return /* @__PURE__ */ c(
66
- k,
77
+ C,
67
78
  {
68
79
  app: t?.app ?? r,
69
80
  isNative: t?.isNative ?? i,
70
- mapUrlToRoute: t?.mapUrlToRoute ?? e.mapAppUrlToRoute ?? f
81
+ mapUrlToRoute: t?.mapUrlToRoute ?? e.mapAppUrlToRoute ?? P
71
82
  }
72
83
  );
73
84
  }
74
- function A(t) {
85
+ function K(t) {
75
86
  return /* @__PURE__ */ c(
76
- C,
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 ?? n.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 T(t) {
101
+ function k(t) {
91
102
  return /* @__PURE__ */ c(
92
- N,
103
+ g,
93
104
  {
94
105
  ...t,
95
106
  router: t?.router ?? e.router,
96
- matchRoute: t?.matchRoute ?? y,
97
- rules: t?.rules ?? d,
107
+ matchRoute: t?.matchRoute ?? B,
108
+ rules: t?.rules ?? v,
98
109
  stateKey: t?.stateKey ?? u,
99
- defaultTransition: t?.defaultTransition ?? n.defaultTransition
110
+ defaultTransition: t?.defaultTransition ?? s.defaultTransition
100
111
  }
101
112
  );
102
113
  }
103
114
  return {
104
- ...p,
105
- AppUrlListener: R,
106
- MobileRouteTransition: T,
107
- NativeBackButtonHandler: A,
108
- configure: B,
109
- queryClient: m,
110
- startOfflineSync: h,
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: d,
127
+ rules: v,
117
128
  stateKey: u
118
129
  }
119
130
  };
120
131
  }
121
132
  export {
122
- D as createKosmioApp
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-CRwPM5kh.js";
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 m, i as p, k as d, h as Q, m as g, j as k, l as O, r as S, t as h, n as W, o as C } from "./localizedRouter-BjT5yIzl.js";
3
- import { c as b, a as E, b as R, g as x, i as q, d as M, m as v, n as F, p as H, r as K, s as A, v as j } from "./shortcuts-n31uRPcv.js";
4
- import { c as D, e as P, g as w, a as L, i as B, b as G, d as I, f as J, r as N, h as U, s as V, j as X, k as Y } from "./offlineWriteQueue-C31IjyB_.js";
5
- import { c as _, q as $ } from "./queryClient-ZtNrT-lA.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 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
- b as clamp,
14
- D as configureOfflineWriteQueue,
14
+ E as clamp,
15
+ P as configureOfflineWriteQueue,
15
16
  f as createEntityModels,
16
17
  c as createEntityResource,
17
18
  y as createEnumType,
18
- _ as createKosmioQueryClient,
19
- m as createLocalizedRouter,
20
- E as createShortcutMatcher,
19
+ ee as createKosmioQueryClient,
20
+ p as createLocalizedRouter,
21
+ T as createShortcutMatcher,
21
22
  R as createStaggerDelay,
22
23
  s as cx,
23
- P as enqueueOfflineWrite,
24
- w as getOfflineWriteQueueScopeKey,
25
- L as getOfflineWriteQueueState,
24
+ w as enqueueOfflineWrite,
25
+ L as getOfflineWriteQueueScopeKey,
26
+ U as getOfflineWriteQueueState,
26
27
  x as getRevealStyle,
27
28
  q as isEditableTarget,
28
- p as isEnumType,
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
- M as isTypingTarget,
34
+ v as isTypingTarget,
34
35
  d as keysToCamel,
35
36
  Q as keysToSnake,
36
- g as makeCrudHooks,
37
- k as makeMutationHook,
38
- O as makeQueryHook,
39
- v as motion,
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
- $ as queryClient,
43
- N as registerOfflineWriteClient,
44
- U as requestOfflineWriteQueueSync,
45
- S as resolveTypeDescriptor,
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
- V as shouldQueueOfflineWrite,
49
- X as startOfflineWriteQueueSync,
50
- Y as subscribeOfflineWriteQueue,
51
- h as toCamel,
52
- W as toPascalCase,
53
- C as toSnake,
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
  };