@nmvuong92/fluxe 0.1.0 → 0.2.0
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/LICENSE +190 -0
- package/NOTICE +5 -0
- package/README.md +10 -0
- package/lib/backends/sqlite.js +2 -0
- package/lib/backends/types.js +2 -0
- package/lib/core/auth.js +2 -0
- package/lib/core/broker.js +2 -0
- package/lib/core/cli.js +2 -0
- package/lib/core/client.js +2 -0
- package/lib/core/codegen.js +2 -0
- package/lib/core/engine.d.ts +3 -0
- package/lib/core/errors.js +2 -0
- package/lib/core/etag.js +2 -0
- package/lib/core/i18n.d.ts +17 -0
- package/lib/core/i18n.js +40 -0
- package/lib/core/jobs.js +2 -0
- package/lib/core/layouts.js +2 -0
- package/lib/core/nav.js +2 -0
- package/lib/core/observe.js +2 -0
- package/lib/core/presence.js +2 -0
- package/lib/core/ratelimit.js +2 -0
- package/lib/core/rendercache.js +2 -0
- package/lib/core/seo.js +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/react/DebugBar.js +2 -0
- package/lib/react/LocaleSwitch.d.ts +6 -0
- package/lib/react/LocaleSwitch.js +8 -0
- package/lib/react/Nav.js +2 -0
- package/lib/react/ThemeToggle.js +2 -0
- package/lib/react/index.d.ts +1 -0
- package/lib/react/index.js +3 -0
- package/lib/react/mutation.js +2 -0
- package/lib/react/nav-client.js +2 -0
- package/lib/react/query.js +2 -0
- package/lib/react/shell.d.ts +1 -1
- package/lib/react/shell.js +3 -1
- package/lib/react/store.js +2 -0
- package/lib/react/theme.js +2 -0
- package/lib/server_factory.d.ts +4 -1
- package/lib/server_factory.js +27 -8
- package/package.json +61 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and
|
|
113
|
+
may provide additional or different license terms and conditions
|
|
114
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
115
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
116
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
117
|
+
the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
120
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
121
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
122
|
+
this License, without any additional terms or conditions.
|
|
123
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
124
|
+
the terms of any separate license agreement you may have executed
|
|
125
|
+
with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
128
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
129
|
+
except as required for reasonable and customary use in describing the
|
|
130
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
131
|
+
|
|
132
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
133
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
134
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
135
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
136
|
+
implied, including, without limitation, any warranties or conditions
|
|
137
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
138
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
139
|
+
appropriateness of using or redistributing the Work and assume any
|
|
140
|
+
risks associated with Your exercise of permissions under this License.
|
|
141
|
+
|
|
142
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
143
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
144
|
+
unless required by applicable law (such as deliberate and grossly
|
|
145
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
146
|
+
liable to You for damages, including any direct, indirect, special,
|
|
147
|
+
incidental, or consequential damages of any character arising as a
|
|
148
|
+
result of this License or out of the use or inability to use the
|
|
149
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
150
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
151
|
+
other commercial damages or losses), even if such Contributor
|
|
152
|
+
has been advised of the possibility of such damages.
|
|
153
|
+
|
|
154
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
155
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
156
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
157
|
+
or other liability obligations and/or rights consistent with this
|
|
158
|
+
License. However, in accepting such obligations, You may act only
|
|
159
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
160
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
161
|
+
defend, and hold each Contributor harmless for any liability
|
|
162
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
163
|
+
of your accepting any such warranty or additional liability.
|
|
164
|
+
|
|
165
|
+
END OF TERMS AND CONDITIONS
|
|
166
|
+
|
|
167
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
168
|
+
|
|
169
|
+
To apply the Apache License to your work, attach the following
|
|
170
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
171
|
+
replaced with your own identifying information. (Don't include
|
|
172
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
173
|
+
comment syntax for the file format. We also recommend that a
|
|
174
|
+
file or class name and description of purpose be included on the
|
|
175
|
+
same "printed page" as the copyright notice for easier
|
|
176
|
+
identification within third-party archives.
|
|
177
|
+
|
|
178
|
+
Copyright 2026 nmvuong92
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# fluxe
|
|
2
2
|
|
|
3
|
+
[](https://github.com/nmvuong92/fluxe/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@nmvuong92/fluxe)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
3
7
|
Khung fullstack **polyglot** dựa trên triết lý **RCA — Resolved Cell Architecture**:
|
|
4
8
|
*logic chỉ phụ thuộc HỢP ĐỒNG; mọi quyết định vận hành (ngôn ngữ, render, transport,
|
|
5
9
|
backend, scale) là **kết quả được GIẢI** bởi engine, không viết tay.*
|
|
@@ -86,3 +90,9 @@ mỗi tầng đúng ngôn ngữ tối ưu, đúng §6d của [idea.md](idea.md).
|
|
|
86
90
|
|
|
87
91
|
Toàn bộ định hướng, các trục chiến lược, tenets và nguyên lý RCA: xem **[idea.md](idea.md)**.
|
|
88
92
|
Spec + plan: `docs/superpowers/`.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
**Apache-2.0** © 2026 nmvuong92. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
97
|
+
Copyright is held solely by the author, who reserves the right to offer the software under
|
|
98
|
+
separate commercial terms.
|
package/lib/backends/sqlite.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
import { DatabaseSync } from "node:sqlite";
|
|
2
4
|
/* Backend DB THẬT — SQLite qua node:sqlite (built-in, 0 dep, persist ra file).
|
|
3
5
|
* Chạy cần cờ: node --experimental-sqlite … Cùng interface Backend → switch như mọi backend. */
|
package/lib/backends/types.js
CHANGED
package/lib/core/auth.js
CHANGED
package/lib/core/broker.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Broker pub/sub in-memory — nền của realtime channel (Trục 4g), bản 1-node.
|
|
2
4
|
* Bản distributed: thay bằng NATS/Redis fan-out (cùng interface). Bản stateful:
|
|
3
5
|
* actor-Go (app/native/actor-go). Đây là lõi đơn giản nhất, dependency-free. */
|
package/lib/core/cli.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* fx CLI — registry lệnh thuần (testable). bin/fx.ts dispatch + spawn. */
|
|
2
4
|
const SYNC = "tsx scripts/sync.ts"; // auto-discovery: quét app/cells/* → app/app.ts
|
|
3
5
|
const ESBUILD = "esbuild src/client.tsx --bundle --format=esm --outfile=dist/client.js --jsx=automatic --loader:.tsx=tsx";
|
package/lib/core/client.js
CHANGED
package/lib/core/codegen.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Codegen contract polyglot — MỘT schema → types TS + Go + Rust (chữ ký RCA:
|
|
2
4
|
* type-safe xuyên ngôn ngữ). Thuần (string-in/string-out), dễ test. */
|
|
3
5
|
const pascal = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
package/lib/core/engine.d.ts
CHANGED
|
@@ -2,10 +2,13 @@ import type { ComponentType } from "react";
|
|
|
2
2
|
import type { Backend } from "../backends/types";
|
|
3
3
|
import type { HeadMeta } from "./seo";
|
|
4
4
|
import type { Session } from "./auth";
|
|
5
|
+
import type { TFn } from "./i18n";
|
|
5
6
|
export interface Ctx<I> {
|
|
6
7
|
input: I;
|
|
7
8
|
backend: Backend;
|
|
8
9
|
session?: Session | null;
|
|
10
|
+
locale?: string;
|
|
11
|
+
t?: TFn;
|
|
9
12
|
}
|
|
10
13
|
export type Loader<I, O> = (ctx: Ctx<I>) => Promise<O>;
|
|
11
14
|
export type Action<I, O> = (ctx: Ctx<I>) => Promise<O>;
|
package/lib/core/errors.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Error handling (tenet T5 / Trục 4q):
|
|
2
4
|
* - FluxeError = domain error (giá trị có kiểu) → map status/code/message an toàn.
|
|
3
5
|
* - Lỗi khác = unexpected → 500 generic + errorId; detail chỉ ở dev (không leak prod). */
|
package/lib/core/etag.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
import { createHash } from "node:crypto";
|
|
2
4
|
/* Render cache — ETag/304: hash body, client gửi If-None-Match → 304 nếu không đổi
|
|
3
5
|
* (không gửi lại body). Dùng cho JSON props (SPA nav refetch nhiều). */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Messages = Record<string, string>;
|
|
2
|
+
export type TFn = (key: string, vars?: Record<string, string | number>) => string;
|
|
3
|
+
export interface I18n {
|
|
4
|
+
locales: string[];
|
|
5
|
+
defaultLocale: string;
|
|
6
|
+
catalogs: Record<string, Messages>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createI18n(opts: {
|
|
9
|
+
defaultLocale: string;
|
|
10
|
+
catalogs: Record<string, Messages>;
|
|
11
|
+
}): I18n;
|
|
12
|
+
export declare function translate(i18n: I18n, locale: string, key: string, vars?: Record<string, string | number>): string;
|
|
13
|
+
export declare function makeT(i18n: I18n, locale: string): TFn;
|
|
14
|
+
export declare function resolveLocale(i18n: I18n, opts: {
|
|
15
|
+
cookie?: string;
|
|
16
|
+
acceptLanguage?: string;
|
|
17
|
+
}): string;
|
package/lib/core/i18n.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/* i18n — THUẦN, testable. Catalog message theo locale + t(key, vars) interpolate {var}.
|
|
4
|
+
* resolveLocale: chọn locale từ cookie / Accept-Language, giới hạn trong locale có thật. */
|
|
5
|
+
export function createI18n(opts) {
|
|
6
|
+
const locales = Object.keys(opts.catalogs);
|
|
7
|
+
if (!locales.includes(opts.defaultLocale)) {
|
|
8
|
+
throw new Error(`i18n: defaultLocale '${opts.defaultLocale}' không có trong catalogs`);
|
|
9
|
+
}
|
|
10
|
+
return { locales, defaultLocale: opts.defaultLocale, catalogs: opts.catalogs };
|
|
11
|
+
}
|
|
12
|
+
/* Tra key trong catalog locale → fallback defaultLocale → fallback chính key. Interpolate {var}. */
|
|
13
|
+
export function translate(i18n, locale, key, vars) {
|
|
14
|
+
const msg = i18n.catalogs[locale]?.[key] ?? i18n.catalogs[i18n.defaultLocale]?.[key] ?? key;
|
|
15
|
+
if (!vars)
|
|
16
|
+
return msg;
|
|
17
|
+
return msg.replace(/\{(\w+)\}/g, (_, k) => (k in vars ? String(vars[k]) : `{${k}}`));
|
|
18
|
+
}
|
|
19
|
+
/* t() đã bind locale — dùng trong loader/view. */
|
|
20
|
+
export function makeT(i18n, locale) {
|
|
21
|
+
return (key, vars) => translate(i18n, locale, key, vars);
|
|
22
|
+
}
|
|
23
|
+
/* Chọn locale: cookie hợp lệ > Accept-Language (khớp tag hoặc base) > defaultLocale. */
|
|
24
|
+
export function resolveLocale(i18n, opts) {
|
|
25
|
+
if (opts.cookie && i18n.locales.includes(opts.cookie))
|
|
26
|
+
return opts.cookie;
|
|
27
|
+
if (opts.acceptLanguage) {
|
|
28
|
+
for (const part of opts.acceptLanguage.split(",")) {
|
|
29
|
+
const tag = part.split(";")[0].trim(); // "en-US"
|
|
30
|
+
if (!tag)
|
|
31
|
+
continue;
|
|
32
|
+
if (i18n.locales.includes(tag))
|
|
33
|
+
return tag;
|
|
34
|
+
const base = tag.split("-")[0]; // "en"
|
|
35
|
+
if (i18n.locales.includes(base))
|
|
36
|
+
return base;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return i18n.defaultLocale;
|
|
40
|
+
}
|
package/lib/core/jobs.js
CHANGED
package/lib/core/layouts.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Nested layouts — phần thuần: giải chuỗi layout từ cell lên root.
|
|
2
4
|
* Trả về thứ tự INNER→OUTER để render bọc dần (outermost cuối cùng bọc ngoài). */
|
|
3
5
|
export function layoutChain(layoutId, layouts) {
|
package/lib/core/nav.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Resolved Navigation — phần THUẦN (testable, không DOM/fetch).
|
|
2
4
|
* shouldIntercept: có nên chặn click để SPA-nav không. createPrefetchCache: cache props
|
|
3
5
|
* theo URL + dedup in-flight (prefetch on hover → nav cảm giác tức thì). */
|
package/lib/core/observe.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Observability — request log Ring Buffer CIRCULAR (#17).
|
|
2
4
|
* Trước: push + shift (shift O(n) mỗi record khi đầy). Giờ: mảng vòng + con trỏ ghi →
|
|
3
5
|
* record O(1) (không dời mảng). recent O(n) chỉ trên số phần tử yêu cầu. */
|
package/lib/core/presence.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Presence — ai đang online per topic (Trục 4g). Refcount theo id để chịu multi-tab/
|
|
2
4
|
* nhiều kết nối cùng user. Bản 1-node; distributed: chia sẻ qua NATS/Redis (gắn 4d). */
|
|
3
5
|
export function createPresence() {
|
package/lib/core/ratelimit.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Rate limiting (6b.F) — token bucket per key (vd IP/user/route). Thuần, clock injected.
|
|
2
4
|
* Bucket bound bằng LRU (maxKeys) → CHỐNG RÒ RAM khi nhiều IP (kẻ tấn công nhiều nguồn).
|
|
3
5
|
* Bản 1-node; distributed: chia sẻ bucket qua Redis (gắn 4d), cùng interface. */
|
package/lib/core/rendercache.js
CHANGED
package/lib/core/seo.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./core/resolver.ts";
|
|
|
5
5
|
export * from "./core/wiring.ts";
|
|
6
6
|
export * from "./core/auth.ts";
|
|
7
7
|
export * from "./core/env.ts";
|
|
8
|
+
export * from "./core/i18n.ts";
|
|
8
9
|
export * from "./core/seo.ts";
|
|
9
10
|
export * from "./core/broker.ts";
|
|
10
11
|
export * from "./core/presence.ts";
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* @nmvuong92/fluxe — entry ENGINE (server-side, không kéo node:sqlite).
|
|
2
4
|
* Subpath: /react (DX React), /client (rpc runtime), /jobs, /sqlite (cần node:sqlite). */
|
|
3
5
|
export * from "./core/engine.js"; // defineCell, Ctx, CellDef, Loader, Action, Hydration
|
|
@@ -7,6 +9,7 @@ export * from "./core/resolver.js"; // resolve, ResolutionProfile/Manifest, Cell
|
|
|
7
9
|
export * from "./core/wiring.js"; // backendFromManifest, backendsFromManifest
|
|
8
10
|
export * from "./core/auth.js"; // session HMAC, scrypt password, CSRF, RBAC
|
|
9
11
|
export * from "./core/env.js"; // loadEnv
|
|
12
|
+
export * from "./core/i18n.js"; // createI18n, resolveLocale, translate, makeT, t(key, vars)
|
|
10
13
|
export * from "./core/seo.js"; // renderHead, renderSitemap, renderRobots, HeadMeta
|
|
11
14
|
export * from "./core/broker.js"; // pub/sub
|
|
12
15
|
export * from "./core/presence.js"; // ai online theo topic
|
package/lib/react/DebugBar.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright (c) 2026 nmvuong92
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
/* <LocaleSwitch> — đổi ngôn ngữ qua link ?locale=xx (server set cookie + redirect).
|
|
5
|
+
* Render HTML thuần → chạy cả trên cell static (0 JS). Active theo `current` (ctx.locale). */
|
|
6
|
+
export function LocaleSwitch({ locales, current, labels, className, }) {
|
|
7
|
+
return (_jsx("span", { className: className ?? "locale-switch", children: locales.map((l) => (_jsx("a", { href: `?locale=${l}`, className: l === current ? "locale active" : "locale", "aria-current": l === current ? "true" : undefined, children: labels?.[l] ?? l.toUpperCase() }, l))) }));
|
|
8
|
+
}
|
package/lib/react/Nav.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright (c) 2026 nmvuong92
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
/* <Nav/> — render menu khai báo (app/nav.ts) bằng <Link>. Active set bởi shellScript (vanilla)
|
|
3
5
|
* theo path → chạy cả trên trang static. <Link> cho SPA nav trên trang island. */
|
|
4
6
|
import { Link } from "./Link";
|
package/lib/react/ThemeToggle.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright (c) 2026 nmvuong92
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
/* <ThemeToggle/> — nút đổi light/dark. Render HTML thuần + marker; logic do shellScript (vanilla)
|
|
3
5
|
* xử lý → chạy cả trên trang static (0 React JS). Không cần hydrate. */
|
|
4
6
|
export function ThemeToggle() {
|
package/lib/react/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { Link } from "./Link";
|
|
|
4
4
|
export { Nav, type NavItem } from "./Nav";
|
|
5
5
|
export { useTheme, type Theme } from "./theme";
|
|
6
6
|
export { ThemeToggle } from "./ThemeToggle";
|
|
7
|
+
export { LocaleSwitch } from "./LocaleSwitch";
|
|
7
8
|
export { shellScript } from "./shell";
|
|
8
9
|
export { DebugBar } from "./DebugBar";
|
|
9
10
|
export { debug, DebugStore } from "./store";
|
package/lib/react/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* @fluxe/react — devtools lite: data fetching + tracing + debug bar.
|
|
2
4
|
* Dùng: useQuery / useMutation trong cell; mount <DebugBar/> 1 lần. */
|
|
3
5
|
export { useQuery } from "./query";
|
|
@@ -6,6 +8,7 @@ export { Link } from "./Link";
|
|
|
6
8
|
export { Nav } from "./Nav";
|
|
7
9
|
export { useTheme } from "./theme";
|
|
8
10
|
export { ThemeToggle } from "./ThemeToggle";
|
|
11
|
+
export { LocaleSwitch } from "./LocaleSwitch";
|
|
9
12
|
export { shellScript } from "./shell";
|
|
10
13
|
export { DebugBar } from "./DebugBar";
|
|
11
14
|
export { debug, DebugStore } from "./store";
|
package/lib/react/mutation.js
CHANGED
package/lib/react/nav-client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Client nav controller — wire phần thuần (nav.ts) với DOM/history/fetch.
|
|
2
4
|
* KHÔNG import cells/router (giữ client bundle sạch server code) → "internal?" = cùng origin +
|
|
3
5
|
* server trả về cell hợp lệ. window/history/location chỉ đụng trong hàm (an toàn SSR import). */
|
package/lib/react/query.js
CHANGED
package/lib/react/shell.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const shellScript = "(function(){\nvar d=document.documentElement;\ntry{var t=localStorage.getItem('theme');if(t==='dark'||t==='light')d.dataset.theme=t;}catch(e){}\nfunction active(){var p=location.pathname;document.querySelectorAll('.nav-link').forEach(function(a){try{a.classList.toggle('active',new URL(a.href).pathname===p);}catch(e){}});}\nfunction wire(){var b=document.querySelector('[data-fluxe-theme-toggle]');if(b&&!b._w){b._w=1;b.addEventListener('click',function(){var n=d.dataset.theme==='dark'?'light':'dark';d.dataset.theme=n;try{localStorage.setItem('theme',n);}catch(e){}});}active();}\nif(document.readyState!=='loading')wire();else document.addEventListener('DOMContentLoaded',wire);\naddEventListener('fluxe:nav',active);addEventListener('popstate',active);\n})();";
|
|
1
|
+
export declare const shellScript = "(function(){\nvar d=document.documentElement;\ntry{var t=localStorage.getItem('theme');if(t==='dark'||t==='light')d.dataset.theme=t;}catch(e){}\nfunction active(){var p=location.pathname;document.querySelectorAll('.nav-link').forEach(function(a){try{a.classList.toggle('active',new URL(a.href).pathname===p);}catch(e){}});}\nfunction wire(){var b=document.querySelector('[data-fluxe-theme-toggle]');if(b&&!b._w){b._w=1;b.addEventListener('click',function(){var n=d.dataset.theme==='dark'?'light':'dark';d.dataset.theme=n;try{localStorage.setItem('theme',n);}catch(e){}document.cookie='theme='+n+';Path=/;Max-Age=31536000;SameSite=Lax';});}active();}\nif(document.readyState!=='loading')wire();else document.addEventListener('DOMContentLoaded',wire);\naddEventListener('fluxe:nav',active);addEventListener('popstate',active);\n})();";
|
package/lib/react/shell.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* shellScript — JS vanilla TÍ HON chạy trên MỌI trang (kể cả static 0-React-JS) để:
|
|
2
4
|
* - no-flash theme: đọc localStorage.theme → set data-theme ngay khi parse (trước content).
|
|
3
5
|
* - nút .theme-toggle: đổi light/dark + lưu localStorage (không cần React hydrate).
|
|
@@ -7,7 +9,7 @@ export const shellScript = `(function(){
|
|
|
7
9
|
var d=document.documentElement;
|
|
8
10
|
try{var t=localStorage.getItem('theme');if(t==='dark'||t==='light')d.dataset.theme=t;}catch(e){}
|
|
9
11
|
function active(){var p=location.pathname;document.querySelectorAll('.nav-link').forEach(function(a){try{a.classList.toggle('active',new URL(a.href).pathname===p);}catch(e){}});}
|
|
10
|
-
function wire(){var b=document.querySelector('[data-fluxe-theme-toggle]');if(b&&!b._w){b._w=1;b.addEventListener('click',function(){var n=d.dataset.theme==='dark'?'light':'dark';d.dataset.theme=n;try{localStorage.setItem('theme',n);}catch(e){}});}active();}
|
|
12
|
+
function wire(){var b=document.querySelector('[data-fluxe-theme-toggle]');if(b&&!b._w){b._w=1;b.addEventListener('click',function(){var n=d.dataset.theme==='dark'?'light':'dark';d.dataset.theme=n;try{localStorage.setItem('theme',n);}catch(e){}document.cookie='theme='+n+';Path=/;Max-Age=31536000;SameSite=Lax';});}active();}
|
|
11
13
|
if(document.readyState!=='loading')wire();else document.addEventListener('DOMContentLoaded',wire);
|
|
12
14
|
addEventListener('fluxe:nav',active);addEventListener('popstate',active);
|
|
13
15
|
})();`;
|
package/lib/react/store.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* @fluxe/react — debug store + tracing (lite). Mọi query/mutation/error ghi vào đây;
|
|
2
4
|
* DebugBar subscribe để hiển thị "full flow". Immutable update → useSyncExternalStore re-render. */
|
|
3
5
|
const MAX = 50;
|
package/lib/react/theme.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
/* Theme — light/dark/auto qua data-theme trên <html> + localStorage. SSR-safe (window chỉ
|
|
2
4
|
* đụng trong effect/handler). "auto" = theo OS (prefers-color-scheme) → static cell 0 JS vẫn
|
|
3
5
|
* dark được nhờ CSS @media, không cần script. */
|
package/lib/server_factory.d.ts
CHANGED
|
@@ -8,5 +8,8 @@ type LayoutEntry = LayoutMeta & {
|
|
|
8
8
|
}) => any;
|
|
9
9
|
};
|
|
10
10
|
type LayoutMap = Record<string, LayoutEntry>;
|
|
11
|
-
|
|
11
|
+
import { type I18n } from "./core/i18n.ts";
|
|
12
|
+
export declare function makeServer(manifest: ResolutionManifest, cells: CellDef<any, any>[], layouts?: LayoutMap, opts?: {
|
|
13
|
+
i18n?: I18n;
|
|
14
|
+
}): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
12
15
|
export {};
|
package/lib/server_factory.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 nmvuong92
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
import http from "node:http";
|
|
2
4
|
import { readFileSync, existsSync } from "node:fs";
|
|
3
5
|
import { PassThrough } from "node:stream";
|
|
@@ -18,6 +20,7 @@ import { createPresence } from "./core/presence.js";
|
|
|
18
20
|
import { etagOf, etagMatches } from "./core/etag.js";
|
|
19
21
|
import { createRenderCache } from "./core/rendercache.js";
|
|
20
22
|
import { parseChaos } from "./core/chaos.js";
|
|
23
|
+
import { resolveLocale, makeT } from "./core/i18n.js";
|
|
21
24
|
import { createMemoryBackend } from "./backends/memory.js";
|
|
22
25
|
import { createHttpBackend } from "./backends/http.js";
|
|
23
26
|
// Build backend theo ngôn ngữ (cho live swap trong devtools).
|
|
@@ -57,9 +60,10 @@ function sendError(res, wantsJson, err) {
|
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
// Phần head (trước body) và tail (sau body) — body được STREAM ở giữa.
|
|
60
|
-
function shellHead(cell, data) {
|
|
63
|
+
function shellHead(cell, data, lang = "vi", theme = "") {
|
|
61
64
|
const headHtml = renderHead(cell.head ? cell.head(data) : {});
|
|
62
|
-
|
|
65
|
+
const themeAttr = theme ? ` data-theme="${theme}"` : ""; // theme-SSR: no-flash ngay lần đầu
|
|
66
|
+
return `<!doctype html><html lang="${lang}"${themeAttr}><head><meta charset="utf-8">${headHtml}</head><body><div id="root">`;
|
|
63
67
|
}
|
|
64
68
|
function shellTail(cell, data, shipClientJs) {
|
|
65
69
|
const island = shipClientJs
|
|
@@ -83,7 +87,8 @@ function renderBodyToString(node) {
|
|
|
83
87
|
});
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
|
-
export function makeServer(manifest, cells, layouts = {}) {
|
|
90
|
+
export function makeServer(manifest, cells, layouts = {}, opts = {}) {
|
|
91
|
+
const i18n = opts.i18n;
|
|
87
92
|
// Cells được TIÊM từ app (DI) — engine không import ngược vào app/. Thêm trang = sửa app/app.ts.
|
|
88
93
|
const matchRoute = makeRouter(cells);
|
|
89
94
|
const byId = new Map(cells.map((c) => [c.id, c]));
|
|
@@ -106,7 +111,20 @@ export function makeServer(manifest, cells, layouts = {}) {
|
|
|
106
111
|
// CSRF double-submit: đảm bảo có cookie csrf (đặt nếu chưa) — client gửi lại qua header.
|
|
107
112
|
let csrf = cookies.csrf;
|
|
108
113
|
const csrfCookie = csrf ? "" : (csrf = newCsrfToken(), `csrf=${csrf}; Path=/; SameSite=Lax`);
|
|
114
|
+
// Resolved Shell: locale (i18n) + theme — giải từ cookie/header, đưa vào loader + <html>.
|
|
115
|
+
const locale = i18n ? resolveLocale(i18n, { cookie: cookies.locale, acceptLanguage: req.headers["accept-language"] }) : "vi";
|
|
116
|
+
const t = i18n ? makeT(i18n, locale) : (k) => k;
|
|
117
|
+
const theme = cookies.theme === "dark" || cookies.theme === "light" ? cookies.theme : "";
|
|
109
118
|
try {
|
|
119
|
+
// Đổi ngôn ngữ qua ?locale=xx → set cookie + redirect (chạy cả trên cell static, 0 JS).
|
|
120
|
+
{
|
|
121
|
+
const ql = url.searchParams.get("locale");
|
|
122
|
+
if (i18n && ql && i18n.locales.includes(ql)) {
|
|
123
|
+
url.searchParams.delete("locale");
|
|
124
|
+
res.writeHead(303, { "set-cookie": `locale=${ql}; Path=/; SameSite=Lax`, location: url.pathname + (url.search || "") });
|
|
125
|
+
return res.end();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
110
128
|
if (url.pathname === "/client.js") {
|
|
111
129
|
if (clientJs === undefined && existsSync("./dist/client.js"))
|
|
112
130
|
clientJs = readFileSync("./dist/client.js");
|
|
@@ -241,7 +259,7 @@ export function makeServer(manifest, cells, layouts = {}) {
|
|
|
241
259
|
if (cell.requireRole && !hasRole(session, cell.requireRole)) {
|
|
242
260
|
throw new FluxeError("forbidden", `Cần quyền '${cell.requireRole}'`, 403);
|
|
243
261
|
}
|
|
244
|
-
const data = await cell.loader({ input: match.params, backend: backendFor(cell.id), session });
|
|
262
|
+
const data = await cell.loader({ input: match.params, backend: backendFor(cell.id), session, locale, t });
|
|
245
263
|
if (wantsJson) {
|
|
246
264
|
const body = JSON.stringify({ cell: cell.id, data, layout: cell.layout });
|
|
247
265
|
const etag = etagOf(body); // render cache: 304 nếu props không đổi
|
|
@@ -253,8 +271,9 @@ export function makeServer(manifest, cells, layouts = {}) {
|
|
|
253
271
|
return res.end(body);
|
|
254
272
|
}
|
|
255
273
|
let node = h(cell.view, { data });
|
|
274
|
+
const shellCtx = { locale, t, theme, path: url.pathname }; // Resolved Shell ctx cho layout
|
|
256
275
|
for (const id of layoutChain(cell.layout, layouts)) { // inner→outer: bọc dần
|
|
257
|
-
node = h(layouts[id].component, { children: node });
|
|
276
|
+
node = h(layouts[id].component, { children: node, ctx: shellCtx });
|
|
258
277
|
}
|
|
259
278
|
const shipClientJs = manifest.cells[cell.id]?.render.shipClientJs ?? false;
|
|
260
279
|
const pageHeaders = { "content-type": "text/html; charset=utf-8" };
|
|
@@ -263,10 +282,10 @@ export function makeServer(manifest, cells, layouts = {}) {
|
|
|
263
282
|
// Ý B — render cache cell static: render 1 lần → giữ Buffer → ghi lại (zero-copy).
|
|
264
283
|
// Gate etag(data): data đổi ⇒ miss ⇒ render lại (không trả HTML cũ). Chỉ cell static & public.
|
|
265
284
|
if (manifest.cells[cell.id]?.render.mode === "static" && cell.cache !== false && !cell.requireAuth && !cell.requireRole) {
|
|
266
|
-
const etag = etagOf(JSON.stringify(data));
|
|
285
|
+
const etag = etagOf(JSON.stringify(data) + "|" + locale + "|" + theme); // lang/theme đổi → bust cache
|
|
267
286
|
let hit = renderCache.get(url.pathname);
|
|
268
287
|
if (!hit || hit.etag !== etag) {
|
|
269
|
-
const full = shellHead(cell, data) + await renderBodyToString(node) + shellTail(cell, data, shipClientJs);
|
|
288
|
+
const full = shellHead(cell, data, locale, theme) + await renderBodyToString(node) + shellTail(cell, data, shipClientJs);
|
|
270
289
|
hit = { etag, buf: Buffer.from(full, "utf8") };
|
|
271
290
|
renderCache.set(url.pathname, hit);
|
|
272
291
|
}
|
|
@@ -275,7 +294,7 @@ export function makeServer(manifest, cells, layouts = {}) {
|
|
|
275
294
|
}
|
|
276
295
|
// Streaming SSR: gửi head ngay → stream body (Suspense chảy dần) → tail khi xong.
|
|
277
296
|
res.writeHead(200, pageHeaders);
|
|
278
|
-
res.write(shellHead(cell, data));
|
|
297
|
+
res.write(shellHead(cell, data, locale, theme));
|
|
279
298
|
const through = new PassThrough();
|
|
280
299
|
through.on("data", (c) => res.write(c));
|
|
281
300
|
through.on("end", () => { res.write(shellTail(cell, data, shipClientJs)); res.end(); });
|
package/package.json
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmvuong92/fluxe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "fluxe — khung fullstack tối giản polyglot (RCA: Resolved Cell Architecture).",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "nmvuong92",
|
|
5
7
|
"type": "module",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/nmvuong92/fluxe.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/nmvuong92/fluxe#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/nmvuong92/fluxe/issues"
|
|
15
|
+
},
|
|
6
16
|
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"./
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./react": {
|
|
22
|
+
"types": "./lib/react/index.d.ts",
|
|
23
|
+
"default": "./lib/react/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./client": {
|
|
26
|
+
"types": "./lib/core/client.d.ts",
|
|
27
|
+
"default": "./lib/core/client.js"
|
|
28
|
+
},
|
|
29
|
+
"./jobs": {
|
|
30
|
+
"types": "./lib/core/jobs.d.ts",
|
|
31
|
+
"default": "./lib/core/jobs.js"
|
|
32
|
+
},
|
|
33
|
+
"./sqlite": {
|
|
34
|
+
"types": "./lib/backends/sqlite.d.ts",
|
|
35
|
+
"default": "./lib/backends/sqlite.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"lib",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE",
|
|
42
|
+
"NOTICE"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
12
46
|
},
|
|
13
|
-
"files": ["lib", "README.md"],
|
|
14
|
-
"publishConfig": { "access": "public" },
|
|
15
47
|
"scripts": {
|
|
16
48
|
"typecheck": "tsc --noEmit",
|
|
17
49
|
"sync": "tsx scripts/sync.ts",
|
|
@@ -25,9 +57,26 @@
|
|
|
25
57
|
"resolve": "npm run sync && tsx scripts/resolve.ts",
|
|
26
58
|
"fx": "tsx bin/fx.ts",
|
|
27
59
|
"build": "rm -rf lib && tsc -p tsconfig.build.json",
|
|
28
|
-
"prepublishOnly": "npm run build"
|
|
60
|
+
"prepublishOnly": "npm run build",
|
|
61
|
+
"release": "npm run test:all && npm version patch -m 'release: v%s' && git push --follow-tags",
|
|
62
|
+
"release:minor": "npm run test:all && npm version minor -m 'release: v%s' && git push --follow-tags",
|
|
63
|
+
"release:major": "npm run test:all && npm version major -m 'release: v%s' && git push --follow-tags"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"zod": "^3"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"react": "^18 || ^19",
|
|
70
|
+
"react-dom": "^18 || ^19"
|
|
29
71
|
},
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"typescript": "^5",
|
|
74
|
+
"tsx": "^4",
|
|
75
|
+
"esbuild": "^0.23",
|
|
76
|
+
"react": "^18",
|
|
77
|
+
"react-dom": "^18",
|
|
78
|
+
"@types/node": "^20",
|
|
79
|
+
"@types/react": "^18",
|
|
80
|
+
"@types/react-dom": "^18"
|
|
81
|
+
}
|
|
33
82
|
}
|