@adobe/data-lit 0.9.87 → 0.9.89
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/elements/database-element.d.ts +5 -3
- package/dist/elements/database-element.js +4 -2
- package/dist/elements/database-element.js.map +1 -1
- package/dist/elements/database-element.type-test.js +12 -0
- package/dist/elements/database-element.type-test.js.map +1 -1
- package/package.json +2 -2
- package/src/elements/database-element.ts +5 -3
- package/src/elements/database-element.type-test.ts +35 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,12 +6,14 @@ export declare abstract class DatabaseElement<P extends Database.Plugin> extends
|
|
|
6
6
|
/**
|
|
7
7
|
* The element's database surface.
|
|
8
8
|
* - SET to inject the full database (DI).
|
|
9
|
-
* - GET returns the UI-restricted view
|
|
10
|
-
* fire-and-forget `void
|
|
9
|
+
* - GET returns the UI-restricted view: every mutator rewritten to
|
|
10
|
+
* fire-and-forget `void`, and every transaction shadowed by a same-named
|
|
11
|
+
* action masked out so the UI calls the action instead (see
|
|
12
|
+
* {@link UIService.FromDatabase}).
|
|
11
13
|
* Divergent get/set types are intentional: inject full, consume restricted.
|
|
12
14
|
*/
|
|
13
15
|
set service(db: Database.Plugin.ToDatabase<P>);
|
|
14
|
-
get service(): UIService.
|
|
16
|
+
get service(): UIService.FromDatabase<Database.Plugin.ToDatabase<P>>;
|
|
15
17
|
/**
|
|
16
18
|
* The full, unrestricted database — for imperative-rendering subclasses
|
|
17
19
|
* (a canvas / WebGL draw loop that reads columns synchronously each frame,
|
|
@@ -11,8 +11,10 @@ export class DatabaseElement extends LitElement {
|
|
|
11
11
|
/**
|
|
12
12
|
* The element's database surface.
|
|
13
13
|
* - SET to inject the full database (DI).
|
|
14
|
-
* - GET returns the UI-restricted view
|
|
15
|
-
* fire-and-forget `void
|
|
14
|
+
* - GET returns the UI-restricted view: every mutator rewritten to
|
|
15
|
+
* fire-and-forget `void`, and every transaction shadowed by a same-named
|
|
16
|
+
* action masked out so the UI calls the action instead (see
|
|
17
|
+
* {@link UIService.FromDatabase}).
|
|
16
18
|
* Divergent get/set types are intentional: inject full, consume restricted.
|
|
17
19
|
*/
|
|
18
20
|
set service(db) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-element.js","sourceRoot":"","sources":["../../src/elements/database-element.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,OAAgB,eAA2C,SAAQ,UAAU;IAEjF;+EAC2E;IAC3E,SAAS,CAAiC;IAE1C
|
|
1
|
+
{"version":3,"file":"database-element.js","sourceRoot":"","sources":["../../src/elements/database-element.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,OAAgB,eAA2C,SAAQ,UAAU;IAEjF;+EAC2E;IAC3E,SAAS,CAAiC;IAE1C;;;;;;;;OAQG;IACH,IAAI,OAAO,CAAC,EAAiC;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAA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AE,OAAO,EAAE,GAAG,OAAgC,CAAC;YACrD,IAAI,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC;gBAAE,OAAO,OAAO,CAAC;QAC3C,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;CAEF"}
|
|
@@ -22,6 +22,18 @@ const plugin = Database.Plugin.create({
|
|
|
22
22
|
setCount: (t, input) => {
|
|
23
23
|
t.resources.count = input.value;
|
|
24
24
|
},
|
|
25
|
+
// A raw commit that the `save` action below wraps.
|
|
26
|
+
save: (t) => {
|
|
27
|
+
t.resources.count = t.resources.count;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
actions: {
|
|
31
|
+
// The `save` action shadows the `save` transaction: it wraps the raw
|
|
32
|
+
// transaction with async work, so the UI must call the action. The
|
|
33
|
+
// restricted view masks `transactions.save` out entirely.
|
|
34
|
+
save: async (db) => {
|
|
35
|
+
db.transactions.save();
|
|
36
|
+
},
|
|
25
37
|
},
|
|
26
38
|
});
|
|
27
39
|
class _CountElement extends DatabaseElement {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-element.type-test.js","sourceRoot":"","sources":["../../src/elements/database-element.type-test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD;;;;;;;;GAQG;AAEH,sDAAsD;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,SAAS,EAAE;QACT,KAAK,EAAE,EAAE,OAAO,EAAE,CAAW,EAAE;KAChC;IACD,YAAY,EAAE;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;YACf,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAiC,EAAE,EAAE;YACjD,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAClC,CAAC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,aAAc,SAAQ,eAA8B;IACxD,IAAI,MAAM;QACR,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAKD,iFAAiF;AACjF,2EAA2E;AAC3E,yDAAyD;AACzD,MAAM,mBAAmB,GAAG,CAAC,EAAiB,EAAE,EAAe,EAAQ,EAAE;IACvE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,CAAC,CAAC;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,MAAM,2BAA2B,GAAG,CAAC,EAAiB,EAAQ,EAAE;IAC9D,+EAA+E;IAC/E,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;AAC1B,CAAC,CAAC;AAEF,gFAAgF;AAChF,0EAA0E;AAC1E,MAAM,yBAAyB,GAAG,CAAC,EAAiB,EAAQ,EAAE;IAC5D,4EAA4E;IAC5E,KAAK,EAAE,CAAC,QAAQ,CAAC;AACnB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"database-element.type-test.js","sourceRoot":"","sources":["../../src/elements/database-element.type-test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD;;;;;;;;GAQG;AAEH,sDAAsD;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,SAAS,EAAE;QACT,KAAK,EAAE,EAAE,OAAO,EAAE,CAAW,EAAE;KAChC;IACD,YAAY,EAAE;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;YACf,CAAC,CAAC,SAAS,CAAC,K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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/data-lit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.89",
|
|
4
4
|
"description": "Adobe data Lit bindings - hooks, elements, decorators",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@adobe/data": "0.9.
|
|
15
|
+
"@adobe/data": "0.9.89"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"lit": "^3.3.1"
|
|
@@ -15,8 +15,10 @@ export abstract class DatabaseElement<P extends Database.Plugin> extends LitElem
|
|
|
15
15
|
/**
|
|
16
16
|
* The element's database surface.
|
|
17
17
|
* - SET to inject the full database (DI).
|
|
18
|
-
* - GET returns the UI-restricted view
|
|
19
|
-
* fire-and-forget `void
|
|
18
|
+
* - GET returns the UI-restricted view: every mutator rewritten to
|
|
19
|
+
* fire-and-forget `void`, and every transaction shadowed by a same-named
|
|
20
|
+
* action masked out so the UI calls the action instead (see
|
|
21
|
+
* {@link UIService.FromDatabase}).
|
|
20
22
|
* Divergent get/set types are intentional: inject full, consume restricted.
|
|
21
23
|
*/
|
|
22
24
|
set service(db: Database.Plugin.ToDatabase<P>) {
|
|
@@ -24,7 +26,7 @@ export abstract class DatabaseElement<P extends Database.Plugin> extends LitElem
|
|
|
24
26
|
this.#database = db;
|
|
25
27
|
this.requestUpdate('service', old);
|
|
26
28
|
}
|
|
27
|
-
get service(): UIService.
|
|
29
|
+
get service(): UIService.FromDatabase<Database.Plugin.ToDatabase<P>> {
|
|
28
30
|
return UIService.restrict(this.#database);
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -29,6 +29,18 @@ const plugin = Database.Plugin.create({
|
|
|
29
29
|
setCount: (t, input: { readonly value: number }) => {
|
|
30
30
|
t.resources.count = input.value;
|
|
31
31
|
},
|
|
32
|
+
// A raw commit that the `save` action below wraps.
|
|
33
|
+
save: (t) => {
|
|
34
|
+
t.resources.count = t.resources.count;
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
actions: {
|
|
38
|
+
// The `save` action shadows the `save` transaction: it wraps the raw
|
|
39
|
+
// transaction with async work, so the UI must call the action. The
|
|
40
|
+
// restricted view masks `transactions.save` out entirely.
|
|
41
|
+
save: async (db) => {
|
|
42
|
+
db.transactions.save();
|
|
43
|
+
},
|
|
32
44
|
},
|
|
33
45
|
});
|
|
34
46
|
|
|
@@ -62,8 +74,9 @@ const _noPublicDatabaseProperty = (el: _CountElement): void => {
|
|
|
62
74
|
};
|
|
63
75
|
type _CheckNoDatabaseKey = Assert<Equal<Extract<keyof _CountElement, "database">, never>>;
|
|
64
76
|
|
|
65
|
-
// 1. The exposed service type is the
|
|
66
|
-
|
|
77
|
+
// 1. The exposed service type is the database-restricted UI view (FromService
|
|
78
|
+
// plus action masking).
|
|
79
|
+
type _CheckRestricted = Assert<Equal<ServiceType, UIService.FromDatabase<RawDatabase>>>;
|
|
67
80
|
|
|
68
81
|
// 2. Observe surfaces survive the restriction.
|
|
69
82
|
type _CheckResourceObserveSurvives = Assert<
|
|
@@ -114,6 +127,26 @@ type _CheckSetCountAsyncVoid = Assert<
|
|
|
114
127
|
Equal<ReturnType<ServiceType["transactions"]["setCount"]>, void>
|
|
115
128
|
>;
|
|
116
129
|
|
|
130
|
+
// 8. Action masking: a transaction shadowed by a same-named action is removed
|
|
131
|
+
// from the restricted `transactions`, so the UI can only reach it through
|
|
132
|
+
// the action. Unshadowed transactions are untouched, and the raw database
|
|
133
|
+
// still exposes the transaction (masking is a UI-view concern only).
|
|
134
|
+
type _CheckSaveTransactionMasked = Assert<
|
|
135
|
+
Equal<Extract<keyof ServiceType["transactions"], "save">, never>
|
|
136
|
+
>;
|
|
137
|
+
type _CheckSaveTransactionStillRaw = Assert<
|
|
138
|
+
Equal<Extract<keyof RawDatabase["transactions"], "save">, "save">
|
|
139
|
+
>;
|
|
140
|
+
type _CheckSaveActionSurvivesAsVoid = Assert<
|
|
141
|
+
Equal<ReturnType<ServiceType["actions"]["save"]>, void>
|
|
142
|
+
>;
|
|
143
|
+
type _CheckIncrementNotMasked = Assert<
|
|
144
|
+
Equal<Extract<keyof ServiceType["transactions"], "increment">, "increment">
|
|
145
|
+
>;
|
|
146
|
+
type _CheckSetCountNotMasked = Assert<
|
|
147
|
+
Equal<Extract<keyof ServiceType["transactions"], "setCount">, "setCount">
|
|
148
|
+
>;
|
|
149
|
+
|
|
117
150
|
// ----------------------------------------------------------------------------
|
|
118
151
|
// Local helpers (kept inline so this file stays a self-contained type test).
|
|
119
152
|
// ----------------------------------------------------------------------------
|