acrylblends 0.7.4 → 0.7.5

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 (42) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/index.js.map +1 -1
  3. package/docs/framework/README.md +2 -1
  4. package/docs/framework/UPSTREAM.md +1 -1
  5. package/docs/framework/getting-started/deploy.md +5 -5
  6. package/docs/framework/getting-started/service-worker.md +5 -3
  7. package/docs/framework/guides/create-acrylblends.md +2 -2
  8. package/docs/framework/guides/data.md +202 -0
  9. package/docs/framework/guides/forms-and-sessions.md +34 -30
  10. package/docs/framework/upstream.json +3 -3
  11. package/lib/db/sqlite.d.ts +27 -0
  12. package/lib/db/sqlite.js +197 -0
  13. package/lib/db.d.ts +2 -0
  14. package/lib/db.js +2 -0
  15. package/lib/index-D4FAsBZu.d.ts +85 -0
  16. package/lib/src-MWcsMS8i.js +85 -0
  17. package/package.json +9 -1
  18. package/plugins/acryl-db/LICENSE +47 -0
  19. package/plugins/acryl-db/plugin.json +12 -0
  20. package/plugins/acryl-db/src/cordis.ts +13 -0
  21. package/plugins/acryl-db/src/facade/database.ts +41 -0
  22. package/plugins/acryl-db/src/facade/migrations.ts +50 -0
  23. package/plugins/acryl-db/src/facade/schema.ts +9 -0
  24. package/plugins/acryl-db/src/index.ts +19 -0
  25. package/plugins/acryl-db/src/migration-files.ts +31 -0
  26. package/plugins/acryl-db/upstream.json +18 -0
  27. package/plugins/acryl-db-sqlite/LICENSE +47 -0
  28. package/plugins/acryl-db-sqlite/plugin.json +13 -0
  29. package/plugins/acryl-db-sqlite/src/facade/node.ts +199 -0
  30. package/plugins/acryl-db-sqlite/src/index.ts +88 -0
  31. package/plugins/acryl-db-sqlite/src/open.ts +61 -0
  32. package/plugins/acryl-db-sqlite/upstream.json +21 -0
  33. package/plugins/acryl-inspect/upstream.json +1 -1
  34. package/plugins/acryl-node-server/upstream.json +1 -1
  35. package/plugins/acryl-router/upstream.json +1 -1
  36. package/plugins/acryl-router-http/upstream.json +1 -1
  37. package/plugins/acryl-state/upstream.json +1 -1
  38. package/plugins/desktop/upstream.json +1 -1
  39. package/plugins/desktop-web/main.ts +13 -3
  40. package/plugins/desktop-web/upstream.json +1 -1
  41. package/plugins/tsconfig.json +1 -0
  42. package/templates/todo/upstream.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The desktop shell of a plain Acryl app: `npm run desktop` serves the app (`src/app.ts`, `export default app`) on a free loopback port from this Electron main process and
2
+ * The desktop shell of a plain Acryl app: `npm run desktop` serves the app (`src/app.ts`: `export default app`, and optionally `export const close` for a database to close) on a free loopback port from this Electron main process and
3
3
  * opens one window on it. Nothing in the app imports electron; every Electron call is in this file and `window.ts`, so a different shell is a change here only.
4
4
  *
5
5
  * Order matters: the user-data folder is set before anything else (and before the single-instance lock), so one app never shares window state, logs or the lock with
@@ -36,13 +36,19 @@ if (!app.requestSingleInstanceLock()) {
36
36
  } else {
37
37
  let server: ReturnType<typeof serve> | undefined
38
38
  let window: BrowserWindow | undefined
39
+ /** The app module's optional `close`, for an app that owns a database: called once the server has stopped. */
40
+ let closeApp: (() => Promise<void>) | undefined
39
41
 
40
42
  const shutdown = createDesktopShutdown(
41
43
  () =>
42
44
  new Promise<void>((done) => {
43
45
  if (server === undefined) return done()
44
46
  server.close(() => {
45
- done()
47
+ const closing = closeApp?.() ?? Promise.resolve()
48
+ closing.then(
49
+ () => done(),
50
+ () => done(),
51
+ )
46
52
  })
47
53
  // Open streams and keep-alive connections would hold close() open: end them.
48
54
  ;(server as { closeAllConnections?: () => void }).closeAllConnections?.()
@@ -67,7 +73,11 @@ if (!app.requestSingleInstanceLock()) {
67
73
 
68
74
  void app.whenReady().then(async () => {
69
75
  // The hook above is registered before the app's modules are loaded, so the app may have .tsx pages: they are loaded here, not as a static import.
70
- const { default: acrylApp } = await import('../../app.ts')
76
+ const { default: acrylApp, close } = (await import('../../app.ts')) as {
77
+ default: { fetch: Parameters<typeof serve>[0]['fetch'] }
78
+ close?: () => Promise<void>
79
+ }
80
+ closeApp = close
71
81
  const port = await new Promise<number>((resolve) => {
72
82
  server = serve(
73
83
  { fetch: acrylApp.fetch, port: 0, hostname: '127.0.0.1' },
@@ -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": "eada6fb06a5cafb6c2c92a97effeba567dbd44ba"
8
+ "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
9
9
  },
10
10
  "rewrittenSpecifiers": 0,
11
11
  "digest": "sha256:7dfe960a8bbb476c35540d2202a7aaa62b33492c2ac3e34314e2ecfca45f32f2"
@@ -23,6 +23,7 @@
23
23
  "acryl-*/src/**/*.case.ts",
24
24
  "acryl-node-server/tests/adapter",
25
25
  "acryl-router/tests/loader.spec.ts",
26
+ "acryl-db-sqlite/tests/loader.spec.ts",
26
27
  "acryl-state/src/react.ts",
27
28
  "acryl-state/tests/react.spec.ts",
28
29
  "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": "eada6fb06a5cafb6c2c92a97effeba567dbd44ba"
8
+ "commit": "4721bb00960fa4e157e6070c330cf87c148739fc"
9
9
  },
10
10
  "rewrittenSpecifiers": 4,
11
11
  "digest": "sha256:9093704776563001f7f472f94cc5c2fdd79206342c1cb59c11fce62aa74df3ed"