syncorejs 0.2.2 → 0.2.3
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/_vendor/cli/app.d.mts.map +1 -1
- package/dist/_vendor/cli/app.mjs +8 -5
- package/dist/_vendor/cli/app.mjs.map +1 -1
- package/dist/_vendor/cli/context.mjs.map +1 -1
- package/dist/_vendor/cli/dev-session.mjs.map +1 -1
- package/dist/_vendor/cli/doctor.mjs.map +1 -1
- package/dist/_vendor/cli/errors.mjs.map +1 -1
- package/dist/_vendor/cli/help.mjs.map +1 -1
- package/dist/_vendor/cli/index.mjs +9 -2
- package/dist/_vendor/cli/index.mjs.map +1 -1
- package/dist/_vendor/cli/messages.mjs.map +1 -1
- package/dist/_vendor/cli/preflight.mjs.map +1 -1
- package/dist/_vendor/cli/project.mjs +20 -20
- package/dist/_vendor/cli/project.mjs.map +1 -1
- package/dist/_vendor/cli/render.mjs.map +1 -1
- package/dist/_vendor/cli/targets.mjs.map +1 -1
- package/dist/_vendor/core/cli.d.mts +8 -2
- package/dist/_vendor/core/cli.d.mts.map +1 -1
- package/dist/_vendor/core/cli.mjs +238 -64
- package/dist/_vendor/core/cli.mjs.map +1 -1
- package/dist/_vendor/core/devtools-auth.mjs.map +1 -1
- package/dist/_vendor/core/runtime/components.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/components.mjs.map +1 -1
- package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/devtools.mjs +130 -23
- package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
- package/dist/_vendor/core/runtime/functions.d.mts +388 -6
- package/dist/_vendor/core/runtime/functions.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/functions.mjs +72 -1
- package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
- package/dist/_vendor/core/runtime/id.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/id.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +11 -5
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +123 -20
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +56 -8
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs +49 -14
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs +4 -7
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs +76 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +1 -0
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +4 -3
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/runtimeStatus.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/systemMeta.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs +4 -0
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs.map +1 -1
- package/dist/_vendor/core/runtime/runtime.d.mts +1040 -9
- package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/runtime.mjs +63 -0
- package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
- package/dist/_vendor/core/transport.d.mts +2 -0
- package/dist/_vendor/core/transport.d.mts.map +1 -1
- package/dist/_vendor/core/transport.mjs +33 -24
- package/dist/_vendor/core/transport.mjs.map +1 -1
- package/dist/_vendor/devtools-protocol/index.d.ts +149 -4
- package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
- package/dist/_vendor/devtools-protocol/index.js.map +1 -1
- package/dist/_vendor/next/config.d.ts +3 -4
- package/dist/_vendor/next/config.d.ts.map +1 -1
- package/dist/_vendor/next/config.js +37 -19
- package/dist/_vendor/next/config.js.map +1 -1
- package/dist/_vendor/next/index.d.ts +109 -29
- package/dist/_vendor/next/index.d.ts.map +1 -1
- package/dist/_vendor/next/index.js +77 -17
- package/dist/_vendor/next/index.js.map +1 -1
- package/dist/_vendor/platform-expo/index.d.ts +146 -27
- package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/index.js +76 -10
- package/dist/_vendor/platform-expo/index.js.map +1 -1
- package/dist/_vendor/platform-expo/react.js.map +1 -1
- package/dist/_vendor/platform-expo/web-sqljs-wasm.js +16 -0
- package/dist/_vendor/platform-expo/web-sqljs-wasm.js.map +1 -0
- package/dist/_vendor/platform-node/index.d.mts +173 -9
- package/dist/_vendor/platform-node/index.d.mts.map +1 -1
- package/dist/_vendor/platform-node/index.mjs +225 -94
- package/dist/_vendor/platform-node/index.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc.d.mts.map +1 -1
- package/dist/_vendor/platform-node/ipc.mjs.map +1 -1
- package/dist/_vendor/platform-web/external-change.d.ts +41 -0
- package/dist/_vendor/platform-web/external-change.d.ts.map +1 -1
- package/dist/_vendor/platform-web/external-change.js +30 -0
- package/dist/_vendor/platform-web/external-change.js.map +1 -1
- package/dist/_vendor/platform-web/index.d.ts +307 -35
- package/dist/_vendor/platform-web/index.d.ts.map +1 -1
- package/dist/_vendor/platform-web/index.js +189 -23
- package/dist/_vendor/platform-web/index.js.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.d.ts +12 -0
- package/dist/_vendor/platform-web/indexeddb.d.ts.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.js +10 -0
- package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
- package/dist/_vendor/platform-web/opfs.d.ts +13 -0
- package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
- package/dist/_vendor/platform-web/opfs.js +12 -0
- package/dist/_vendor/platform-web/opfs.js.map +1 -1
- package/dist/_vendor/platform-web/persistence.d.ts +54 -0
- package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
- package/dist/_vendor/platform-web/persistence.js +15 -0
- package/dist/_vendor/platform-web/persistence.js.map +1 -1
- package/dist/_vendor/platform-web/react.d.ts +1 -2
- package/dist/_vendor/platform-web/react.d.ts.map +1 -1
- package/dist/_vendor/platform-web/react.js +2 -4
- package/dist/_vendor/platform-web/react.js.map +1 -1
- package/dist/_vendor/platform-web/sqljs.js +10 -1
- package/dist/_vendor/platform-web/sqljs.js.map +1 -1
- package/dist/_vendor/platform-web/web-sqljs-wasm.js +8 -0
- package/dist/_vendor/platform-web/web-sqljs-wasm.js.map +1 -0
- package/dist/_vendor/platform-web/worker.d.ts +60 -9
- package/dist/_vendor/platform-web/worker.d.ts.map +1 -1
- package/dist/_vendor/platform-web/worker.js +37 -4
- package/dist/_vendor/platform-web/worker.js.map +1 -1
- package/dist/_vendor/react/index.d.ts +196 -13
- package/dist/_vendor/react/index.d.ts.map +1 -1
- package/dist/_vendor/react/index.js +208 -17
- package/dist/_vendor/react/index.js.map +1 -1
- package/dist/_vendor/schema/definition.d.ts +129 -0
- package/dist/_vendor/schema/definition.d.ts.map +1 -1
- package/dist/_vendor/schema/definition.js +99 -0
- package/dist/_vendor/schema/definition.js.map +1 -1
- package/dist/_vendor/schema/planner.d.ts.map +1 -1
- package/dist/_vendor/schema/planner.js.map +1 -1
- package/dist/_vendor/schema/validators.d.ts +180 -4
- package/dist/_vendor/schema/validators.d.ts.map +1 -1
- package/dist/_vendor/schema/validators.js +35 -1
- package/dist/_vendor/schema/validators.js.map +1 -1
- package/dist/_vendor/svelte/index.d.ts +205 -7
- package/dist/_vendor/svelte/index.d.ts.map +1 -1
- package/dist/_vendor/svelte/index.js +199 -6
- package/dist/_vendor/svelte/index.js.map +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +24 -21
|
@@ -3,84 +3,251 @@ import { BroadcastChannelExternalChangeSignal, BroadcastChannelExternalChangeSig
|
|
|
3
3
|
import { AttachWebWorkerRuntimeOptions, AttachedWebWorkerRuntime, CreateWebWorkerClientProviderOptions, ManagedWebWorkerClient, SyncoreWebWorkerClient, SyncoreWorkerMessageEndpoint, WebWorkerSyncoreSchema, WorkerQueryWatch, attachWebWorkerRuntime, createManagedWebWorkerClient, createSyncoreWebWorkerClient, createWebWorkerClient } from "./worker.js";
|
|
4
4
|
import { IndexedDbPersistenceOptions, SyncoreIndexedDbPersistence } from "./indexeddb.js";
|
|
5
5
|
import { OpfsPersistenceOptions, SyncoreOpfsPersistence } from "./opfs.js";
|
|
6
|
-
import * as _syncore_core0 from "../core/index.d.mts";
|
|
7
6
|
import { DevtoolsCommandHandler, DevtoolsSink, DevtoolsSubscriptionHost, SchedulerOptions, StorageObject, StorageWriteInput, SyncoreCapabilities, SyncoreDataModel, SyncoreRuntime, SyncoreRuntimeOptions, SyncoreStorageAdapter } from "../core/index.d.mts";
|
|
7
|
+
import { SyncoreDevtoolsCapabilities } from "../devtools-protocol/index.d.ts";
|
|
8
8
|
|
|
9
9
|
//#region src/index.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Schema type constraint for web-platform Syncore runtimes.
|
|
12
|
+
*
|
|
13
|
+
* Pass any schema produced by `defineSchema()` where this type is expected.
|
|
14
|
+
* Defaults to the unconstrained `SyncoreDataModel` when omitted.
|
|
15
|
+
*/
|
|
10
16
|
type WebSyncoreSchema<TSchema extends SyncoreDataModel = SyncoreDataModel> = TSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Alias of {@link WebSyncoreSchema} for the `syncorejs/browser` surface.
|
|
19
|
+
* @see WebSyncoreSchema
|
|
20
|
+
*/
|
|
11
21
|
type BrowserSyncoreSchema<TSchema extends SyncoreDataModel = SyncoreDataModel> = WebSyncoreSchema<TSchema>;
|
|
12
22
|
/**
|
|
13
23
|
* Options for constructing a browser Syncore runtime.
|
|
14
24
|
*
|
|
15
|
-
* Use this when you want to host the full runtime in a browser tab or
|
|
25
|
+
* Use this when you want to host the full runtime directly in a browser tab or
|
|
26
|
+
* dedicated Web Worker. In most React or Svelte apps you should call
|
|
27
|
+
* `createWebWorkerSyncoreRuntime()` inside a worker file instead, so that
|
|
28
|
+
* SQLite and query execution run off the main thread.
|
|
29
|
+
*
|
|
30
|
+
* At minimum you must supply `schema` and `functions`. Everything else has
|
|
31
|
+
* sensible defaults (OPFS persistence, SQL.js driver, auto-devtools connect).
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const runtime = await createWebSyncoreRuntime({
|
|
35
|
+
* schema,
|
|
36
|
+
* functions,
|
|
37
|
+
* databaseName: "my-app",
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
16
40
|
*/
|
|
17
41
|
interface CreateWebRuntimeOptions<TSchema extends WebSyncoreSchema = WebSyncoreSchema> {
|
|
18
|
-
/** The
|
|
42
|
+
/** The data model that defines the available tables and indexes. */
|
|
19
43
|
schema: TSchema;
|
|
20
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* The registered function map. In practice this is always the `functions`
|
|
46
|
+
* export from `syncore/_generated/functions.ts`.
|
|
47
|
+
*/
|
|
21
48
|
functions: SyncoreRuntimeOptions<TSchema>["functions"];
|
|
22
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Resolved Syncore component instances to mount alongside the root app.
|
|
51
|
+
* Only required when your app installs Syncore component packages.
|
|
52
|
+
*/
|
|
23
53
|
components?: SyncoreRuntimeOptions<TSchema>["components"];
|
|
24
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Platform capabilities injected into `ctx.capabilities` inside function
|
|
56
|
+
* handlers. Use this to expose browser APIs (e.g. `navigator.geolocation`)
|
|
57
|
+
* to your Syncore functions in a portable way.
|
|
58
|
+
*/
|
|
25
59
|
capabilities?: SyncoreCapabilities;
|
|
26
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Custom SQLite driver. Defaults to a `SqlJsDriver` backed by the
|
|
62
|
+
* persistence layer chosen by `persistenceMode` / `persistence`.
|
|
63
|
+
*
|
|
64
|
+
* Override only when you need a non-standard SQLite binding.
|
|
65
|
+
*/
|
|
27
66
|
driver?: SyncoreRuntimeOptions<TSchema>["driver"];
|
|
28
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Custom blob storage adapter. Defaults to `BrowserFileStorageAdapter`
|
|
69
|
+
* backed by the same persistence layer as the SQL driver.
|
|
70
|
+
*
|
|
71
|
+
* Override when you want to store files in a different location (e.g. an
|
|
72
|
+
* in-memory adapter for tests).
|
|
73
|
+
*/
|
|
29
74
|
storage?: SyncoreStorageAdapter;
|
|
30
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* An explicit persistence implementation. When provided, `persistenceMode`,
|
|
77
|
+
* `persistenceDatabaseName`, and `opfsRootDirectoryName` are ignored.
|
|
78
|
+
*
|
|
79
|
+
* Most apps should omit this and let Syncore choose the best available mode
|
|
80
|
+
* automatically via `persistenceMode`.
|
|
81
|
+
*/
|
|
31
82
|
persistence?: SyncoreWebPersistence;
|
|
32
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Which browser storage backend Syncore should use when it creates the
|
|
85
|
+
* persistence layer for you.
|
|
86
|
+
*
|
|
87
|
+
* - `"opfs"` — Origin Private File System (recommended for modern browsers;
|
|
88
|
+
* supports large databases and true WAL mode).
|
|
89
|
+
* - `"indexeddb"` — IndexedDB-backed persistence (wider compatibility).
|
|
90
|
+
*
|
|
91
|
+
* Defaults to the best mode available in the current browser.
|
|
92
|
+
*/
|
|
33
93
|
persistenceMode?: WebPersistenceMode;
|
|
34
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Logical name used to namespace the SQL.js database and local storage keys.
|
|
96
|
+
*
|
|
97
|
+
* Set a stable value (e.g. your app’s slug) so the database persists across
|
|
98
|
+
* page reloads with a predictable name. Defaults to `"syncore"`.
|
|
99
|
+
*/
|
|
35
100
|
databaseName?: string;
|
|
36
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* IndexedDB database name used to store persistence metadata (e.g. the OPFS
|
|
103
|
+
* scope identifier). Defaults to `databaseName`.
|
|
104
|
+
*/
|
|
37
105
|
persistenceDatabaseName?: string;
|
|
38
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* OPFS root directory name for the SQLite database file and blob storage.
|
|
108
|
+
* Defaults to `databaseName` or `"syncore"`.
|
|
109
|
+
*/
|
|
39
110
|
opfsRootDirectoryName?: string;
|
|
40
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Namespace prefix for blob storage keys. Defaults to `databaseName` or
|
|
113
|
+
* `"syncore"`.
|
|
114
|
+
*/
|
|
41
115
|
storageNamespace?: string;
|
|
42
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Explicit URL for the `sql.js` WebAssembly binary.
|
|
118
|
+
*
|
|
119
|
+
* Syncore resolves the URL automatically in most bundler setups. Override
|
|
120
|
+
* this only if the auto-resolved URL is incorrect (e.g. in a custom CDN
|
|
121
|
+
* deploy or a worker with a different asset base path).
|
|
122
|
+
*/
|
|
43
123
|
wasmUrl?: string;
|
|
44
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Custom file resolver for SQL.js support files (wasm + worker scripts).
|
|
126
|
+
*
|
|
127
|
+
* Takes a filename (e.g. `"sql-wasm.wasm"`) and returns the full URL.
|
|
128
|
+
* Equivalent to sql.js’s `locateFile` option. Use `wasmUrl` instead when
|
|
129
|
+
* you only need to override the `.wasm` path.
|
|
130
|
+
*/
|
|
45
131
|
locateFile?: (fileName: string) => string;
|
|
46
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Platform label reported to the devtools dashboard.
|
|
134
|
+
* Defaults to `"browser"`.
|
|
135
|
+
*/
|
|
47
136
|
platform?: string;
|
|
48
|
-
/**
|
|
137
|
+
/** Human-readable app name shown in the devtools dashboard header. */
|
|
138
|
+
appName?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Explicit devtools WebSocket server URL.
|
|
141
|
+
* Defaults to `ws://127.0.0.1:4311` (the Syncore devtools default port).
|
|
142
|
+
*/
|
|
143
|
+
devtoolsUrl?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Devtools event sink. Pass `false` to disable devtools entirely
|
|
146
|
+
* (recommended for production builds). Omit to auto-connect to the local
|
|
147
|
+
* devtools server when running in development.
|
|
148
|
+
*/
|
|
49
149
|
devtools?: DevtoolsSink | false;
|
|
50
|
-
/**
|
|
150
|
+
/** Scheduler configuration for background and recurring jobs. */
|
|
51
151
|
scheduler?: SchedulerOptions;
|
|
52
152
|
}
|
|
53
153
|
/**
|
|
54
|
-
* Options for hosting a Syncore runtime inside a browser Worker.
|
|
154
|
+
* Options for hosting a Syncore runtime inside a dedicated browser Worker.
|
|
155
|
+
*
|
|
156
|
+
* Extends {@link CreateWebRuntimeOptions} with the `endpoint` field that wires
|
|
157
|
+
* the runtime to the worker’s message port. Use this inside a worker entry
|
|
158
|
+
* file (`syncore.worker.ts`):
|
|
159
|
+
*
|
|
160
|
+
* ```ts
|
|
161
|
+
* // syncore.worker.ts
|
|
162
|
+
* import { createWebWorkerSyncoreRuntime } from "syncorejs/browser";
|
|
163
|
+
* import schema from "./syncore/schema";
|
|
164
|
+
* import { functions } from "./syncore/_generated/functions";
|
|
165
|
+
*
|
|
166
|
+
* createWebWorkerSyncoreRuntime({
|
|
167
|
+
* schema,
|
|
168
|
+
* functions,
|
|
169
|
+
* endpoint: self as unknown as SyncoreWorkerMessageEndpoint,
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
55
172
|
*/
|
|
56
173
|
interface CreateWebWorkerRuntimeOptions<TSchema extends WebSyncoreSchema = WebSyncoreSchema> extends CreateWebRuntimeOptions<TSchema> {
|
|
57
174
|
/** The message endpoint exposed by the current worker global. */
|
|
58
175
|
endpoint: SyncoreWorkerMessageEndpoint;
|
|
59
176
|
}
|
|
60
177
|
/**
|
|
61
|
-
*
|
|
178
|
+
* Alias of {@link CreateWebRuntimeOptions} for the `syncorejs/browser` surface.
|
|
179
|
+
* @see CreateWebRuntimeOptions
|
|
62
180
|
*/
|
|
63
181
|
type CreateBrowserRuntimeOptions<TSchema extends BrowserSyncoreSchema = BrowserSyncoreSchema> = CreateWebRuntimeOptions<TSchema>;
|
|
64
182
|
/**
|
|
65
|
-
*
|
|
183
|
+
* Alias of {@link CreateWebWorkerRuntimeOptions} for the `syncorejs/browser` surface.
|
|
184
|
+
* @see CreateWebWorkerRuntimeOptions
|
|
66
185
|
*/
|
|
67
186
|
type CreateBrowserWorkerRuntimeOptions<TSchema extends BrowserSyncoreSchema = BrowserSyncoreSchema> = CreateWebWorkerRuntimeOptions<TSchema>;
|
|
187
|
+
/**
|
|
188
|
+
* Internal bookkeeping for the browser cross-tab change synchronisation layer.
|
|
189
|
+
*
|
|
190
|
+
* Holds the `BroadcastChannel`-based signal that publishes and receives
|
|
191
|
+
* database-change events between tabs, and optionally an `applier` that
|
|
192
|
+
* reconciles incoming changes into an in-memory SQL.js database.
|
|
193
|
+
*
|
|
194
|
+
* You do not need to use this directly — `createWebSyncoreRuntime` builds it
|
|
195
|
+
* for you from your options. Exposed for advanced setups (e.g. Expo web) that
|
|
196
|
+
* construct the change support layer independently.
|
|
197
|
+
*/
|
|
68
198
|
interface WebExternalChangeSupport {
|
|
69
199
|
signal: BroadcastChannelExternalChangeSignal;
|
|
70
200
|
applier?: SqlJsExternalChangeApplier;
|
|
71
201
|
}
|
|
72
202
|
/**
|
|
73
|
-
* Create a full Syncore runtime directly in the browser
|
|
203
|
+
* Create a full Syncore runtime directly in the browser (main thread or
|
|
204
|
+
* shared worker).
|
|
205
|
+
*
|
|
206
|
+
* This function sets up SQL.js, the OPFS/IndexedDB persistence layer, blob
|
|
207
|
+
* storage, cross-tab change synchronisation via `BroadcastChannel`, and
|
|
208
|
+
* auto-connects to the devtools server in development.
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* Most React/Svelte apps should run the runtime inside a `Worker` using
|
|
212
|
+
* `createWebWorkerSyncoreRuntime()` instead, so that SQLite queries don’t
|
|
213
|
+
* block the main thread. Use `createWebSyncoreRuntime` only when a worker is
|
|
214
|
+
* not practical (e.g. in Electron renderer processes or certain test setups).
|
|
74
215
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* const runtime = await createWebSyncoreRuntime({ schema, functions });
|
|
218
|
+
* await runtime.start();
|
|
219
|
+
* const client = runtime.createClient();
|
|
220
|
+
* ```
|
|
77
221
|
*/
|
|
78
222
|
declare function createWebSyncoreRuntime<TSchema extends WebSyncoreSchema>(options: CreateWebRuntimeOptions<TSchema>): Promise<SyncoreRuntime<TSchema>>;
|
|
223
|
+
/**
|
|
224
|
+
* Build a {@link WebExternalChangeSupport} bundle for a given database and
|
|
225
|
+
* persistence layer.
|
|
226
|
+
*
|
|
227
|
+
* Creates a `BroadcastChannel`-based signal so that all tabs sharing the same
|
|
228
|
+
* `databaseName` are notified when a mutation commits. When `driver` is a
|
|
229
|
+
* `SqlJsDriver` (i.e. an in-memory database), an `applier` is also created so
|
|
230
|
+
* the local database can be updated from the latest on-disk snapshot.
|
|
231
|
+
*
|
|
232
|
+
* Called automatically by `createWebSyncoreRuntime`. Exposed for advanced use
|
|
233
|
+
* cases such as the Expo web adapter.
|
|
234
|
+
*/
|
|
79
235
|
declare function createWebExternalChangeSupport(options: {
|
|
80
236
|
databaseName: string;
|
|
81
237
|
persistence: SyncoreWebPersistence;
|
|
82
238
|
driver: CreateWebRuntimeOptions<SyncoreDataModel>["driver"] | undefined;
|
|
83
239
|
}): WebExternalChangeSupport;
|
|
240
|
+
/**
|
|
241
|
+
* Build a {@link WebExternalChangeSupport} bundle for an Expo app running on
|
|
242
|
+
* the web platform.
|
|
243
|
+
*
|
|
244
|
+
* Behaves identically to {@link createWebExternalChangeSupport} but accepts
|
|
245
|
+
* the same options shape used by `createExpoSyncoreRuntime`, making it easy
|
|
246
|
+
* to share config when bootstrapping an Expo web runtime.\
|
|
247
|
+
*
|
|
248
|
+
* Called internally by the Expo platform adapter. Use directly only when
|
|
249
|
+
* constructing the runtime outside of `createExpoSyncoreRuntime`.
|
|
250
|
+
*/
|
|
84
251
|
declare function createExpoWebExternalChangeSupport(options: {
|
|
85
252
|
databaseName: string;
|
|
86
253
|
locateFile?: (fileName: string) => string;
|
|
@@ -90,45 +257,150 @@ declare function createExpoWebExternalChangeSupport(options: {
|
|
|
90
257
|
persistenceMode?: WebPersistenceMode;
|
|
91
258
|
}): Promise<WebExternalChangeSupport>;
|
|
92
259
|
/**
|
|
93
|
-
*
|
|
260
|
+
* Start a Syncore runtime inside a browser `Worker` and wire it to the
|
|
261
|
+
* worker’s own message endpoint.
|
|
262
|
+
*
|
|
263
|
+
* This is the function you call **inside your worker file** (`syncore.worker.ts`).
|
|
264
|
+
* It creates the full runtime (SQL.js + OPFS + BroadcastChannel) in the worker
|
|
265
|
+
* context and begins listening for messages from the main-thread client.
|
|
266
|
+
*
|
|
267
|
+
* ```ts
|
|
268
|
+
* // syncore.worker.ts
|
|
269
|
+
* import { createWebWorkerRuntime } from "syncorejs/browser";
|
|
270
|
+
* import schema from "./syncore/schema";
|
|
271
|
+
* import { functions } from "./syncore/_generated/functions";
|
|
272
|
+
*
|
|
273
|
+
* void createWebWorkerRuntime({
|
|
274
|
+
* schema,
|
|
275
|
+
* functions,
|
|
276
|
+
* endpoint: self as unknown as SyncoreWorkerMessageEndpoint,
|
|
277
|
+
* });
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* On the main thread, connect with `createManagedWebWorkerClient()` or
|
|
281
|
+
* `SyncoreNextProvider` (Next.js).
|
|
94
282
|
*/
|
|
95
|
-
declare function createWebWorkerRuntime<TSchema extends WebSyncoreSchema>(options: CreateWebWorkerRuntimeOptions<TSchema>):
|
|
283
|
+
declare function createWebWorkerRuntime<TSchema extends WebSyncoreSchema>(options: CreateWebWorkerRuntimeOptions<TSchema>): import("../core/index.d.mts").AttachedRuntimeBridge;
|
|
96
284
|
/**
|
|
97
|
-
*
|
|
285
|
+
* Alias of {@link createWebWorkerRuntime} for the `syncorejs/browser` surface.
|
|
286
|
+
* @see createWebWorkerRuntime
|
|
98
287
|
*/
|
|
99
|
-
declare function createBrowserWorkerRuntime(options: CreateBrowserWorkerRuntimeOptions):
|
|
288
|
+
declare function createBrowserWorkerRuntime(options: CreateBrowserWorkerRuntimeOptions): import("../core/index.d.mts").AttachedRuntimeBridge;
|
|
100
289
|
/**
|
|
101
|
-
* Create a client
|
|
290
|
+
* Create a same-process Syncore client from a started browser runtime.
|
|
291
|
+
*
|
|
292
|
+
* Use this when the runtime lives in the same context as the client (e.g.
|
|
293
|
+
* main-thread runtime in an Electron renderer or a test harness). For
|
|
294
|
+
* worker-based setups use `createManagedWebWorkerClient()` instead, which
|
|
295
|
+
* communicates with the worker over `postMessage`.
|
|
296
|
+
*
|
|
297
|
+
* ```ts
|
|
298
|
+
* const runtime = await createWebSyncoreRuntime({ schema, functions });
|
|
299
|
+
* await runtime.start();
|
|
300
|
+
* const client = createWebSyncoreClient(runtime);
|
|
301
|
+
* ```
|
|
102
302
|
*/
|
|
103
|
-
declare function createWebSyncoreClient<TSchema extends WebSyncoreSchema>(runtime: SyncoreRuntime<TSchema>):
|
|
303
|
+
declare function createWebSyncoreClient<TSchema extends WebSyncoreSchema>(runtime: SyncoreRuntime<TSchema>): import("../core/index.d.mts").SyncoreClient;
|
|
104
304
|
/**
|
|
105
|
-
*
|
|
305
|
+
* Alias of {@link createWebSyncoreRuntime} for the `syncorejs/browser` surface.
|
|
306
|
+
* @see createWebSyncoreRuntime
|
|
106
307
|
*/
|
|
107
308
|
declare function createBrowserSyncoreRuntime<TSchema extends BrowserSyncoreSchema>(options: CreateBrowserRuntimeOptions<TSchema>): Promise<SyncoreRuntime<TSchema>>;
|
|
108
309
|
/**
|
|
109
|
-
*
|
|
310
|
+
* Alias of {@link createWebSyncoreClient} for the `syncorejs/browser` surface.
|
|
311
|
+
* @see createWebSyncoreClient
|
|
312
|
+
*/
|
|
313
|
+
declare function createBrowserSyncoreClient<TSchema extends BrowserSyncoreSchema>(runtime: SyncoreRuntime<TSchema>): import("../core/index.d.mts").SyncoreClient;
|
|
314
|
+
/**
|
|
315
|
+
* Configuration options for {@link createBrowserWebSocketDevtoolsSink}.
|
|
316
|
+
*
|
|
317
|
+
* All fields except `url` are optional — `createWebSyncoreRuntime` fills them
|
|
318
|
+
* in automatically from the runtime’s own metadata.
|
|
110
319
|
*/
|
|
111
|
-
declare function createBrowserSyncoreClient<TSchema extends BrowserSyncoreSchema>(runtime: SyncoreRuntime<TSchema>): _syncore_core0.SyncoreClient;
|
|
112
320
|
interface BrowserWebSocketDevtoolsSinkOptions {
|
|
321
|
+
/** WebSocket URL of the Syncore devtools server, e.g. `"ws://127.0.0.1:4311"`. */
|
|
113
322
|
url: string;
|
|
323
|
+
/**
|
|
324
|
+
* How long to wait before attempting a reconnect after the WebSocket closes,
|
|
325
|
+
* in milliseconds. Defaults to `1200`.
|
|
326
|
+
*/
|
|
114
327
|
reconnectDelayMs?: number;
|
|
328
|
+
/** Human-readable app name shown in the devtools dashboard header. */
|
|
115
329
|
appName?: string;
|
|
330
|
+
/** Origin label (e.g. `window.location.origin`) shown in the devtools session list. */
|
|
116
331
|
origin?: string;
|
|
332
|
+
/** Session label auto-generated from the tab’s URL path; helps distinguish multiple open tabs. */
|
|
117
333
|
sessionLabel?: string;
|
|
334
|
+
/** Kind of this devtools participant. Always `"client"` for browser runtimes. */
|
|
118
335
|
targetKind?: "client";
|
|
336
|
+
/** Persistence protocol tag reported to devtools (e.g. `"opfs"`, `"indexeddb"`). */
|
|
119
337
|
storageProtocol?: string;
|
|
338
|
+
/** Logical database name used to group sessions in the devtools UI. */
|
|
120
339
|
databaseLabel?: string;
|
|
340
|
+
/** Stable alias for the data source, used by devtools for cross-session continuity. */
|
|
341
|
+
dataSourceAlias?: string;
|
|
342
|
+
/**
|
|
343
|
+
* Opaque identity string that uniquely identifies this database across origin
|
|
344
|
+
* + persistence protocol + name, used by devtools for data-source tracking.
|
|
345
|
+
*/
|
|
121
346
|
storageIdentity?: string;
|
|
347
|
+
/** Capability flags advertising what devtools features this runtime supports. */
|
|
348
|
+
capabilities?: SyncoreDevtoolsCapabilities;
|
|
122
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* A {@link DevtoolsSink} that forwards runtime events to the Syncore devtools
|
|
352
|
+
* dashboard over a persistent WebSocket connection with auto-reconnect.
|
|
353
|
+
*
|
|
354
|
+
* Returned by {@link createBrowserWebSocketDevtoolsSink}. You typically do not
|
|
355
|
+
* use this interface directly — `createWebSyncoreRuntime` creates and manages
|
|
356
|
+
* the sink automatically when running in development.
|
|
357
|
+
*/
|
|
123
358
|
interface BrowserWebSocketDevtoolsSink extends DevtoolsSink {
|
|
359
|
+
/** Attach the runtime so the sink can pull metadata for devtools messages. */
|
|
124
360
|
attachRuntime(runtime: SyncoreRuntime<WebSyncoreSchema>): void;
|
|
361
|
+
/** Attach the command handler that processes devtools RPC commands. */
|
|
125
362
|
attachCommandHandler(handler: DevtoolsCommandHandler): void;
|
|
363
|
+
/** Attach the subscription host for live query streaming. */
|
|
126
364
|
attachSubscriptionHost(host: DevtoolsSubscriptionHost): void;
|
|
365
|
+
/** Close the WebSocket and stop reconnecting. Call on runtime shutdown. */
|
|
127
366
|
dispose(): void;
|
|
128
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Create a WebSocket-based devtools sink that connects to the Syncore devtools
|
|
370
|
+
* server and forwards runtime events in real time.
|
|
371
|
+
*
|
|
372
|
+
* The sink auto-reconnects if the connection drops (e.g. while the devtools
|
|
373
|
+
* dashboard is restarting) and buffers events that arrive before the socket is
|
|
374
|
+
* open.
|
|
375
|
+
*
|
|
376
|
+
* In most cases you do not need to call this directly — `createWebSyncoreRuntime`
|
|
377
|
+
* creates and attaches the sink automatically when `devtools` is omitted and the
|
|
378
|
+
* page is served from a local/private hostname.
|
|
379
|
+
*
|
|
380
|
+
* ```ts
|
|
381
|
+
* const sink = createBrowserWebSocketDevtoolsSink({
|
|
382
|
+
* url: "ws://127.0.0.1:4311",
|
|
383
|
+
* appName: "My App",
|
|
384
|
+
* });
|
|
385
|
+
* const runtime = await createWebSyncoreRuntime({ schema, functions, devtools: sink });
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
129
388
|
declare function createBrowserWebSocketDevtoolsSink(options: BrowserWebSocketDevtoolsSinkOptions): BrowserWebSocketDevtoolsSink;
|
|
130
389
|
/**
|
|
131
|
-
* Browser file/blob storage
|
|
390
|
+
* Browser file/blob storage adapter backed by `SyncoreWebPersistence`.
|
|
391
|
+
*
|
|
392
|
+
* Stores binary blobs (images, documents, etc.) in the same OPFS or
|
|
393
|
+
* IndexedDB store as the SQLite database. Pass an instance to
|
|
394
|
+
* `CreateWebRuntimeOptions.storage` to enable Syncore's Storage API
|
|
395
|
+
* (`ctx.storage.put`, `ctx.storage.get`, etc.) in browser functions.
|
|
396
|
+
*
|
|
397
|
+
* ```ts
|
|
398
|
+
* const runtime = await createWebSyncoreRuntime({
|
|
399
|
+
* schema,
|
|
400
|
+
* functions,
|
|
401
|
+
* storage: (persistence) => new BrowserFileStorageAdapter(persistence, "files"),
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
132
404
|
*/
|
|
133
405
|
declare class BrowserFileStorageAdapter implements SyncoreStorageAdapter {
|
|
134
406
|
private readonly persistence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;KAoDY,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