@rocicorp/zero 0.12.2025012403 → 0.12.2025012501
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/out/{chunk-UFOAJN2W.js → chunk-7HJRUZ7X.js} +2 -2
- package/out/solid.js +30 -28
- package/out/solid.js.map +2 -2
- package/out/zero-solid/src/solid-view.d.ts +3 -3
- package/out/zero-solid/src/solid-view.d.ts.map +1 -1
- package/out/zero.js +1 -1
- package/package.json +1 -1
- /package/out/{chunk-UFOAJN2W.js.map → chunk-7HJRUZ7X.js.map} +0 -0
|
@@ -13424,7 +13424,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
13424
13424
|
}
|
|
13425
13425
|
|
|
13426
13426
|
// ../zero-client/src/client/version.ts
|
|
13427
|
-
var version2 = "0.12.
|
|
13427
|
+
var version2 = "0.12.2025012501+3203d0";
|
|
13428
13428
|
|
|
13429
13429
|
// ../zero-client/src/client/log-options.ts
|
|
13430
13430
|
var LevelFilterLogSink = class {
|
|
@@ -15491,4 +15491,4 @@ export {
|
|
|
15491
15491
|
escapeLike,
|
|
15492
15492
|
Zero
|
|
15493
15493
|
};
|
|
15494
|
-
//# sourceMappingURL=chunk-
|
|
15494
|
+
//# sourceMappingURL=chunk-7HJRUZ7X.js.map
|
package/out/solid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Zero
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HJRUZ7X.js";
|
|
4
4
|
import "./chunk-HARIWJ2J.js";
|
|
5
5
|
import "./chunk-ULOTOBTC.js";
|
|
6
6
|
import {
|
|
@@ -34,9 +34,10 @@ var SolidView = class {
|
|
|
34
34
|
#onDestroy;
|
|
35
35
|
#state;
|
|
36
36
|
#setState;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
#pendingChanges = [];
|
|
38
|
+
constructor(input, onTransactionCommit, format, onDestroy, queryComplete) {
|
|
39
39
|
this.#input = input;
|
|
40
|
+
onTransactionCommit(this.#onTransactionCommit);
|
|
40
41
|
this.#format = format;
|
|
41
42
|
this.#onDestroy = onDestroy;
|
|
42
43
|
[this.#state, this.#setState] = createStore([
|
|
@@ -44,19 +45,7 @@ var SolidView = class {
|
|
|
44
45
|
queryComplete === true ? complete : unknown
|
|
45
46
|
]);
|
|
46
47
|
input.setOutput(this);
|
|
47
|
-
this.#
|
|
48
|
-
produce((draftState) => {
|
|
49
|
-
for (const node of input.fetch({})) {
|
|
50
|
-
applyChange(
|
|
51
|
-
draftState[0],
|
|
52
|
-
{ type: "add", node },
|
|
53
|
-
input.getSchema(),
|
|
54
|
-
"",
|
|
55
|
-
this.#format
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
);
|
|
48
|
+
this.#applyChanges(input.fetch({}), (node) => ({ type: "add", node }));
|
|
60
49
|
if (queryComplete !== true) {
|
|
61
50
|
void queryComplete.then(() => {
|
|
62
51
|
this.#setState((oldState) => [oldState[0], complete]);
|
|
@@ -72,23 +61,36 @@ var SolidView = class {
|
|
|
72
61
|
destroy() {
|
|
73
62
|
this.#onDestroy();
|
|
74
63
|
}
|
|
64
|
+
#onTransactionCommit = () => {
|
|
65
|
+
this.#applyChanges(this.#pendingChanges, (c) => c);
|
|
66
|
+
};
|
|
67
|
+
#applyChanges(changes, mapper) {
|
|
68
|
+
try {
|
|
69
|
+
this.#setState(
|
|
70
|
+
produce((draftState) => {
|
|
71
|
+
for (const change of changes) {
|
|
72
|
+
applyChange(
|
|
73
|
+
draftState[0],
|
|
74
|
+
mapper(change),
|
|
75
|
+
this.#input.getSchema(),
|
|
76
|
+
"",
|
|
77
|
+
this.#format
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
} finally {
|
|
83
|
+
this.#pendingChanges = [];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
75
86
|
push(change) {
|
|
76
|
-
this.#
|
|
77
|
-
produce((draftState) => {
|
|
78
|
-
applyChange(
|
|
79
|
-
draftState[0],
|
|
80
|
-
change,
|
|
81
|
-
this.#input.getSchema(),
|
|
82
|
-
"",
|
|
83
|
-
this.#format
|
|
84
|
-
);
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
+
this.#pendingChanges.push(change);
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
|
-
function solidViewFactory(_query, input, format, onDestroy,
|
|
90
|
+
function solidViewFactory(_query, input, format, onDestroy, onTransactionCommit, queryComplete) {
|
|
90
91
|
return new SolidView(
|
|
91
92
|
input,
|
|
93
|
+
onTransactionCommit,
|
|
92
94
|
format,
|
|
93
95
|
onDestroy,
|
|
94
96
|
queryComplete
|
package/out/solid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../zero-solid/src/create-zero.ts", "../../zero-solid/src/use-query.ts", "../../zero-solid/src/solid-view.ts"],
|
|
4
|
-
"sourcesContent": ["import {batch} from 'solid-js';\nimport {Zero, type ZeroOptions} from '../../zero-client/src/mod.js';\nimport type {ZeroAdvancedOptions} from '../../zero-advanced/src/mod.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\n\nexport function createZero<S extends Schema>(options: ZeroOptions<S>): Zero<S> {\n const opts: ZeroAdvancedOptions<S> = {\n ...options,\n batchViewUpdates: batch,\n };\n return new Zero(opts);\n}\n", "import {createMemo, onCleanup, type Accessor} from 'solid-js';\nimport type {\n AdvancedQuery,\n HumanReadable,\n Query,\n} from '../../zero-advanced/src/mod.js';\nimport {solidViewFactory, type QueryResultDetails} from './solid-view.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\n\nexport type QueryResult<TReturn> = readonly [\n Accessor<HumanReadable<TReturn>>,\n Accessor<QueryResultDetails>,\n];\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(querySignal: () => Query<TSchema, TTable, TReturn>): QueryResult<TReturn> {\n // Wrap in in createMemo to ensure a new view is created if the querySignal changes.\n const view = createMemo(() => {\n const query = querySignal();\n const view = (query as AdvancedQuery<TSchema, TTable, TReturn>).materialize(\n solidViewFactory,\n );\n\n onCleanup(() => {\n view.destroy();\n });\n return view;\n });\n\n return [() => view().data, () => view().resultDetails];\n}\n", "import {\n createStore,\n produce,\n type SetStoreFunction,\n type Store,\n} from 'solid-js/store';\nimport {\n applyChange,\n type Change,\n type Entry,\n type Format,\n type HumanReadable,\n type Input,\n type Output,\n type Query,\n type ViewFactory,\n} from '../../zero-advanced/src/mod.js';\nimport type {
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAAA,SAAQ,aAAY;AAKb,SAAS,WAA6B,SAAkC;AAC7E,QAAM,OAA+B;AAAA,IACnC,GAAG;AAAA,IACH,kBAAkB;AAAA,EACpB;AACA,SAAO,IAAI,KAAK,IAAI;AACtB;;;ACXA,SAAQ,YAAY,iBAA+B;;;ACAnD;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAqBP,IAAM,WAAW,EAAC,MAAM,WAAU;AAClC,IAAM,UAAU,EAAC,MAAM,UAAS;AAEzB,IAAM,YAAN,MAAqC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EAET;AAAA,EACA;AAAA,EAEA,
|
|
4
|
+
"sourcesContent": ["import {batch} from 'solid-js';\nimport {Zero, type ZeroOptions} from '../../zero-client/src/mod.js';\nimport type {ZeroAdvancedOptions} from '../../zero-advanced/src/mod.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\n\nexport function createZero<S extends Schema>(options: ZeroOptions<S>): Zero<S> {\n const opts: ZeroAdvancedOptions<S> = {\n ...options,\n batchViewUpdates: batch,\n };\n return new Zero(opts);\n}\n", "import {createMemo, onCleanup, type Accessor} from 'solid-js';\nimport type {\n AdvancedQuery,\n HumanReadable,\n Query,\n} from '../../zero-advanced/src/mod.js';\nimport {solidViewFactory, type QueryResultDetails} from './solid-view.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\n\nexport type QueryResult<TReturn> = readonly [\n Accessor<HumanReadable<TReturn>>,\n Accessor<QueryResultDetails>,\n];\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(querySignal: () => Query<TSchema, TTable, TReturn>): QueryResult<TReturn> {\n // Wrap in in createMemo to ensure a new view is created if the querySignal changes.\n const view = createMemo(() => {\n const query = querySignal();\n const view = (query as AdvancedQuery<TSchema, TTable, TReturn>).materialize(\n solidViewFactory,\n );\n\n onCleanup(() => {\n view.destroy();\n });\n return view;\n });\n\n return [() => view().data, () => view().resultDetails];\n}\n", "import {\n createStore,\n produce,\n type SetStoreFunction,\n type Store,\n} from 'solid-js/store';\nimport {\n applyChange,\n type Change,\n type Entry,\n type Format,\n type HumanReadable,\n type Input,\n type Output,\n type Query,\n type ViewFactory,\n} from '../../zero-advanced/src/mod.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\nimport type {ResultType} from '../../zql/src/query/typed-view.js';\n\nexport type QueryResultDetails = {\n readonly type: ResultType;\n};\n\ntype State = [Entry, QueryResultDetails];\n\nconst complete = {type: 'complete'} as const;\nconst unknown = {type: 'unknown'} as const;\n\nexport class SolidView<V> implements Output {\n readonly #input: Input;\n readonly #format: Format;\n readonly #onDestroy: () => void;\n\n #state: Store<State>;\n #setState: SetStoreFunction<State>;\n\n #pendingChanges: Change[] = [];\n\n constructor(\n input: Input,\n onTransactionCommit: (cb: () => void) => void,\n format: Format,\n onDestroy: () => void,\n queryComplete: true | Promise<true>,\n ) {\n this.#input = input;\n onTransactionCommit(this.#onTransactionCommit);\n this.#format = format;\n this.#onDestroy = onDestroy;\n [this.#state, this.#setState] = createStore<State>([\n {'': format.singular ? undefined : []},\n queryComplete === true ? complete : unknown,\n ]);\n input.setOutput(this);\n\n this.#applyChanges(input.fetch({}), node => ({type: 'add', node}));\n\n if (queryComplete !== true) {\n void queryComplete.then(() => {\n this.#setState(oldState => [oldState[0], complete]);\n });\n }\n }\n\n get data(): V {\n return this.#state[0][''] as V;\n }\n\n get resultDetails(): QueryResultDetails {\n return this.#state[1];\n }\n\n destroy(): void {\n this.#onDestroy();\n }\n\n #onTransactionCommit = () => {\n this.#applyChanges(this.#pendingChanges, c => c);\n };\n\n #applyChanges<T>(changes: Iterable<T>, mapper: (v: T) => Change): void {\n try {\n this.#setState(\n produce((draftState: State) => {\n for (const change of changes) {\n applyChange(\n draftState[0],\n mapper(change),\n this.#input.getSchema(),\n '',\n this.#format,\n );\n }\n }),\n );\n } finally {\n this.#pendingChanges = [];\n }\n }\n\n push(change: Change): void {\n // Delay setting the state until the transaction commit.\n this.#pendingChanges.push(change);\n }\n}\n\nexport function solidViewFactory<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n _query: Query<TSchema, TTable, TReturn>,\n input: Input,\n format: Format,\n onDestroy: () => void,\n onTransactionCommit: (cb: () => void) => void,\n queryComplete: true | Promise<true>,\n) {\n return new SolidView<HumanReadable<TReturn>>(\n input,\n onTransactionCommit,\n format,\n onDestroy,\n queryComplete,\n );\n}\n\nsolidViewFactory satisfies ViewFactory<Schema, string, unknown, unknown>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAAA,SAAQ,aAAY;AAKb,SAAS,WAA6B,SAAkC;AAC7E,QAAM,OAA+B;AAAA,IACnC,GAAG;AAAA,IACH,kBAAkB;AAAA,EACpB;AACA,SAAO,IAAI,KAAK,IAAI;AACtB;;;ACXA,SAAQ,YAAY,iBAA+B;;;ACAnD;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAqBP,IAAM,WAAW,EAAC,MAAM,WAAU;AAClC,IAAM,UAAU,EAAC,MAAM,UAAS;AAEzB,IAAM,YAAN,MAAqC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EAET;AAAA,EACA;AAAA,EAEA,kBAA4B,CAAC;AAAA,EAE7B,YACE,OACA,qBACA,QACA,WACA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,OACA,QACA,WACA,qBACA,eACA;AACA,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ADhHO,SAAS,SAId,aAA0E;AAE1E,QAAM,OAAO,WAAW,MAAM;AAC5B,UAAM,QAAQ,YAAY;AAC1B,UAAMA,QAAQ,MAAkD;AAAA,MAC9D;AAAA,IACF;AAEA,cAAU,MAAM;AACd,MAAAA,MAAK,QAAQ;AAAA,IACf,CAAC;AACD,WAAOA;AAAA,EACT,CAAC;AAED,SAAO,CAAC,MAAM,KAAK,EAAE,MAAM,MAAM,KAAK,EAAE,aAAa;AACvD;",
|
|
6
6
|
"names": ["view"]
|
|
7
7
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type Change, type Format, type HumanReadable, type Input, type Output, type Query } from '../../zero-advanced/src/mod.js';
|
|
2
|
-
import type { ResultType } from '../../zql/src/query/typed-view.js';
|
|
3
2
|
import type { Schema } from '../../zero-schema/src/mod.js';
|
|
3
|
+
import type { ResultType } from '../../zql/src/query/typed-view.js';
|
|
4
4
|
export type QueryResultDetails = {
|
|
5
5
|
readonly type: ResultType;
|
|
6
6
|
};
|
|
7
7
|
export declare class SolidView<V> implements Output {
|
|
8
8
|
#private;
|
|
9
|
-
constructor(input: Input, format
|
|
9
|
+
constructor(input: Input, onTransactionCommit: (cb: () => void) => void, format: Format, onDestroy: () => void, queryComplete: true | Promise<true>);
|
|
10
10
|
get data(): V;
|
|
11
11
|
get resultDetails(): QueryResultDetails;
|
|
12
12
|
destroy(): void;
|
|
13
13
|
push(change: Change): void;
|
|
14
14
|
}
|
|
15
|
-
export declare function solidViewFactory<TSchema extends Schema, TTable extends keyof TSchema['tables'] & string, TReturn>(_query: Query<TSchema, TTable, TReturn>, input: Input, format: Format, onDestroy: () => void,
|
|
15
|
+
export declare function solidViewFactory<TSchema extends Schema, TTable extends keyof TSchema['tables'] & string, TReturn>(_query: Query<TSchema, TTable, TReturn>, input: Input, format: Format, onDestroy: () => void, onTransactionCommit: (cb: () => void) => void, queryComplete: true | Promise<true>): SolidView<HumanReadable<TReturn>>;
|
|
16
16
|
//# sourceMappingURL=solid-view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid-view.d.ts","sourceRoot":"","sources":["../../../../zero-solid/src/solid-view.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,KAAK,EAEX,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"solid-view.d.ts","sourceRoot":"","sources":["../../../../zero-solid/src/solid-view.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,KAAK,EAEX,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAC;AAElE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B,CAAC;AAOF,qBAAa,SAAS,CAAC,CAAC,CAAE,YAAW,MAAM;;gBAWvC,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,EAC7C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,IAAI,EACrB,aAAa,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrC,IAAI,IAAI,IAAI,CAAC,CAEZ;IAED,IAAI,aAAa,IAAI,kBAAkB,CAEtC;IAED,OAAO,IAAI,IAAI;IA4Bf,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAI3B;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,SAAS,MAAM,EACtB,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,OAAO,EAEP,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EACvC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,IAAI,EACrB,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,EAC7C,aAAa,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,qCASpC"}
|
package/out/zero.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocicorp/zero",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2025012501+3203d0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rm -rf out && npm run build-server && npm run build-client",
|
|
6
6
|
"build-client": "tsc -p tsconfig.client.json && tsc-alias -p tsconfig.client.json && node tool/build.js",
|
|
File without changes
|