mates 0.4.0-beta.9 → 0.4.1
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/Fetch/Fetch.d.ts +7 -1
- package/dist/Fetch/Fetch.d.ts.map +1 -1
- package/dist/MatesUtils/FetchUtils.d.ts +30 -0
- package/dist/MatesUtils/FetchUtils.d.ts.map +1 -0
- package/dist/MatesUtils/MatesUtils.d.ts +47 -0
- package/dist/MatesUtils/MatesUtils.d.ts.map +1 -0
- package/dist/MatesUtils/RouterUtils.d.ts +39 -0
- package/dist/MatesUtils/RouterUtils.d.ts.map +1 -0
- package/dist/MatesUtils/StorageUtils.d.ts +16 -0
- package/dist/MatesUtils/StorageUtils.d.ts.map +1 -0
- package/dist/MatesUtils/ThemeUtils.d.ts +18 -0
- package/dist/MatesUtils/ThemeUtils.d.ts.map +1 -0
- package/dist/MatesUtils/index.d.ts +6 -0
- package/dist/MatesUtils/index.d.ts.map +1 -0
- package/dist/Mutables/Extended Atoms/themeAtom.d.ts +3 -15
- package/dist/Mutables/Extended Atoms/themeAtom.d.ts.map +1 -1
- package/dist/Mutables/atom/storageAtom.d.ts +9 -31
- package/dist/Mutables/atom/storageAtom.d.ts.map +1 -1
- package/dist/Mutables/atom/titleAtom.d.ts +3 -9
- package/dist/Mutables/atom/titleAtom.d.ts.map +1 -1
- package/dist/Mutables/scope/scope.d.ts +20 -1
- package/dist/Mutables/scope/scope.d.ts.map +1 -1
- package/dist/Router/animatedRouter.d.ts.map +1 -1
- package/dist/Router/hashAtom.d.ts +7 -3
- package/dist/Router/hashAtom.d.ts.map +1 -1
- package/dist/Router/historyStateAtom.d.ts +4 -36
- package/dist/Router/historyStateAtom.d.ts.map +1 -1
- package/dist/Router/historyUtils.d.ts +1 -12
- package/dist/Router/historyUtils.d.ts.map +1 -1
- package/dist/Router/index.d.ts +1 -8
- package/dist/Router/index.d.ts.map +1 -1
- package/dist/Router/isPathMatching.d.ts +5 -1
- package/dist/Router/isPathMatching.d.ts.map +1 -1
- package/dist/Router/location.d.ts +3 -63
- package/dist/Router/location.d.ts.map +1 -1
- package/dist/Router/navigateTo.d.ts +7 -27
- package/dist/Router/navigateTo.d.ts.map +1 -1
- package/dist/Router/navigationLock.d.ts +5 -46
- package/dist/Router/navigationLock.d.ts.map +1 -1
- package/dist/Router/navigationRequest.d.ts +7 -42
- package/dist/Router/navigationRequest.d.ts.map +1 -1
- package/dist/Router/pathAtom.d.ts +16 -36
- package/dist/Router/pathAtom.d.ts.map +1 -1
- package/dist/Router/qsAtom.d.ts +7 -3
- package/dist/Router/qsAtom.d.ts.map +1 -1
- package/dist/Template/x-x.d.ts +0 -7
- package/dist/Template/x-x.d.ts.map +1 -1
- package/dist/Template/x.d.ts +17 -4
- package/dist/Template/x.d.ts.map +1 -1
- package/dist/css-in-js/theme.d.ts +0 -8
- package/dist/css-in-js/theme.d.ts.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +26 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +31 -34
- package/dist/index.js.map +1 -1
- package/dist/minidb/index.d.ts +1 -1
- package/dist/minidb/index.d.ts.map +1 -1
- package/dist/minidb/minidb.d.ts +47 -53
- package/dist/minidb/minidb.d.ts.map +1 -1
- package/dist/on/hooks.d.ts.map +1 -1
- package/dist/ssr/index.d.ts +1 -0
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/useCtx.d.ts +63 -0
- package/dist/ssr/useCtx.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/Router/pathResolver.d.ts +0 -9
- package/dist/Router/pathResolver.d.ts.map +0 -1
package/dist/minidb/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/minidb/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/minidb/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/minidb/minidb.d.ts
CHANGED
|
@@ -4,101 +4,95 @@ export type MiniDBMigrator = {
|
|
|
4
4
|
};
|
|
5
5
|
export type MiniDBMigrateFn = (oldVersion: number, newVersion: number, migrator: MiniDBMigrator) => void;
|
|
6
6
|
/**
|
|
7
|
-
* A reactive
|
|
7
|
+
* A reactive table handle backed by an IndexedDB object store.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* - `list()` returns a plain `T[]` and registers the list as a reactive
|
|
10
|
+
* dependency — components and effects re-run when any item changes.
|
|
11
|
+
* The returned array is a normal JS array so `.filter()`, `.sort()`,
|
|
12
|
+
* `.map()` etc. work directly.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* - `find(key)` queries IndexedDB directly without loading the full table
|
|
15
|
+
* into memory. The result is a plain value, **not** reactive.
|
|
16
|
+
*
|
|
17
|
+
* All write methods (`add`, `delete`) persist to IndexedDB and broadcast
|
|
18
|
+
* to other tabs via `BroadcastChannel`.
|
|
17
19
|
*/
|
|
18
|
-
export type
|
|
20
|
+
export type TableHandle<T> = {
|
|
19
21
|
/** Reactive — returns all items as `T[]`. Tracks as a dependency. */
|
|
20
22
|
(): T[];
|
|
21
|
-
/** Reactive
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/** Reactive — returns all items as `T[]`. Alias for call syntax. */
|
|
24
|
+
list(): T[];
|
|
25
|
+
/**
|
|
26
|
+
* Non-reactive — fetches a single item by key directly from IndexedDB.
|
|
27
|
+
* Does NOT load the full table into memory. Returns `undefined` if not found.
|
|
28
|
+
*/
|
|
29
|
+
find(key: string): Promise<T | undefined>;
|
|
27
30
|
/**
|
|
28
31
|
* Add an item. Uses the item's `id` field as the key when present,
|
|
29
32
|
* otherwise auto-generates a UUID and assigns it.
|
|
30
33
|
* @returns The id used.
|
|
31
34
|
*/
|
|
32
35
|
add(item: T): Promise<string>;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
/** Delete one item by key. */
|
|
37
|
+
delete(key: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Update an item in-place. Fetches from the in-memory atom, applies `fn`,
|
|
40
|
+
* persists to IndexedDB, and syncs the reactive state.
|
|
41
|
+
* Does nothing if the key doesn't exist.
|
|
42
|
+
*/
|
|
43
|
+
update(key: string, fn: (item: T) => void): Promise<void>;
|
|
44
|
+
/** Reactive item count. */
|
|
45
|
+
readonly size: number;
|
|
41
46
|
};
|
|
42
47
|
export type MiniDBInstance = {
|
|
43
48
|
/**
|
|
44
|
-
* Returns a
|
|
49
|
+
* Returns a table handle for the given name.
|
|
45
50
|
* The underlying IDB object store is created automatically on first call.
|
|
46
51
|
*
|
|
47
|
-
* Await calls sequentially when requesting multiple new
|
|
48
|
-
*
|
|
52
|
+
* Await calls sequentially when requesting multiple new tables — each new
|
|
53
|
+
* table may internally close and reopen the database to add the store.
|
|
49
54
|
*/
|
|
50
|
-
|
|
55
|
+
table<T>(name: string): Promise<TableHandle<T>>;
|
|
51
56
|
};
|
|
52
57
|
/**
|
|
53
58
|
* Opens (or creates) the opinionated `"mini-db"` IndexedDB database.
|
|
54
59
|
*
|
|
55
60
|
* - **Fixed name** — always `"mini-db"`, cannot be changed.
|
|
56
61
|
* - **No schema** — object stores are created automatically on first
|
|
57
|
-
* `db.
|
|
58
|
-
* -
|
|
59
|
-
*
|
|
62
|
+
* `db.table()` call.
|
|
63
|
+
* - **`list()` loads all into memory** as a reactive `mapAtom`. Components
|
|
64
|
+
* re-render automatically on any write.
|
|
65
|
+
* - **`find()` queries IDB directly** without loading the full dataset.
|
|
60
66
|
* - **No cursors, no indexes, no query builder** — use plain JS array methods
|
|
61
|
-
* (`filter`, `sort`, `map`, …) on
|
|
67
|
+
* (`filter`, `sort`, `map`, …) on `list()`.
|
|
62
68
|
* - **Cross-tab sync** — writes broadcast via `BroadcastChannel` so every
|
|
63
69
|
* open tab's atoms reflect changes immediately without polling.
|
|
64
70
|
*
|
|
65
71
|
* @param version App-level data version (default `1`). Increment to
|
|
66
72
|
* trigger the `onMigrate` callback.
|
|
67
73
|
* @param onMigrate Called once when `version` changes. Use
|
|
68
|
-
* `migrator.clear("
|
|
74
|
+
* `migrator.clear("tableName")` to wipe stale data.
|
|
69
75
|
*
|
|
70
76
|
* @example
|
|
71
77
|
* ```ts
|
|
72
78
|
* interface User { id: string; name: string; role: string }
|
|
73
79
|
*
|
|
74
|
-
* // One shared instance — open at module level, export and reuse everywhere.
|
|
75
80
|
* export const db = await miniDB(2, (oldV, newV, m) => {
|
|
76
81
|
* if (oldV < 2) m.clear("users");
|
|
77
82
|
* });
|
|
78
83
|
*
|
|
79
|
-
* const users = await db.
|
|
84
|
+
* const users = await db.table<User>("users");
|
|
80
85
|
*
|
|
81
|
-
* // ── Reactive
|
|
82
|
-
*
|
|
83
|
-
* ${users()
|
|
84
|
-
* .filter(u => u.role === "admin")
|
|
85
|
-
* .sort((a, b) => a.name.localeCompare(b.name))
|
|
86
|
-
* .map(u => html`<li>${u.name}</li>`)}
|
|
87
|
-
* `
|
|
86
|
+
* // ── Reactive: loads all into memory, tracks changes ──────────────────────
|
|
87
|
+
* users.list().filter(u => u.role === "admin")
|
|
88
88
|
*
|
|
89
|
-
* // ──
|
|
90
|
-
* await users.
|
|
91
|
-
* await users.add({ name: "Bob", role: "user" }); // auto-generates id
|
|
92
|
-
* await users.set("u1", { id: "u1", name: "Alice B.", role: "admin" });
|
|
93
|
-
* await users.update("u1", u => { u.role = "mod"; });
|
|
94
|
-
* await users.deleteRow("u1");
|
|
95
|
-
* await users.clear();
|
|
89
|
+
* // ── Non-reactive: direct IDB lookup, no memory load ──────────────────────
|
|
90
|
+
* const admin = await users.find("u1");
|
|
96
91
|
*
|
|
97
|
-
* // ──
|
|
98
|
-
* users();
|
|
99
|
-
* users.
|
|
100
|
-
* users.
|
|
101
|
-
* users.size; // number
|
|
92
|
+
* // ── Writes ───────────────────────────────────────────────────────────────
|
|
93
|
+
* await users.add({ name: "Alice", role: "admin" });
|
|
94
|
+
* await users.add({ id: "u1", name: "Bob", role: "user" });
|
|
95
|
+
* await users.delete("u1");
|
|
102
96
|
* ```
|
|
103
97
|
*/
|
|
104
98
|
export declare function miniDB(version?: number, onMigrate?: MiniDBMigrateFn): Promise<MiniDBInstance>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minidb.d.ts","sourceRoot":"","sources":["../../lib/minidb/minidb.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"minidb.d.ts","sourceRoot":"","sources":["../../lib/minidb/minidb.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,cAAc,GAAG;IAC3B,qDAAqD;IACrD,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,cAAc,KACrB,IAAI,CAAC;AAEV;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,qEAAqE;IACrE,IAAI,CAAC,EAAE,CAAC;IACR,oEAAoE;IACpE,IAAI,IAAI,CAAC,EAAE,CAAC;IACZ;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1C;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,8BAA8B;IAC9B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;CACjD,CAAC;AAyLF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,MAAM,CAC1B,OAAO,SAAI,EACX,SAAS,CAAC,EAAE,eAAe,GAC1B,OAAO,CAAC,cAAc,CAAC,CA6CzB"}
|
package/dist/on/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../lib/on/hooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../lib/on/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAqBjD,KAAK,SAAS,GAAG,MAAM,IAAI,CAAC;AAI5B;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,WAAW,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,mBAAm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MAAM,WAAW,GAAI,IAAI,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,KAAG,IAgBzD,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GACnB,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,SAAS,GAAG,SAAS,EACvC,SAAQ,WAAoB,KAC3B,IAgBF,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,QAAQ,GACnB,IAAI,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAAS,GAAG,SAAS,EACzD,SAAS,WAAW,KACnB,IAoBF,CAAC;AAIF,eAAO,MAAM,UAAU,GACrB,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,IAAI,KACjD,IAgBF,CAAC;AAIF,eAAO,MAAM,UAAU,GACrB,IAAI,MAAM,SAAS,GAAG,SAAS,EAC/B,IAAI,MAAM,KACT,IAeF,CAAC;AAIF,eAAO,MAAM,SAAS,GACpB,IAAI,MAAM,SAAS,GAAG,SAAS,EAC/B,IAAI,MAAM,KACT,IAcF,CAAC;AAIF;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,EAC1B,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GACzB,IAAI,CAON;AAID,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,SAAS,GAAG,SAAS,KAAG,IAa1D,CAAC"}
|
package/dist/ssr/index.d.ts
CHANGED
package/dist/ssr/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mates — useCtx
|
|
3
|
+
*
|
|
4
|
+
* Retrieves the current server-side Context (Hono-style) during SSR or
|
|
5
|
+
* RPC calls. Uses the same global AsyncLocalStorage key as mates-fullstack's
|
|
6
|
+
* ssr-context.ts, so it works inside the SSR esbuild bundle as well.
|
|
7
|
+
*
|
|
8
|
+
* Returns undefined when called outside a request context (e.g. client-side).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // In a component outer function:
|
|
12
|
+
* const ctx = useCtx();
|
|
13
|
+
* if (ctx) {
|
|
14
|
+
* console.log("request path:", ctx.req.path);
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Minimal Ctx interface matching the Hono-style Context shape.
|
|
19
|
+
* Defined locally — mates doesn't import from mates-fullstack.
|
|
20
|
+
*/
|
|
21
|
+
export interface Ctx {
|
|
22
|
+
req: {
|
|
23
|
+
raw: Request;
|
|
24
|
+
method: string;
|
|
25
|
+
url: string;
|
|
26
|
+
path: string;
|
|
27
|
+
param(name: string): string | undefined;
|
|
28
|
+
query(name: string): string | undefined;
|
|
29
|
+
header(name: string): string | undefined;
|
|
30
|
+
params: Record<string, string>;
|
|
31
|
+
queries: Record<string, string>;
|
|
32
|
+
};
|
|
33
|
+
isSSR: boolean;
|
|
34
|
+
auth: Record<string, unknown> | null;
|
|
35
|
+
cookie: {
|
|
36
|
+
get(name: string): string | undefined;
|
|
37
|
+
getAll(): Record<string, string>;
|
|
38
|
+
set(name: string, value: string, options?: Record<string, unknown>): void;
|
|
39
|
+
delete(name: string, options?: Record<string, unknown>): void;
|
|
40
|
+
};
|
|
41
|
+
var: Record<string, unknown>;
|
|
42
|
+
set(key: string, value: unknown): void;
|
|
43
|
+
get(key: string): unknown;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the current server-side Context (Hono-style).
|
|
48
|
+
*
|
|
49
|
+
* Returns `undefined` when called:
|
|
50
|
+
* - On the client (browser)
|
|
51
|
+
* - Outside a request handler
|
|
52
|
+
*
|
|
53
|
+
* Available when called:
|
|
54
|
+
* - During SSR page rendering
|
|
55
|
+
* - Inside RPC functions (both SSR and HTTP paths)
|
|
56
|
+
* - Inside onRequest/onBeforeRPC/onAfterRPC hooks
|
|
57
|
+
*/
|
|
58
|
+
export declare function useCtx(): Ctx | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true when currently executing inside an SSR render pass.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useIsSSR(): boolean;
|
|
63
|
+
//# sourceMappingURL=useCtx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCtx.d.ts","sourceRoot":"","sources":["../../lib/ssr/useCtx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE;QACH,GAAG,EAAE,OAAO,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QACxC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QACxC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,CAAC;IACF,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC,MAAM,EAAE;QACN,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QACtC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QAC1E,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;KAC/D,CAAC;IACF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAiBD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,IAAI,GAAG,GAAG,SAAS,CAUxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAUlC"}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { buildPath } from "./buildPath";
|
|
2
|
-
export { hashAtom } from "./hashAtom";
|
|
3
|
-
export { isPathMatching } from "./isPathMatching";
|
|
4
|
-
export { location } from "./location";
|
|
5
|
-
export { navigateTo } from "./navigateTo";
|
|
6
|
-
export { lockNavigation, navigationLocked, unlockNavigation, } from "./navigationLock";
|
|
7
|
-
export { pathAtom } from "./pathAtom";
|
|
8
|
-
export { qsAtom } from "./qsAtom";
|
|
9
|
-
//# sourceMappingURL=pathResolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathResolver.d.ts","sourceRoot":"","sources":["../../lib/Router/pathResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|