acrylblends 0.7.5 → 0.7.7

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.
Files changed (48) hide show
  1. package/dist/index.js +277 -5
  2. package/dist/index.js.map +1 -1
  3. package/docs/framework/UPSTREAM.md +1 -1
  4. package/docs/framework/guides/data.md +101 -2
  5. package/docs/framework/upstream.json +2 -2
  6. package/lib/database-D_UN6We8.d.ts +44 -0
  7. package/lib/db/sqlite.d.ts +1 -1
  8. package/lib/db.d.ts +84 -1
  9. package/lib/kv/db.d.ts +12 -0
  10. package/lib/kv/db.js +57 -0
  11. package/lib/kv/json.d.ts +11 -0
  12. package/lib/kv/json.js +161 -0
  13. package/lib/kv-DWDm0Lja.d.ts +39 -0
  14. package/lib/kv.d.ts +93 -0
  15. package/lib/kv.js +2 -0
  16. package/lib/src-DRFVEQQb.js +90 -0
  17. package/package.json +13 -1
  18. package/plugins/acryl-db/upstream.json +1 -1
  19. package/plugins/acryl-db-sqlite/upstream.json +1 -1
  20. package/plugins/acryl-inspect/upstream.json +1 -1
  21. package/plugins/acryl-kv/LICENSE +47 -0
  22. package/plugins/acryl-kv/plugin.json +12 -0
  23. package/plugins/acryl-kv/src/check.ts +58 -0
  24. package/plugins/acryl-kv/src/copy.ts +39 -0
  25. package/plugins/acryl-kv/src/cordis.ts +13 -0
  26. package/plugins/acryl-kv/src/index.ts +14 -0
  27. package/plugins/acryl-kv/src/kv.ts +37 -0
  28. package/plugins/acryl-kv/upstream.json +18 -0
  29. package/plugins/acryl-kv-db/LICENSE +47 -0
  30. package/plugins/acryl-kv-db/plugin.json +13 -0
  31. package/plugins/acryl-kv-db/src/index.ts +37 -0
  32. package/plugins/acryl-kv-db/src/open.ts +80 -0
  33. package/plugins/acryl-kv-db/upstream.json +21 -0
  34. package/plugins/acryl-kv-json/LICENSE +47 -0
  35. package/plugins/acryl-kv-json/plugin.json +13 -0
  36. package/plugins/acryl-kv-json/src/index.ts +71 -0
  37. package/plugins/acryl-kv-json/src/open.ts +185 -0
  38. package/plugins/acryl-kv-json/upstream.json +22 -0
  39. package/plugins/acryl-node-server/src/index.ts +12 -1
  40. package/plugins/acryl-node-server/upstream.json +2 -2
  41. package/plugins/acryl-router/upstream.json +1 -1
  42. package/plugins/acryl-router-http/upstream.json +1 -1
  43. package/plugins/acryl-state/upstream.json +1 -1
  44. package/plugins/desktop/upstream.json +1 -1
  45. package/plugins/desktop-web/upstream.json +1 -1
  46. package/plugins/tsconfig.json +2 -0
  47. package/templates/todo/upstream.json +1 -1
  48. package/lib/index-D4FAsBZu.d.ts +0 -85
@@ -0,0 +1,22 @@
1
+ {
2
+ "source": {
3
+ "repo": "acryldev/acryl",
4
+ "path": "plugins/acryl-kv-json",
5
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
6
+ },
7
+ "vendored": [
8
+ "src",
9
+ "tests",
10
+ "LICENSE"
11
+ ],
12
+ "rewrittenSpecifiers": 6,
13
+ "digest": "sha256:d8e3e7f9c98399d0f21f29f91323b4ce57646e59e312d4175978259d618a88cf",
14
+ "testsNotRun": {
15
+ "tests/loader.spec.ts": "loads the plugin through the real Loader (@deepseek-ai/cordis-plugin-loader), which generated apps do not install; the plain opener it wraps is tested here by open.spec.ts and conformance.spec.ts",
16
+ "tests/crash.spec.ts": "kills a child process that imports the package build (lib/), which a copy vendored into an app does not have; it runs in ACRYL",
17
+ "tests/plain-entry-imports.spec.ts": "a copy vendored into an app (with relative imports, no build of its own) has neither `lib/`; the app's own typecheck is what proves the copy names no Cordis type it does not provide."
18
+ },
19
+ "notice": [
20
+ "LICENSE"
21
+ ]
22
+ }
@@ -93,13 +93,24 @@ export class NodeServer extends Service {
93
93
  this.bound = (this.server.address() as AddressInfo).port
94
94
  return
95
95
  } catch (error) {
96
- if ((error as NodeJS.ErrnoException).code !== 'EADDRINUSE') throw error
96
+ if (!isPortUnavailable(error)) throw error
97
97
  }
98
98
  }
99
99
  throw new Error(`acryl-node-server: no free port from ${String(port)} to ${String(last)} on ${hostname}`)
100
100
  }
101
101
  }
102
102
 
103
+ /**
104
+ * Whether a failed bind means "this port, try the next one". A port another socket holds answers `EADDRINUSE` everywhere. On Windows a port
105
+ * inside a range the system reserves (Hyper-V, WSL and Docker exclude ranges, `netsh interface ipv4 show excludedportrange`) answers
106
+ * `EACCES`, which is a property of that port too; elsewhere `EACCES` means the process may not bind low ports at all, so moving on would
107
+ * only hide the reason.
108
+ */
109
+ export function isPortUnavailable(error: unknown, platform: NodeJS.Platform = process.platform): boolean {
110
+ const code = (error as NodeJS.ErrnoException | undefined)?.code
111
+ return code === 'EADDRINUSE' || (platform === 'win32' && code === 'EACCES')
112
+ }
113
+
103
114
  /** Loads once the server listens, so a plugin that injects `nodeServer` can rely on `url`. A failure to bind fails the plugin. */
104
115
  export async function apply(ctx: Context, config: Partial<Config> = {}): Promise<void> {
105
116
  const server = new NodeServer(ctx, { hostname: '127.0.0.1', port: 0, scan: 20, ...config })
@@ -2,7 +2,7 @@
2
2
  "source": {
3
3
  "repo": "acryldev/acryl",
4
4
  "path": "plugins/acryl-node-server",
5
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
5
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
6
6
  },
7
7
  "vendored": [
8
8
  "src",
@@ -10,7 +10,7 @@
10
10
  "LICENSE"
11
11
  ],
12
12
  "rewrittenSpecifiers": 31,
13
- "digest": "sha256:0a3278e006540d0dbecdfb6ada3ca865f3a9a78b649edd9454dab0c76281eda0",
13
+ "digest": "sha256:e4f98422082758912834a6e454505230a18ac543b4851f6eb697b628a1acec4e",
14
14
  "testsNotRun": {
15
15
  "tests/client-modules.spec.ts": "links typescript from the plugin's own node_modules (ACRYL's workspace layout); clientModules and build-client are exercised here by the templates' tests and verify:scaffolder",
16
16
  "tests/register.spec.ts": "links typescript from the plugin's own node_modules (ACRYL's workspace layout); the hook is exercised here by the templates' own .tsx tests and verify:scaffolder"
@@ -2,7 +2,7 @@
2
2
  "source": {
3
3
  "repo": "acryldev/acryl",
4
4
  "path": "plugins/acryl-router",
5
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
5
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
6
6
  },
7
7
  "vendored": [
8
8
  "src",
@@ -2,7 +2,7 @@
2
2
  "source": {
3
3
  "repo": "acryldev/acryl",
4
4
  "path": "plugins/acryl-router-http",
5
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
5
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
6
6
  },
7
7
  "vendored": [
8
8
  "src",
@@ -2,7 +2,7 @@
2
2
  "source": {
3
3
  "repo": "acryldev/acryl",
4
4
  "path": "plugins/acryl-state",
5
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
5
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
6
6
  },
7
7
  "vendored": [
8
8
  "src",
@@ -5,7 +5,7 @@
5
5
  "apps/acryl-desktop/src/shell/desktop-user-data.ts": "user-data.ts",
6
6
  "apps/acryl-desktop/src/shell/shutdown.ts": "shutdown.ts"
7
7
  },
8
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
8
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
9
9
  },
10
10
  "rewrittenSpecifiers": 0,
11
11
  "digest": "sha256:7dfe960a8bbb476c35540d2202a7aaa62b33492c2ac3e34314e2ecfca45f32f2"
@@ -5,7 +5,7 @@
5
5
  "apps/acryl-desktop/src/shell/desktop-user-data.ts": "user-data.ts",
6
6
  "apps/acryl-desktop/src/shell/shutdown.ts": "shutdown.ts"
7
7
  },
8
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
8
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
9
9
  },
10
10
  "rewrittenSpecifiers": 0,
11
11
  "digest": "sha256:7dfe960a8bbb476c35540d2202a7aaa62b33492c2ac3e34314e2ecfca45f32f2"
@@ -24,6 +24,8 @@
24
24
  "acryl-node-server/tests/adapter",
25
25
  "acryl-router/tests/loader.spec.ts",
26
26
  "acryl-db-sqlite/tests/loader.spec.ts",
27
+ "acryl-kv-json/tests/loader.spec.ts",
28
+ "acryl-kv-db/tests/loader.spec.ts",
27
29
  "acryl-state/src/react.ts",
28
30
  "acryl-state/tests/react.spec.ts",
29
31
  "acryl-router-http/tests/adapter.spec.ts",
@@ -5,7 +5,7 @@
5
5
  "examples/acryl-todo/src/index.ts": "src/todo.ts",
6
6
  "examples/acryl-todo/src/page.ts": "src/page.ts"
7
7
  },
8
- "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
8
+ "commit": "f8e385e4389fe2fdc6fd2a4366a7f2a7389faacb"
9
9
  },
10
10
  "rewrittenSpecifiers": 4,
11
11
  "digest": "sha256:9093704776563001f7f472f94cc5c2fdd79206342c1cb59c11fce62aa74df3ed"
@@ -1,85 +0,0 @@
1
- //#region ../../plugins/acryl-db/src/facade/database.d.ts
2
- /** Values supported by the portable SQL drivers. */
3
- type SqlValue = null | number | bigint | string | Uint8Array;
4
- /**
5
- * Asynchronous SQL operations shared by a database and its transaction handles.
6
- *
7
- * `exec` runs SQL text without bindings and may contain several statements. `run`, `get`, and `all`
8
- * execute one statement with positional bindings. Adapters may cache prepared statements by SQL text,
9
- * so callers pass values as bindings instead of interpolating them. `run` resolves the number of rows
10
- * the statement changed.
11
- */
12
- interface DbExecutor {
13
- exec(sql: string): Promise<void>;
14
- run(sql: string, ...params: SqlValue[]): Promise<{
15
- readonly changes: number;
16
- }>;
17
- get<T extends object>(sql: string, ...params: SqlValue[]): Promise<T | undefined>;
18
- all<T extends object>(sql: string, ...params: SqlValue[]): Promise<T[]>;
19
- }
20
- /**
21
- * Minimal portable SQL database facade.
22
- *
23
- * All operations are asynchronous so adapters may execute outside the caller's runtime.
24
- *
25
- * `transaction` passes the callback a transaction handle. All work in the transaction
26
- * must use that handle; the handle is invalid after the callback settles. Adapters must
27
- * queue unrelated operations and other transactions until the transaction finishes. The
28
- * returned promise settles after commit or rollback. Calling the database itself (including
29
- * `transaction`) from inside a callback therefore waits for that transaction and
30
- * never settles.
31
- *
32
- * When the callback rejects, the adapter must roll the transaction back before rejecting
33
- * with that same error. If rollback fails, it must reject with a different error (for
34
- * example an `AggregateError`) so callers cannot mistake the callback error for a
35
- * guaranteed rollback.
36
- *
37
- * Closing is the adapter's: the plugin that opened a database closes it, so the facade an
38
- * app receives has no `close`.
39
- */
40
- interface Db extends DbExecutor {
41
- transaction<T>(callback: (transaction: DbExecutor) => Promise<T>): Promise<T>;
42
- }
43
- //#endregion
44
- //#region ../../plugins/acryl-db/src/facade/migrations.d.ts
45
- type Migration = {
46
- readonly version: number;
47
- readonly statements: readonly string[];
48
- };
49
- /**
50
- * Apply all pending migrations atomically, tracking their version in the named metadata table.
51
- *
52
- * The bookkeeping SQL runs unchanged on SQLite and Postgres: no `STRICT` table, `ON CONFLICT DO NOTHING`
53
- * instead of `INSERT OR IGNORE`, and the version written as a checked integer rather than a binding,
54
- * since the two dialects spell placeholders differently.
55
- */
56
- declare function applyMigrations(database: Db, migrations: readonly Migration[], options: {
57
- readonly table: string;
58
- }): Promise<void>;
59
- //#endregion
60
- //#region ../../plugins/acryl-db/src/facade/schema.d.ts
61
- /** Validate a prefix before using it as part of a SQL identifier. */
62
- declare function validateSchemaPrefix(prefix: string): void;
63
- //#endregion
64
- //#region ../../plugins/acryl-db/src/migration-files.d.ts
65
- /**
66
- * Read every `NNN-name.sql` file of a folder, in number order.
67
- * @throws when a `.sql` file is not named `NNN-name.sql`, or the numbers do not run 1, 2, 3, ... without gaps or repeats.
68
- */
69
- declare function readMigrationFiles(folder: string | URL): Promise<Migration[]>;
70
- //#endregion
71
- //#region ../../plugins/acryl-db/src/index.d.ts
72
- /**
73
- * The `db` port: what an app's code sees of its relational database, whichever provider (`acryl-db-sqlite`, `acryl-db-postgres`) serves
74
- * it. Plain code (an acrylblends app) opens a database with a provider's `openDb`; a Cordis plugin declares `inject: ['db']`, imports
75
- * `acryl-db/cordis` for the `ctx.db` type, and never imports a driver.
76
- *
77
- * Bindings are positional `?` placeholders on every provider; a provider whose database spells them differently translates them.
78
- * This entry imports nothing from Cordis, at runtime or in its types.
79
- */
80
- /** The service name every `db` provider registers. */
81
- declare const DB_SERVICE = "db";
82
- /** The table that records an app's migration version. */
83
- declare const MIGRATIONS_TABLE = "_migrations";
84
- //#endregion
85
- export { Migration as a, DbExecutor as c, validateSchemaPrefix as i, SqlValue as l, MIGRATIONS_TABLE as n, applyMigrations as o, readMigrationFiles as r, Db as s, DB_SERVICE as t };