vinojs 0.1.0 → 0.1.2
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/client.mjs +1 -1
- package/dist/{compile-Lxl_tdxL.mjs → compile-glNMkyyx.mjs} +3 -47
- package/dist/compile-glNMkyyx.mjs.map +1 -0
- package/dist/{definePage-Ba4r-TFh.mjs → definePage--9Pz7rHs.mjs} +29 -7
- package/dist/definePage--9Pz7rHs.mjs.map +1 -0
- package/dist/defineServerFn-H-bz7xBX.mjs +47 -0
- package/dist/defineServerFn-H-bz7xBX.mjs.map +1 -0
- package/dist/factory-CVT0-OZw.d.mts +187 -0
- package/dist/factory-CVT0-OZw.d.mts.map +1 -0
- package/dist/factory.d.mts +2 -0
- package/dist/factory.mjs +153 -0
- package/dist/factory.mjs.map +1 -0
- package/dist/vino.d.mts +4 -103
- package/dist/vino.d.mts.map +1 -1
- package/dist/vino.mjs +8 -3
- package/dist/vino.mjs.map +1 -1
- package/dist/vite.mjs +3 -2
- package/dist/vite.mjs.map +1 -1
- package/package.json +5 -1
- package/dist/compile-Lxl_tdxL.mjs.map +0 -1
- package/dist/definePage-Ba4r-TFh.mjs.map +0 -1
- package/examples/basic/dist/client/.assetsignore +0 -2
- package/examples/basic/dist/client/about.html +0 -1
- package/examples/basic/dist/client/admin.html +0 -1
- package/examples/basic/dist/client/assets/Counter-BvqMZKON.js +0 -1
- package/examples/basic/dist/client/assets/_slug_-CYpOSbrn.js +0 -1
- package/examples/basic/dist/client/assets/about-BZXRzUyv.js +0 -1
- package/examples/basic/dist/client/assets/admin-DRE7uh2s.js +0 -1
- package/examples/basic/dist/client/assets/client-B6nFkut5.js +0 -1
- package/examples/basic/dist/client/assets/client-pages-Bc6cNZAm.js +0 -2
- package/examples/basic/dist/client/assets/components-DX9r6vHn.js +0 -1
- package/examples/basic/dist/client/assets/components-DsWJ6F73.js +0 -2
- package/examples/basic/dist/client/assets/counter-DBpvln_F.js +0 -1
- package/examples/basic/dist/client/assets/dom-B5sHIJ1E.js +0 -1
- package/examples/basic/dist/client/assets/honoto-9UtdLp4J.js +0 -33
- package/examples/basic/dist/client/assets/honoto-client-DEh86_WZ.css +0 -1
- package/examples/basic/dist/client/assets/honoto-client.js +0 -2
- package/examples/basic/dist/client/assets/hooks-Cz6AT21d.js +0 -1
- package/examples/basic/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
- package/examples/basic/dist/client/counter.html +0 -1
- package/examples/basic/dist/client/index.html +0 -1
- package/examples/basic/dist/client/jobs.html +0 -1
- package/examples/basic/dist/ssr/.vite/manifest.json +0 -140
- package/examples/basic/dist/ssr/assets/_slug_-CY3-kffX.js +0 -46
- package/examples/basic/dist/ssr/assets/about-CTDjNhkO.js +0 -15
- package/examples/basic/dist/ssr/assets/admin-DvS-UGJx.js +0 -26
- package/examples/basic/dist/ssr/assets/constants-UoriGYcX-CUecBFMT.js +0 -6
- package/examples/basic/dist/ssr/assets/counter-DfIbc9Sp.js +0 -30
- package/examples/basic/dist/ssr/assets/honoto-CA313cVy.js +0 -2129
- package/examples/basic/dist/ssr/assets/jobs-D9hh-UO9.js +0 -42
- package/examples/basic/dist/ssr/assets/jsx-CgYLQazd.js +0 -1080
- package/examples/basic/dist/ssr/assets/jsx-dev-runtime-BlUda7H8.js +0 -742
- package/examples/basic/dist/ssr/assets/jsx-renderer-CzZcZPnS.js +0 -65
- package/examples/basic/dist/ssr/assets/layout-DYvLwr2u.js +0 -53
- package/examples/basic/dist/ssr/assets/pages-DB6jeyrt.js +0 -53
- package/examples/basic/dist/ssr/assets/rolldown-runtime-D7D4PA-g.js +0 -13
- package/examples/basic/dist/ssr/assets/ssr-hooks-CBQr0cdH.js +0 -7
- package/examples/basic/dist/ssr/index.js +0 -22
- package/examples/basic/dist/ssr/wrangler.json +0 -1
- package/examples/full/dist/client/.assetsignore +0 -2
- package/examples/full/dist/client/assets/BookmarkButton-py0xGxgl.js +0 -1
- package/examples/full/dist/client/assets/_slug_-DZUFsE9O.js +0 -1
- package/examples/full/dist/client/assets/auth-client-D2Wtuobe.js +0 -1
- package/examples/full/dist/client/assets/bun-sqlite-dialect-C7ftEUSI-CsHdUKBY.js +0 -1
- package/examples/full/dist/client/assets/client-B6nFkut5.js +0 -1
- package/examples/full/dist/client/assets/client-pages-fshKs747.js +0 -2
- package/examples/full/dist/client/assets/components-DX9r6vHn.js +0 -1
- package/examples/full/dist/client/assets/components-S_-rWrKi.js +0 -2
- package/examples/full/dist/client/assets/d1-sqlite-dialect-BZmaVTp8-FPCaMZqX.js +0 -1
- package/examples/full/dist/client/assets/default-query-compiler-CUdqIu1h.js +0 -1
- package/examples/full/dist/client/assets/dist-BoGTNvkC.js +0 -1
- package/examples/full/dist/client/assets/dom-DCd3wYW7.js +0 -1
- package/examples/full/dist/client/assets/factory-Bgf4EtLx.js +0 -8
- package/examples/full/dist/client/assets/honoto-client-BSvNAnxN.css +0 -1
- package/examples/full/dist/client/assets/honoto-client.js +0 -2
- package/examples/full/dist/client/assets/hooks-Cz6AT21d.js +0 -1
- package/examples/full/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
- package/examples/full/dist/client/assets/kysely-adapter-BHhasAnc.js +0 -1
- package/examples/full/dist/client/assets/kysely-migration-tables-DFfmKhq--U5ujlMwE.js +0 -1
- package/examples/full/dist/client/assets/node-sqlite-dialect-DJDXH5Ot.js +0 -1
- package/examples/full/dist/client/assets/pages-CUQx6Eus.js +0 -1
- package/examples/full/dist/client/assets/saved-jIi74ncJ.js +0 -1
- package/examples/full/dist/client/assets/session-B-accyM3.js +0 -611
- package/examples/full/dist/client/assets/sign-in-BelI3gSs.js +0 -1
- package/examples/full/dist/client/assets/sign-up-pR94lfdu.js +0 -1
- package/examples/full/dist/client/index.html +0 -1
- package/examples/full/dist/client/saved.html +0 -1
- package/examples/full/dist/client/sign-in.html +0 -1
- package/examples/full/dist/client/sign-up.html +0 -1
- package/examples/full/dist/ssr/.dev.vars +0 -1
- package/examples/full/dist/ssr/.vite/manifest.json +0 -219
- package/examples/full/dist/ssr/assets/BookmarkButton-KS7z5_vi.js +0 -298
- package/examples/full/dist/ssr/assets/_slug_-rRStRaAN.js +0 -89
- package/examples/full/dist/ssr/assets/auth-DSFZ4iak.js +0 -31434
- package/examples/full/dist/ssr/assets/auth-client-BFSBVoML.js +0 -894
- package/examples/full/dist/ssr/assets/bun-sqlite-dialect-C7ftEUSI-BeXpIqKl.js +0 -162
- package/examples/full/dist/ssr/assets/compiled-query-DmoyCh28.js +0 -8410
- package/examples/full/dist/ssr/assets/d1-sqlite-dialect-BZmaVTp8-CjJdvL94.js +0 -114
- package/examples/full/dist/ssr/assets/default-query-compiler-D7xOzCCJ.js +0 -1727
- package/examples/full/dist/ssr/assets/dist-LmmDoNdk.js +0 -6832
- package/examples/full/dist/ssr/assets/dist-kFDN1l4Z.js +0 -342
- package/examples/full/dist/ssr/assets/factory-AD6s9SIW.js +0 -2079
- package/examples/full/dist/ssr/assets/jsx-renderer-mMLf5XLN.js +0 -1926
- package/examples/full/dist/ssr/assets/kysely-adapter-BCLenpM8.js +0 -2
- package/examples/full/dist/ssr/assets/kysely-migration-tables-DFfmKhq--BtVr6hRe.js +0 -17
- package/examples/full/dist/ssr/assets/layout-mVA7qP4j.js +0 -44
- package/examples/full/dist/ssr/assets/node-sqlite-dialect-D-wtYAD7.js +0 -162
- package/examples/full/dist/ssr/assets/pages-Do5kR_Ia.js +0 -147
- package/examples/full/dist/ssr/assets/saved-Dr4pP6B5.js +0 -111
- package/examples/full/dist/ssr/assets/session-BvIpX7tr.js +0 -13
- package/examples/full/dist/ssr/assets/sign-in-22pzTnJE.js +0 -115
- package/examples/full/dist/ssr/assets/sign-up-CN4j8Qg1.js +0 -117
- package/examples/full/dist/ssr/assets/sqlite-adapter-DVlms5wO.js +0 -79
- package/examples/full/dist/ssr/index.js +0 -97
- package/examples/full/dist/ssr/wrangler.json +0 -1
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@better-auth+kysely-adapter@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@bet_5fd430926dca70baa91453aa7860f913/node_modules/@better-auth/kysely-adapter/dist/kysely-migration-tables-DFfmKhq-.mjs
|
|
2
|
-
/**
|
|
3
|
-
* Kysely's internal migration table names, mirrored as local constants.
|
|
4
|
-
*
|
|
5
|
-
* Kysely 0.29 moved these from its main entry to the `kysely/migration`
|
|
6
|
-
* subpath (which 0.28 lacks), and the main entry now exports only type stubs
|
|
7
|
-
* with no runtime value, which breaks strict ESM bundlers.
|
|
8
|
-
*
|
|
9
|
-
* The values are stable parts of Kysely's public migration contract. Mirroring
|
|
10
|
-
* them allows the SQLite dialects to support both Kysely 0.28 and 0.29.
|
|
11
|
-
*
|
|
12
|
-
* TODO: Import these from `kysely/migration` after dropping Kysely 0.28.
|
|
13
|
-
*/
|
|
14
|
-
var DEFAULT_MIGRATION_TABLE = "kysely_migration";
|
|
15
|
-
var DEFAULT_MIGRATION_LOCK_TABLE = "kysely_migration_lock";
|
|
16
|
-
//#endregion
|
|
17
|
-
export { DEFAULT_MIGRATION_TABLE as n, DEFAULT_MIGRATION_LOCK_TABLE as t };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { n as useRequestContext, o as jsxDEV, s as Fragment } from "./jsx-renderer-mMLf5XLN.js";
|
|
2
|
-
//#region src/layout/index.tsx
|
|
3
|
-
function Layout({ children, data }) {
|
|
4
|
-
const pathname = useRequestContext().req.path;
|
|
5
|
-
const user = data?.user;
|
|
6
|
-
const link = (href, label) => {
|
|
7
|
-
const active = href === "/" ? pathname === "/" : pathname.startsWith(href);
|
|
8
|
-
return /* @__PURE__ */ jsxDEV("a", {
|
|
9
|
-
href,
|
|
10
|
-
class: `text-stone-100 no-underline border-transparent border-b-2 hover:border-current ${active ? "border-current" : ""}`,
|
|
11
|
-
children: label
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
return /* @__PURE__ */ jsxDEV("html", { children: [/* @__PURE__ */ jsxDEV("head", { children: [
|
|
15
|
-
/* @__PURE__ */ jsxDEV("meta", { charset: "utf-8" }),
|
|
16
|
-
/* @__PURE__ */ jsxDEV("meta", {
|
|
17
|
-
name: "viewport",
|
|
18
|
-
content: "width=device-width, initial-scale=1"
|
|
19
|
-
}),
|
|
20
|
-
/* @__PURE__ */ jsxDEV("title", { children: "Honoto Store" })
|
|
21
|
-
] }), /* @__PURE__ */ jsxDEV("body", {
|
|
22
|
-
class: "bg-stone-100 text-stone-900 min-h-screen",
|
|
23
|
-
children: [/* @__PURE__ */ jsxDEV("nav", {
|
|
24
|
-
class: "flex flex-wrap items-center gap-4 p-4 bg-stone-900",
|
|
25
|
-
children: [/* @__PURE__ */ jsxDEV("a", {
|
|
26
|
-
href: "/",
|
|
27
|
-
class: "text-stone-100 font-semibold no-underline tracking-wide",
|
|
28
|
-
children: "Honoto Store"
|
|
29
|
-
}), /* @__PURE__ */ jsxDEV("div", {
|
|
30
|
-
class: "flex flex-wrap gap-4 text-sm items-center",
|
|
31
|
-
children: [
|
|
32
|
-
link("/", "Feed"),
|
|
33
|
-
link("/saved", "Saved"),
|
|
34
|
-
user ? /* @__PURE__ */ jsxDEV("span", {
|
|
35
|
-
class: "text-stone-400",
|
|
36
|
-
children: user.name
|
|
37
|
-
}) : /* @__PURE__ */ jsxDEV(Fragment, { children: [link("/sign-in", "Sign in"), link("/sign-up", "Sign up")] })
|
|
38
|
-
]
|
|
39
|
-
})]
|
|
40
|
-
}), children]
|
|
41
|
-
})] });
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { Layout as default };
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { t as DefaultQueryCompiler } from "./default-query-compiler-D7xOzCCJ.js";
|
|
2
|
-
import { n as sql, t as CompiledQuery } from "./compiled-query-DmoyCh28.js";
|
|
3
|
-
import { n as DEFAULT_MIGRATION_TABLE, t as DEFAULT_MIGRATION_LOCK_TABLE } from "./kysely-migration-tables-DFfmKhq--BtVr6hRe.js";
|
|
4
|
-
//#region ../../node_modules/.pnpm/@better-auth+kysely-adapter@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@bet_5fd430926dca70baa91453aa7860f913/node_modules/@better-auth/kysely-adapter/dist/node-sqlite-dialect.mjs
|
|
5
|
-
var NodeSqliteAdapter = class {
|
|
6
|
-
get supportsCreateIfNotExists() {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
get supportsTransactionalDdl() {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
get supportsReturning() {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
async acquireMigrationLock() {}
|
|
16
|
-
async releaseMigrationLock() {}
|
|
17
|
-
get supportsOutput() {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var NodeSqliteDriver = class {
|
|
22
|
-
#config;
|
|
23
|
-
#connectionMutex = new ConnectionMutex();
|
|
24
|
-
#db;
|
|
25
|
-
#connection;
|
|
26
|
-
constructor(config) {
|
|
27
|
-
this.#config = { ...config };
|
|
28
|
-
}
|
|
29
|
-
async init() {
|
|
30
|
-
this.#db = this.#config.database;
|
|
31
|
-
this.#connection = new NodeSqliteConnection(this.#db);
|
|
32
|
-
if (this.#config.onCreateConnection) await this.#config.onCreateConnection(this.#connection);
|
|
33
|
-
}
|
|
34
|
-
async acquireConnection() {
|
|
35
|
-
await this.#connectionMutex.lock();
|
|
36
|
-
return this.#connection;
|
|
37
|
-
}
|
|
38
|
-
async beginTransaction(connection) {
|
|
39
|
-
await connection.executeQuery(CompiledQuery.raw("begin"));
|
|
40
|
-
}
|
|
41
|
-
async commitTransaction(connection) {
|
|
42
|
-
await connection.executeQuery(CompiledQuery.raw("commit"));
|
|
43
|
-
}
|
|
44
|
-
async rollbackTransaction(connection) {
|
|
45
|
-
await connection.executeQuery(CompiledQuery.raw("rollback"));
|
|
46
|
-
}
|
|
47
|
-
async releaseConnection() {
|
|
48
|
-
this.#connectionMutex.unlock();
|
|
49
|
-
}
|
|
50
|
-
async destroy() {
|
|
51
|
-
this.#db?.close();
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var NodeSqliteConnection = class {
|
|
55
|
-
#db;
|
|
56
|
-
constructor(db) {
|
|
57
|
-
this.#db = db;
|
|
58
|
-
}
|
|
59
|
-
executeQuery(compiledQuery) {
|
|
60
|
-
const { sql, parameters } = compiledQuery;
|
|
61
|
-
const stmt = this.#db.prepare(sql);
|
|
62
|
-
const params = parameters;
|
|
63
|
-
if (stmt.columns().length > 0) return Promise.resolve({ rows: stmt.all(...params) });
|
|
64
|
-
const { changes, lastInsertRowid } = stmt.run(...params);
|
|
65
|
-
return Promise.resolve({
|
|
66
|
-
rows: [],
|
|
67
|
-
numAffectedRows: BigInt(changes),
|
|
68
|
-
insertId: typeof lastInsertRowid === "bigint" ? lastInsertRowid : BigInt(lastInsertRowid)
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
async *streamQuery() {
|
|
72
|
-
throw new Error("Streaming query is not supported by SQLite driver.");
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var ConnectionMutex = class {
|
|
76
|
-
#promise;
|
|
77
|
-
#resolve;
|
|
78
|
-
async lock() {
|
|
79
|
-
while (this.#promise !== void 0) await this.#promise;
|
|
80
|
-
this.#promise = new Promise((resolve) => {
|
|
81
|
-
this.#resolve = resolve;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
unlock() {
|
|
85
|
-
const resolve = this.#resolve;
|
|
86
|
-
this.#promise = void 0;
|
|
87
|
-
this.#resolve = void 0;
|
|
88
|
-
resolve?.();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
var NodeSqliteIntrospector = class {
|
|
92
|
-
#db;
|
|
93
|
-
constructor(db) {
|
|
94
|
-
this.#db = db;
|
|
95
|
-
}
|
|
96
|
-
async getSchemas() {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
async getTables(options = { withInternalKyselyTables: false }) {
|
|
100
|
-
let query = this.#db.selectFrom("sqlite_schema").where("type", "=", "table").where("name", "not like", "sqlite_%").select("name").$castTo();
|
|
101
|
-
if (!options.withInternalKyselyTables) query = query.where("name", "!=", DEFAULT_MIGRATION_TABLE).where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
|
102
|
-
const tables = await query.execute();
|
|
103
|
-
return Promise.all(tables.map(({ name }) => this.#getTableMetadata(name)));
|
|
104
|
-
}
|
|
105
|
-
async getMetadata(options) {
|
|
106
|
-
return { tables: await this.getTables(options) };
|
|
107
|
-
}
|
|
108
|
-
async #getTableMetadata(table) {
|
|
109
|
-
const db = this.#db;
|
|
110
|
-
const autoIncrementCol = (await db.selectFrom("sqlite_master").where("name", "=", table).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((it) => it.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g, "");
|
|
111
|
-
return {
|
|
112
|
-
name: table,
|
|
113
|
-
columns: (await db.selectFrom(sql`pragma_table_info(${table})`.as("table_info")).select([
|
|
114
|
-
"name",
|
|
115
|
-
"type",
|
|
116
|
-
"notnull",
|
|
117
|
-
"dflt_value"
|
|
118
|
-
]).execute()).map((col) => ({
|
|
119
|
-
name: col.name,
|
|
120
|
-
dataType: col.type,
|
|
121
|
-
isNullable: !col.notnull,
|
|
122
|
-
isAutoIncrementing: col.name === autoIncrementCol,
|
|
123
|
-
hasDefaultValue: col.dflt_value != null
|
|
124
|
-
})),
|
|
125
|
-
isView: false
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var NodeSqliteQueryCompiler = class extends DefaultQueryCompiler {
|
|
130
|
-
getCurrentParameterPlaceholder() {
|
|
131
|
-
return "?";
|
|
132
|
-
}
|
|
133
|
-
getLeftIdentifierWrapper() {
|
|
134
|
-
return "\"";
|
|
135
|
-
}
|
|
136
|
-
getRightIdentifierWrapper() {
|
|
137
|
-
return "\"";
|
|
138
|
-
}
|
|
139
|
-
getAutoIncrement() {
|
|
140
|
-
return "autoincrement";
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
var NodeSqliteDialect = class {
|
|
144
|
-
#config;
|
|
145
|
-
constructor(config) {
|
|
146
|
-
this.#config = { ...config };
|
|
147
|
-
}
|
|
148
|
-
createDriver() {
|
|
149
|
-
return new NodeSqliteDriver(this.#config);
|
|
150
|
-
}
|
|
151
|
-
createQueryCompiler() {
|
|
152
|
-
return new NodeSqliteQueryCompiler();
|
|
153
|
-
}
|
|
154
|
-
createAdapter() {
|
|
155
|
-
return new NodeSqliteAdapter();
|
|
156
|
-
}
|
|
157
|
-
createIntrospector(db) {
|
|
158
|
-
return new NodeSqliteIntrospector(db);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
//#endregion
|
|
162
|
-
export { NodeSqliteDialect };
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { a as useState, i as useRef, o as jsxDEV, r as useEffect } from "./jsx-renderer-mMLf5XLN.js";
|
|
2
|
-
import { d as eq, f as inArray, g as definePage, i as bookmarks, l as desc, n as createDb, r as articles, u as and } from "./auth-DSFZ4iak.js";
|
|
3
|
-
import { n as api, t as BookmarkButton_default } from "./BookmarkButton-KS7z5_vi.js";
|
|
4
|
-
import { t as getSessionUser } from "./session-BvIpX7tr.js";
|
|
5
|
-
function Feed({ data }) {
|
|
6
|
-
const [items, setItems] = useState(data.items);
|
|
7
|
-
const [cursor, setCursor] = useState(data.nextCursor);
|
|
8
|
-
const [loading, setLoading] = useState(false);
|
|
9
|
-
const [bookmarkedIds, setBookmarkedIds] = useState(data.bookmarkedIds);
|
|
10
|
-
const cursorRef = useRef(cursor);
|
|
11
|
-
const loadingRef = useRef(loading);
|
|
12
|
-
const itemsRef = useRef(items);
|
|
13
|
-
const sentinelRef = useRef(null);
|
|
14
|
-
cursorRef.current = cursor;
|
|
15
|
-
loadingRef.current = loading;
|
|
16
|
-
itemsRef.current = items;
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const el = sentinelRef.current;
|
|
19
|
-
if (!el) return;
|
|
20
|
-
const observer = new IntersectionObserver((entries) => {
|
|
21
|
-
if (!entries[0]?.isIntersecting) return;
|
|
22
|
-
loadMore();
|
|
23
|
-
}, { rootMargin: "240px" });
|
|
24
|
-
observer.observe(el);
|
|
25
|
-
return () => observer.disconnect();
|
|
26
|
-
}, []);
|
|
27
|
-
async function loadMore() {
|
|
28
|
-
const currentCursor = cursorRef.current;
|
|
29
|
-
if (!currentCursor || loadingRef.current) return;
|
|
30
|
-
loadingRef.current = true;
|
|
31
|
-
setLoading(true);
|
|
32
|
-
try {
|
|
33
|
-
const res = await api.api.articles.$get({ query: {
|
|
34
|
-
cursor: currentCursor,
|
|
35
|
-
limit: String(8)
|
|
36
|
-
} });
|
|
37
|
-
if (!res.ok) return;
|
|
38
|
-
const json = await res.json();
|
|
39
|
-
const nextItems = [...itemsRef.current, ...json.items];
|
|
40
|
-
itemsRef.current = nextItems;
|
|
41
|
-
setItems(nextItems);
|
|
42
|
-
cursorRef.current = json.nextCursor;
|
|
43
|
-
setCursor(json.nextCursor);
|
|
44
|
-
if (data.user) {
|
|
45
|
-
const bm = await api.api.bookmarks.$get();
|
|
46
|
-
if (bm.ok) {
|
|
47
|
-
const body = await bm.json();
|
|
48
|
-
setBookmarkedIds(body.articleIds);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} finally {
|
|
52
|
-
loadingRef.current = false;
|
|
53
|
-
setLoading(false);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return /* @__PURE__ */ jsxDEV("main", {
|
|
57
|
-
class: "max-w-2xl mx-auto px-4 py-8",
|
|
58
|
-
children: [
|
|
59
|
-
/* @__PURE__ */ jsxDEV("header", {
|
|
60
|
-
class: "mb-8",
|
|
61
|
-
children: [/* @__PURE__ */ jsxDEV("h1", {
|
|
62
|
-
class: "text-3xl font-semibold tracking-tight",
|
|
63
|
-
children: "Articles"
|
|
64
|
-
}), /* @__PURE__ */ jsxDEV("p", {
|
|
65
|
-
class: "text-stone-600 mt-2",
|
|
66
|
-
children: "Scroll the store feed. Sign in to save pieces you want to revisit."
|
|
67
|
-
})]
|
|
68
|
-
}),
|
|
69
|
-
/* @__PURE__ */ jsxDEV("ul", {
|
|
70
|
-
class: "flex flex-col gap-6 list-none p-0 m-0",
|
|
71
|
-
children: items.map((article) => /* @__PURE__ */ jsxDEV("li", {
|
|
72
|
-
class: "bg-white border border-stone-200 rounded-lg p-5 shadow-sm",
|
|
73
|
-
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
74
|
-
class: "flex items-start justify-between gap-4",
|
|
75
|
-
children: [/* @__PURE__ */ jsxDEV("div", { children: [/* @__PURE__ */ jsxDEV("a", {
|
|
76
|
-
href: `/articles/${article.slug}`,
|
|
77
|
-
class: "text-xl font-medium text-stone-900 no-underline hover:underline",
|
|
78
|
-
children: article.title
|
|
79
|
-
}), /* @__PURE__ */ jsxDEV("p", {
|
|
80
|
-
class: "text-sm text-stone-500 mt-1",
|
|
81
|
-
children: [
|
|
82
|
-
article.author,
|
|
83
|
-
" · ",
|
|
84
|
-
new Date(article.publishedAt).toLocaleDateString()
|
|
85
|
-
]
|
|
86
|
-
})] }), /* @__PURE__ */ jsxDEV(BookmarkButton_default, {
|
|
87
|
-
articleId: article.id,
|
|
88
|
-
initialBookmarked: bookmarkedIds.includes(article.id),
|
|
89
|
-
signedIn: Boolean(data.user)
|
|
90
|
-
})]
|
|
91
|
-
}), /* @__PURE__ */ jsxDEV("p", {
|
|
92
|
-
class: "mt-3 text-stone-700 leading-relaxed",
|
|
93
|
-
children: article.excerpt
|
|
94
|
-
})]
|
|
95
|
-
}, article.id))
|
|
96
|
-
}),
|
|
97
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
98
|
-
ref: sentinelRef,
|
|
99
|
-
class: "h-8"
|
|
100
|
-
}),
|
|
101
|
-
loading ? /* @__PURE__ */ jsxDEV("p", {
|
|
102
|
-
class: "text-center text-stone-500 text-sm py-4",
|
|
103
|
-
children: "Loading more…"
|
|
104
|
-
}) : null,
|
|
105
|
-
!cursor && items.length > 0 ? /* @__PURE__ */ jsxDEV("p", {
|
|
106
|
-
class: "text-center text-stone-400 text-sm py-4",
|
|
107
|
-
children: "End of the shelf."
|
|
108
|
-
}) : null
|
|
109
|
-
]
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/pages/index.tsx
|
|
114
|
-
var pages_default = definePage({
|
|
115
|
-
async data(c) {
|
|
116
|
-
const env = c.env;
|
|
117
|
-
const db = createDb(env.DB);
|
|
118
|
-
const user = await getSessionUser(c);
|
|
119
|
-
const rows = await db.select().from(articles).orderBy(desc(articles.publishedAt), desc(articles.id)).limit(9);
|
|
120
|
-
const hasMore = rows.length > 8;
|
|
121
|
-
const page = hasMore ? rows.slice(0, 8) : rows;
|
|
122
|
-
const last = page[page.length - 1];
|
|
123
|
-
const nextCursor = hasMore && last ? `${last.publishedAt instanceof Date ? last.publishedAt.toISOString() : last.publishedAt}|${last.id}` : null;
|
|
124
|
-
let bookmarkedIds = [];
|
|
125
|
-
if (user && page.length > 0) {
|
|
126
|
-
const ids = page.map((r) => r.id);
|
|
127
|
-
bookmarkedIds = (await db.select({ articleId: bookmarks.articleId }).from(bookmarks).where(and(eq(bookmarks.userId, user.id), inArray(bookmarks.articleId, ids)))).map((s) => s.articleId);
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
user,
|
|
131
|
-
items: page.map((row) => ({
|
|
132
|
-
id: row.id,
|
|
133
|
-
slug: row.slug,
|
|
134
|
-
title: row.title,
|
|
135
|
-
excerpt: row.excerpt,
|
|
136
|
-
body: row.body,
|
|
137
|
-
author: row.author,
|
|
138
|
-
publishedAt: row.publishedAt instanceof Date ? row.publishedAt.toISOString() : String(row.publishedAt)
|
|
139
|
-
})),
|
|
140
|
-
nextCursor,
|
|
141
|
-
bookmarkedIds
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
render: Feed
|
|
145
|
-
});
|
|
146
|
-
//#endregion
|
|
147
|
-
export { pages_default as default };
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { a as useState, o as jsxDEV, r as useEffect } from "./jsx-renderer-mMLf5XLN.js";
|
|
2
|
-
import { d as eq, g as definePage, i as bookmarks, l as desc, n as createDb, r as articles } from "./auth-DSFZ4iak.js";
|
|
3
|
-
import { n as api, t as BookmarkButton_default } from "./BookmarkButton-KS7z5_vi.js";
|
|
4
|
-
import { t as getSessionUser } from "./session-BvIpX7tr.js";
|
|
5
|
-
import { t as authClient } from "./auth-client-BFSBVoML.js";
|
|
6
|
-
//#region src/features/saved.tsx
|
|
7
|
-
function SavedList({ data }) {
|
|
8
|
-
const [items, setItems] = useState(data.items);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (!data.user) return;
|
|
11
|
-
(async () => {
|
|
12
|
-
const res = await api.api.bookmarks.$get();
|
|
13
|
-
if (!res.ok) return;
|
|
14
|
-
const body = await res.json();
|
|
15
|
-
setItems(body.items);
|
|
16
|
-
})();
|
|
17
|
-
}, []);
|
|
18
|
-
async function signOut() {
|
|
19
|
-
await authClient.signOut();
|
|
20
|
-
window.location.href = "/";
|
|
21
|
-
}
|
|
22
|
-
if (!data.user) return /* @__PURE__ */ jsxDEV("main", {
|
|
23
|
-
class: "max-w-2xl mx-auto px-4 py-12",
|
|
24
|
-
children: [
|
|
25
|
-
/* @__PURE__ */ jsxDEV("h1", {
|
|
26
|
-
class: "text-2xl font-semibold",
|
|
27
|
-
children: "Saved articles"
|
|
28
|
-
}),
|
|
29
|
-
/* @__PURE__ */ jsxDEV("p", {
|
|
30
|
-
class: "mt-3 text-stone-600",
|
|
31
|
-
children: "Sign in to keep a shelf of articles you want to reread."
|
|
32
|
-
}),
|
|
33
|
-
/* @__PURE__ */ jsxDEV("a", {
|
|
34
|
-
href: "/sign-in",
|
|
35
|
-
class: "inline-block mt-6 bg-stone-900 text-stone-50 px-4 py-2 rounded-md no-underline",
|
|
36
|
-
children: "Sign in"
|
|
37
|
-
})
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
return /* @__PURE__ */ jsxDEV("main", {
|
|
41
|
-
class: "max-w-2xl mx-auto px-4 py-8",
|
|
42
|
-
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
43
|
-
class: "flex items-center justify-between gap-4 mb-8",
|
|
44
|
-
children: [/* @__PURE__ */ jsxDEV("div", { children: [/* @__PURE__ */ jsxDEV("h1", {
|
|
45
|
-
class: "text-3xl font-semibold tracking-tight",
|
|
46
|
-
children: "Saved"
|
|
47
|
-
}), /* @__PURE__ */ jsxDEV("p", {
|
|
48
|
-
class: "text-stone-600 mt-2",
|
|
49
|
-
children: "Your bookmarked articles."
|
|
50
|
-
})] }), /* @__PURE__ */ jsxDEV("button", {
|
|
51
|
-
type: "button",
|
|
52
|
-
onClick: signOut,
|
|
53
|
-
class: "text-sm text-stone-600 underline bg-transparent border-0 cursor-pointer",
|
|
54
|
-
children: "Sign out"
|
|
55
|
-
})]
|
|
56
|
-
}), items.length === 0 ? /* @__PURE__ */ jsxDEV("p", {
|
|
57
|
-
class: "text-stone-500",
|
|
58
|
-
children: "Nothing saved yet. Browse the feed and tap Save."
|
|
59
|
-
}) : /* @__PURE__ */ jsxDEV("ul", {
|
|
60
|
-
class: "flex flex-col gap-6 list-none p-0 m-0",
|
|
61
|
-
children: items.map((article) => /* @__PURE__ */ jsxDEV("li", {
|
|
62
|
-
class: "bg-white border border-stone-200 rounded-lg p-5 shadow-sm",
|
|
63
|
-
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
64
|
-
class: "flex items-start justify-between gap-4",
|
|
65
|
-
children: [/* @__PURE__ */ jsxDEV("div", { children: [/* @__PURE__ */ jsxDEV("a", {
|
|
66
|
-
href: `/articles/${article.slug}`,
|
|
67
|
-
class: "text-xl font-medium text-stone-900 no-underline hover:underline",
|
|
68
|
-
children: article.title
|
|
69
|
-
}), /* @__PURE__ */ jsxDEV("p", {
|
|
70
|
-
class: "text-sm text-stone-500 mt-1",
|
|
71
|
-
children: article.author
|
|
72
|
-
})] }), /* @__PURE__ */ jsxDEV(BookmarkButton_default, {
|
|
73
|
-
articleId: article.id,
|
|
74
|
-
initialBookmarked: true,
|
|
75
|
-
signedIn: true
|
|
76
|
-
})]
|
|
77
|
-
}), /* @__PURE__ */ jsxDEV("p", {
|
|
78
|
-
class: "mt-3 text-stone-700 leading-relaxed",
|
|
79
|
-
children: article.excerpt
|
|
80
|
-
})]
|
|
81
|
-
}, article.id))
|
|
82
|
-
})]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/pages/saved.tsx
|
|
87
|
-
var saved_default = definePage({
|
|
88
|
-
async data(c) {
|
|
89
|
-
const env = c.env;
|
|
90
|
-
const user = await getSessionUser(c);
|
|
91
|
-
if (!user) return {
|
|
92
|
-
user: null,
|
|
93
|
-
items: []
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
user,
|
|
97
|
-
items: (await createDb(env.DB).select({ article: articles }).from(bookmarks).innerJoin(articles, eq(bookmarks.articleId, articles.id)).where(eq(bookmarks.userId, user.id)).orderBy(desc(bookmarks.createdAt))).map((r) => ({
|
|
98
|
-
id: r.article.id,
|
|
99
|
-
slug: r.article.slug,
|
|
100
|
-
title: r.article.title,
|
|
101
|
-
excerpt: r.article.excerpt,
|
|
102
|
-
body: r.article.body,
|
|
103
|
-
author: r.article.author,
|
|
104
|
-
publishedAt: r.article.publishedAt instanceof Date ? r.article.publishedAt.toISOString() : String(r.article.publishedAt)
|
|
105
|
-
}))
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
render: SavedList
|
|
109
|
-
});
|
|
110
|
-
//#endregion
|
|
111
|
-
export { saved_default as default };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { t as createAuth } from "./auth-DSFZ4iak.js";
|
|
2
|
-
//#region src/lib/session.ts
|
|
3
|
-
async function getSessionUser(c) {
|
|
4
|
-
const session = await createAuth(c.env).api.getSession({ headers: c.req.raw.headers });
|
|
5
|
-
if (!session?.user) return null;
|
|
6
|
-
return {
|
|
7
|
-
id: session.user.id,
|
|
8
|
-
name: session.user.name,
|
|
9
|
-
email: session.user.email
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { getSessionUser as t };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { a as useState, o as jsxDEV } from "./jsx-renderer-mMLf5XLN.js";
|
|
2
|
-
import { g as definePage } from "./auth-DSFZ4iak.js";
|
|
3
|
-
import { t as getSessionUser } from "./session-BvIpX7tr.js";
|
|
4
|
-
import { t as authClient } from "./auth-client-BFSBVoML.js";
|
|
5
|
-
//#region src/features/sign-in.tsx
|
|
6
|
-
function SignInForm({ data }) {
|
|
7
|
-
const [email, setEmail] = useState("");
|
|
8
|
-
const [password, setPassword] = useState("");
|
|
9
|
-
const [error, setError] = useState(null);
|
|
10
|
-
const [pending, setPending] = useState(false);
|
|
11
|
-
if (data.user) return /* @__PURE__ */ jsxDEV("main", {
|
|
12
|
-
class: "max-w-md mx-auto px-4 py-12",
|
|
13
|
-
children: [
|
|
14
|
-
/* @__PURE__ */ jsxDEV("h1", {
|
|
15
|
-
class: "text-2xl font-semibold",
|
|
16
|
-
children: "You are signed in"
|
|
17
|
-
}),
|
|
18
|
-
/* @__PURE__ */ jsxDEV("p", {
|
|
19
|
-
class: "mt-2 text-stone-600",
|
|
20
|
-
children: [
|
|
21
|
-
"Welcome back, ",
|
|
22
|
-
data.user.name,
|
|
23
|
-
"."
|
|
24
|
-
]
|
|
25
|
-
}),
|
|
26
|
-
/* @__PURE__ */ jsxDEV("a", {
|
|
27
|
-
href: "/",
|
|
28
|
-
class: "inline-block mt-6 text-stone-800 underline",
|
|
29
|
-
children: "Go to feed"
|
|
30
|
-
})
|
|
31
|
-
]
|
|
32
|
-
});
|
|
33
|
-
async function onSubmit(e) {
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
setPending(true);
|
|
36
|
-
setError(null);
|
|
37
|
-
const res = await authClient.signIn.email({
|
|
38
|
-
email,
|
|
39
|
-
password
|
|
40
|
-
});
|
|
41
|
-
setPending(false);
|
|
42
|
-
if (res.error) {
|
|
43
|
-
setError(res.error.message ?? "Sign in failed");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
window.location.href = "/";
|
|
47
|
-
}
|
|
48
|
-
return /* @__PURE__ */ jsxDEV("main", {
|
|
49
|
-
class: "max-w-md mx-auto px-4 py-12",
|
|
50
|
-
children: [
|
|
51
|
-
/* @__PURE__ */ jsxDEV("h1", {
|
|
52
|
-
class: "text-2xl font-semibold",
|
|
53
|
-
children: "Sign in"
|
|
54
|
-
}),
|
|
55
|
-
/* @__PURE__ */ jsxDEV("p", {
|
|
56
|
-
class: "mt-2 text-stone-600 text-sm",
|
|
57
|
-
children: [
|
|
58
|
-
"No account?",
|
|
59
|
-
" ",
|
|
60
|
-
/* @__PURE__ */ jsxDEV("a", {
|
|
61
|
-
href: "/sign-up",
|
|
62
|
-
class: "underline text-stone-800",
|
|
63
|
-
children: "Sign up"
|
|
64
|
-
})
|
|
65
|
-
]
|
|
66
|
-
}),
|
|
67
|
-
/* @__PURE__ */ jsxDEV("form", {
|
|
68
|
-
class: "mt-8 flex flex-col gap-4",
|
|
69
|
-
onSubmit,
|
|
70
|
-
children: [
|
|
71
|
-
/* @__PURE__ */ jsxDEV("label", {
|
|
72
|
-
class: "flex flex-col gap-1 text-sm",
|
|
73
|
-
children: ["Email", /* @__PURE__ */ jsxDEV("input", {
|
|
74
|
-
type: "email",
|
|
75
|
-
required: true,
|
|
76
|
-
value: email,
|
|
77
|
-
onInput: (e) => setEmail(e.currentTarget.value),
|
|
78
|
-
class: "border border-stone-300 rounded-md px-3 py-2 bg-white"
|
|
79
|
-
})]
|
|
80
|
-
}),
|
|
81
|
-
/* @__PURE__ */ jsxDEV("label", {
|
|
82
|
-
class: "flex flex-col gap-1 text-sm",
|
|
83
|
-
children: ["Password", /* @__PURE__ */ jsxDEV("input", {
|
|
84
|
-
type: "password",
|
|
85
|
-
required: true,
|
|
86
|
-
value: password,
|
|
87
|
-
onInput: (e) => setPassword(e.currentTarget.value),
|
|
88
|
-
class: "border border-stone-300 rounded-md px-3 py-2 bg-white"
|
|
89
|
-
})]
|
|
90
|
-
}),
|
|
91
|
-
error ? /* @__PURE__ */ jsxDEV("p", {
|
|
92
|
-
class: "text-sm text-red-700",
|
|
93
|
-
children: error
|
|
94
|
-
}) : null,
|
|
95
|
-
/* @__PURE__ */ jsxDEV("button", {
|
|
96
|
-
type: "submit",
|
|
97
|
-
disabled: pending,
|
|
98
|
-
class: "bg-stone-900 text-stone-50 rounded-md px-4 py-2 disabled:opacity-50",
|
|
99
|
-
children: pending ? "Signing in…" : "Sign in"
|
|
100
|
-
})
|
|
101
|
-
]
|
|
102
|
-
})
|
|
103
|
-
]
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/pages/sign-in.tsx
|
|
108
|
-
var sign_in_default = definePage({
|
|
109
|
-
async data(c) {
|
|
110
|
-
return { user: await getSessionUser(c) };
|
|
111
|
-
},
|
|
112
|
-
render: SignInForm
|
|
113
|
-
});
|
|
114
|
-
//#endregion
|
|
115
|
-
export { sign_in_default as default };
|