@luvio/lwc-luvio 0.98.0 → 0.99.0
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/es/es2018/LWCGraphQLLuvioWireAdapter.d.ts +35 -0
- package/dist/es/es2018/LWCLuvioWireAdapter.d.ts +2 -1
- package/dist/es/es2018/lwcluvio.js +63 -3
- package/dist/es/es2018/main.d.ts +2 -1
- package/dist/es/es2018/utils/SnapshotState.d.ts +1 -1
- package/dist/umd/es2018/LWCGraphQLLuvioWireAdapter.d.ts +35 -0
- package/dist/umd/es2018/LWCLuvioWireAdapter.d.ts +2 -1
- package/dist/umd/es2018/lwcluvio.js +63 -2
- package/dist/umd/es2018/main.d.ts +2 -1
- package/dist/umd/es2018/utils/SnapshotState.d.ts +1 -1
- package/dist/umd/es5/LWCGraphQLLuvioWireAdapter.d.ts +35 -0
- package/dist/umd/es5/LWCLuvioWireAdapter.d.ts +2 -1
- package/dist/umd/es5/lwcluvio.js +70 -2
- package/dist/umd/es5/main.d.ts +2 -1
- package/dist/umd/es5/utils/SnapshotState.d.ts +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
5
|
+
export declare type GraphQLError = {
|
|
6
|
+
message: string;
|
|
7
|
+
locations?: Array<{
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
}>;
|
|
11
|
+
path?: Array<string | number>;
|
|
12
|
+
extensions?: Record<string, any>;
|
|
13
|
+
};
|
|
14
|
+
export declare type GraphQLResponse = {
|
|
15
|
+
data: any;
|
|
16
|
+
errors?: GraphQLError[];
|
|
17
|
+
} | {
|
|
18
|
+
errors: GraphQLError[];
|
|
19
|
+
};
|
|
20
|
+
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
21
|
+
/**
|
|
22
|
+
* Emits new values to the callback.
|
|
23
|
+
*
|
|
24
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
25
|
+
*/
|
|
26
|
+
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
30
|
+
*
|
|
31
|
+
* @param adapter Adapter
|
|
32
|
+
* @param name name to assign to the generated constructor
|
|
33
|
+
* @param luvio Luvio
|
|
34
|
+
*/
|
|
35
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
3
4
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
4
5
|
adapter: Adapter<unknown, unknown>;
|
|
5
6
|
name: string;
|
|
@@ -39,7 +40,7 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
protected emit(snapshot?: EmittableSnapshot): void;
|
|
43
44
|
/**
|
|
44
45
|
* Subscribes this wire adapter to future changes to the specified snapshot. Any changes
|
|
45
46
|
* to the snapshot will be automatically emitted to the component.
|
|
@@ -35,7 +35,7 @@ function isUnfulfilledSnapshot(snapshot) {
|
|
|
35
35
|
*
|
|
36
36
|
* @param snapshot Snapshot
|
|
37
37
|
*/
|
|
38
|
-
function snapshotToPayload(snapshot) {
|
|
38
|
+
function snapshotToPayload$1(snapshot) {
|
|
39
39
|
if (snapshot === undefined) {
|
|
40
40
|
return {
|
|
41
41
|
data: undefined,
|
|
@@ -291,7 +291,7 @@ class LWCLuvioWireAdapter {
|
|
|
291
291
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
292
292
|
*/
|
|
293
293
|
emit(snapshot) {
|
|
294
|
-
const payload = snapshotToPayload(snapshot);
|
|
294
|
+
const payload = snapshotToPayload$1(snapshot);
|
|
295
295
|
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
296
296
|
try {
|
|
297
297
|
this.callback(payload);
|
|
@@ -405,4 +405,64 @@ function createInfiniteScrollingWireAdapterConstructor(adapter, name, luvio) {
|
|
|
405
405
|
return constructor;
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
-
|
|
408
|
+
function snapshotToPayload(snapshot) {
|
|
409
|
+
if (snapshot === undefined) {
|
|
410
|
+
return {
|
|
411
|
+
data: undefined,
|
|
412
|
+
errors: undefined,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (isErrorSnapshot(snapshot)) {
|
|
416
|
+
return {
|
|
417
|
+
data: undefined,
|
|
418
|
+
errors: [snapshot.error],
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
// fulfilled or stale
|
|
422
|
+
const payload = {};
|
|
423
|
+
if ('data' in snapshot.data && snapshot.data.data !== undefined) {
|
|
424
|
+
payload.data = snapshot.data.data;
|
|
425
|
+
}
|
|
426
|
+
if (snapshot.data.errors !== undefined) {
|
|
427
|
+
payload.errors = snapshot.data.errors;
|
|
428
|
+
}
|
|
429
|
+
return payload;
|
|
430
|
+
}
|
|
431
|
+
class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
432
|
+
/**
|
|
433
|
+
* Emits new values to the callback.
|
|
434
|
+
*
|
|
435
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
436
|
+
*/
|
|
437
|
+
emit(snapshot) {
|
|
438
|
+
const payload = snapshotToPayload(snapshot);
|
|
439
|
+
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
440
|
+
try {
|
|
441
|
+
this.callback(payload);
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
if (error instanceof Error) {
|
|
445
|
+
throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
452
|
+
*
|
|
453
|
+
* @param adapter Adapter
|
|
454
|
+
* @param name name to assign to the generated constructor
|
|
455
|
+
* @param luvio Luvio
|
|
456
|
+
*/
|
|
457
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio) {
|
|
458
|
+
const constructor = function (callback) {
|
|
459
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, callback);
|
|
460
|
+
this.connect = () => delegate.connect();
|
|
461
|
+
this.disconnect = () => delegate.disconnect();
|
|
462
|
+
this.update = (config, context) => delegate.update(config, context);
|
|
463
|
+
};
|
|
464
|
+
Object.defineProperty(constructor, 'name', { value: name });
|
|
465
|
+
return constructor;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export { ADAPTER_UNFULFILLED_ERROR, REFRESH_ADAPTER_EVENT, bindWireRefresh, createGraphQLWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createWireAdapterConstructor, refreshData };
|
package/dist/es/es2018/main.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './utils/consta
|
|
|
2
2
|
import { bindWireRefresh, refreshData } from './LWCLuvioBindings';
|
|
3
3
|
import { createWireAdapterConstructor } from './LWCLuvioWireAdapter';
|
|
4
4
|
import { createInfiniteScrollingWireAdapterConstructor } from './LWCInfiniteScrollingLuvioWireAdapter';
|
|
5
|
-
|
|
5
|
+
import { createGraphQLWireAdapterConstructor } from './LWCGraphQLLuvioWireAdapter';
|
|
6
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
@@ -3,7 +3,7 @@ export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): s
|
|
|
3
3
|
export declare function isFulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is FulfilledSnapshot<unknown, unknown>;
|
|
4
4
|
export declare function isStaleSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is StaleSnapshot<unknown, unknown>;
|
|
5
5
|
export declare function isUnfulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is UnfulfilledSnapshot<unknown, unknown>;
|
|
6
|
-
export declare type EmittableSnapshot = FulfilledSnapshot<
|
|
6
|
+
export declare type EmittableSnapshot<T = unknown> = FulfilledSnapshot<T> | StaleSnapshot<T> | ErrorSnapshot;
|
|
7
7
|
/**
|
|
8
8
|
* Transform a Snapshot into a payload suitable for passing to a DataCallback.
|
|
9
9
|
*
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
5
|
+
export declare type GraphQLError = {
|
|
6
|
+
message: string;
|
|
7
|
+
locations?: Array<{
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
}>;
|
|
11
|
+
path?: Array<string | number>;
|
|
12
|
+
extensions?: Record<string, any>;
|
|
13
|
+
};
|
|
14
|
+
export declare type GraphQLResponse = {
|
|
15
|
+
data: any;
|
|
16
|
+
errors?: GraphQLError[];
|
|
17
|
+
} | {
|
|
18
|
+
errors: GraphQLError[];
|
|
19
|
+
};
|
|
20
|
+
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
21
|
+
/**
|
|
22
|
+
* Emits new values to the callback.
|
|
23
|
+
*
|
|
24
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
25
|
+
*/
|
|
26
|
+
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
30
|
+
*
|
|
31
|
+
* @param adapter Adapter
|
|
32
|
+
* @param name name to assign to the generated constructor
|
|
33
|
+
* @param luvio Luvio
|
|
34
|
+
*/
|
|
35
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
3
4
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
4
5
|
adapter: Adapter<unknown, unknown>;
|
|
5
6
|
name: string;
|
|
@@ -39,7 +40,7 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
protected emit(snapshot?: EmittableSnapshot): void;
|
|
43
44
|
/**
|
|
44
45
|
* Subscribes this wire adapter to future changes to the specified snapshot. Any changes
|
|
45
46
|
* to the snapshot will be automatically emitted to the component.
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
*
|
|
40
40
|
* @param snapshot Snapshot
|
|
41
41
|
*/
|
|
42
|
-
function snapshotToPayload(snapshot) {
|
|
42
|
+
function snapshotToPayload$1(snapshot) {
|
|
43
43
|
if (snapshot === undefined) {
|
|
44
44
|
return {
|
|
45
45
|
data: undefined,
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
296
296
|
*/
|
|
297
297
|
emit(snapshot) {
|
|
298
|
-
const payload = snapshotToPayload(snapshot);
|
|
298
|
+
const payload = snapshotToPayload$1(snapshot);
|
|
299
299
|
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
300
300
|
try {
|
|
301
301
|
this.callback(payload);
|
|
@@ -409,9 +409,70 @@
|
|
|
409
409
|
return constructor;
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
function snapshotToPayload(snapshot) {
|
|
413
|
+
if (snapshot === undefined) {
|
|
414
|
+
return {
|
|
415
|
+
data: undefined,
|
|
416
|
+
errors: undefined,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
if (isErrorSnapshot(snapshot)) {
|
|
420
|
+
return {
|
|
421
|
+
data: undefined,
|
|
422
|
+
errors: [snapshot.error],
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
// fulfilled or stale
|
|
426
|
+
const payload = {};
|
|
427
|
+
if ('data' in snapshot.data && snapshot.data.data !== undefined) {
|
|
428
|
+
payload.data = snapshot.data.data;
|
|
429
|
+
}
|
|
430
|
+
if (snapshot.data.errors !== undefined) {
|
|
431
|
+
payload.errors = snapshot.data.errors;
|
|
432
|
+
}
|
|
433
|
+
return payload;
|
|
434
|
+
}
|
|
435
|
+
class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
436
|
+
/**
|
|
437
|
+
* Emits new values to the callback.
|
|
438
|
+
*
|
|
439
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
440
|
+
*/
|
|
441
|
+
emit(snapshot) {
|
|
442
|
+
const payload = snapshotToPayload(snapshot);
|
|
443
|
+
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
444
|
+
try {
|
|
445
|
+
this.callback(payload);
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
if (error instanceof Error) {
|
|
449
|
+
throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
456
|
+
*
|
|
457
|
+
* @param adapter Adapter
|
|
458
|
+
* @param name name to assign to the generated constructor
|
|
459
|
+
* @param luvio Luvio
|
|
460
|
+
*/
|
|
461
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio) {
|
|
462
|
+
const constructor = function (callback) {
|
|
463
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, callback);
|
|
464
|
+
this.connect = () => delegate.connect();
|
|
465
|
+
this.disconnect = () => delegate.disconnect();
|
|
466
|
+
this.update = (config, context) => delegate.update(config, context);
|
|
467
|
+
};
|
|
468
|
+
Object.defineProperty(constructor, 'name', { value: name });
|
|
469
|
+
return constructor;
|
|
470
|
+
}
|
|
471
|
+
|
|
412
472
|
exports.ADAPTER_UNFULFILLED_ERROR = ADAPTER_UNFULFILLED_ERROR;
|
|
413
473
|
exports.REFRESH_ADAPTER_EVENT = REFRESH_ADAPTER_EVENT;
|
|
414
474
|
exports.bindWireRefresh = bindWireRefresh;
|
|
475
|
+
exports.createGraphQLWireAdapterConstructor = createGraphQLWireAdapterConstructor;
|
|
415
476
|
exports.createInfiniteScrollingWireAdapterConstructor = createInfiniteScrollingWireAdapterConstructor;
|
|
416
477
|
exports.createWireAdapterConstructor = createWireAdapterConstructor;
|
|
417
478
|
exports.refreshData = refreshData;
|
|
@@ -2,4 +2,5 @@ import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './utils/consta
|
|
|
2
2
|
import { bindWireRefresh, refreshData } from './LWCLuvioBindings';
|
|
3
3
|
import { createWireAdapterConstructor } from './LWCLuvioWireAdapter';
|
|
4
4
|
import { createInfiniteScrollingWireAdapterConstructor } from './LWCInfiniteScrollingLuvioWireAdapter';
|
|
5
|
-
|
|
5
|
+
import { createGraphQLWireAdapterConstructor } from './LWCGraphQLLuvioWireAdapter';
|
|
6
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
@@ -3,7 +3,7 @@ export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): s
|
|
|
3
3
|
export declare function isFulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is FulfilledSnapshot<unknown, unknown>;
|
|
4
4
|
export declare function isStaleSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is StaleSnapshot<unknown, unknown>;
|
|
5
5
|
export declare function isUnfulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is UnfulfilledSnapshot<unknown, unknown>;
|
|
6
|
-
export declare type EmittableSnapshot = FulfilledSnapshot<
|
|
6
|
+
export declare type EmittableSnapshot<T = unknown> = FulfilledSnapshot<T> | StaleSnapshot<T> | ErrorSnapshot;
|
|
7
7
|
/**
|
|
8
8
|
* Transform a Snapshot into a payload suitable for passing to a DataCallback.
|
|
9
9
|
*
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
5
|
+
export declare type GraphQLError = {
|
|
6
|
+
message: string;
|
|
7
|
+
locations?: Array<{
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
}>;
|
|
11
|
+
path?: Array<string | number>;
|
|
12
|
+
extensions?: Record<string, any>;
|
|
13
|
+
};
|
|
14
|
+
export declare type GraphQLResponse = {
|
|
15
|
+
data: any;
|
|
16
|
+
errors?: GraphQLError[];
|
|
17
|
+
} | {
|
|
18
|
+
errors: GraphQLError[];
|
|
19
|
+
};
|
|
20
|
+
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
21
|
+
/**
|
|
22
|
+
* Emits new values to the callback.
|
|
23
|
+
*
|
|
24
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
25
|
+
*/
|
|
26
|
+
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
30
|
+
*
|
|
31
|
+
* @param adapter Adapter
|
|
32
|
+
* @param name name to assign to the generated constructor
|
|
33
|
+
* @param luvio Luvio
|
|
34
|
+
*/
|
|
35
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
3
4
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
4
5
|
adapter: Adapter<unknown, unknown>;
|
|
5
6
|
name: string;
|
|
@@ -39,7 +40,7 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
protected emit(snapshot?: EmittableSnapshot): void;
|
|
43
44
|
/**
|
|
44
45
|
* Subscribes this wire adapter to future changes to the specified snapshot. Any changes
|
|
45
46
|
* to the snapshot will be automatically emitted to the component.
|
package/dist/umd/es5/lwcluvio.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
*
|
|
40
40
|
* @param snapshot Snapshot
|
|
41
41
|
*/
|
|
42
|
-
function snapshotToPayload(snapshot) {
|
|
42
|
+
function snapshotToPayload$1(snapshot) {
|
|
43
43
|
if (snapshot === undefined) {
|
|
44
44
|
return {
|
|
45
45
|
data: undefined,
|
|
@@ -301,7 +301,7 @@
|
|
|
301
301
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
302
302
|
*/
|
|
303
303
|
LWCLuvioWireAdapter.prototype.emit = function (snapshot) {
|
|
304
|
-
var payload = snapshotToPayload(snapshot);
|
|
304
|
+
var payload = snapshotToPayload$1(snapshot);
|
|
305
305
|
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
306
306
|
try {
|
|
307
307
|
this.callback(payload);
|
|
@@ -456,9 +456,77 @@
|
|
|
456
456
|
return constructor;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
+
function snapshotToPayload(snapshot) {
|
|
460
|
+
if (snapshot === undefined) {
|
|
461
|
+
return {
|
|
462
|
+
data: undefined,
|
|
463
|
+
errors: undefined,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
if (isErrorSnapshot(snapshot)) {
|
|
467
|
+
return {
|
|
468
|
+
data: undefined,
|
|
469
|
+
errors: [snapshot.error],
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
// fulfilled or stale
|
|
473
|
+
var payload = {};
|
|
474
|
+
if ('data' in snapshot.data && snapshot.data.data !== undefined) {
|
|
475
|
+
payload.data = snapshot.data.data;
|
|
476
|
+
}
|
|
477
|
+
if (snapshot.data.errors !== undefined) {
|
|
478
|
+
payload.errors = snapshot.data.errors;
|
|
479
|
+
}
|
|
480
|
+
return payload;
|
|
481
|
+
}
|
|
482
|
+
var LWCGraphQLLuvioWireAdapter = /** @class */ (function (_super) {
|
|
483
|
+
__extends(LWCGraphQLLuvioWireAdapter, _super);
|
|
484
|
+
function LWCGraphQLLuvioWireAdapter() {
|
|
485
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Emits new values to the callback.
|
|
489
|
+
*
|
|
490
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
491
|
+
*/
|
|
492
|
+
LWCGraphQLLuvioWireAdapter.prototype.emit = function (snapshot) {
|
|
493
|
+
var payload = snapshotToPayload(snapshot);
|
|
494
|
+
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
495
|
+
try {
|
|
496
|
+
this.callback(payload);
|
|
497
|
+
}
|
|
498
|
+
catch (error) {
|
|
499
|
+
if (error instanceof Error) {
|
|
500
|
+
throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
return LWCGraphQLLuvioWireAdapter;
|
|
505
|
+
}(LWCLuvioWireAdapter));
|
|
506
|
+
/**
|
|
507
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
508
|
+
*
|
|
509
|
+
* @param adapter Adapter
|
|
510
|
+
* @param name name to assign to the generated constructor
|
|
511
|
+
* @param luvio Luvio
|
|
512
|
+
*/
|
|
513
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio) {
|
|
514
|
+
var constructor = function (callback) {
|
|
515
|
+
var delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, callback);
|
|
516
|
+
this.connect = function () { return delegate.connect(); };
|
|
517
|
+
this.disconnect = function () { return delegate.disconnect(); };
|
|
518
|
+
this.update = function (config, context) {
|
|
519
|
+
return delegate.update(config, context);
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
Object.defineProperty(constructor, 'name', { value: name });
|
|
523
|
+
return constructor;
|
|
524
|
+
}
|
|
525
|
+
|
|
459
526
|
exports.ADAPTER_UNFULFILLED_ERROR = ADAPTER_UNFULFILLED_ERROR;
|
|
460
527
|
exports.REFRESH_ADAPTER_EVENT = REFRESH_ADAPTER_EVENT;
|
|
461
528
|
exports.bindWireRefresh = bindWireRefresh;
|
|
529
|
+
exports.createGraphQLWireAdapterConstructor = createGraphQLWireAdapterConstructor;
|
|
462
530
|
exports.createInfiniteScrollingWireAdapterConstructor = createInfiniteScrollingWireAdapterConstructor;
|
|
463
531
|
exports.createWireAdapterConstructor = createWireAdapterConstructor;
|
|
464
532
|
exports.refreshData = refreshData;
|
package/dist/umd/es5/main.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './utils/consta
|
|
|
2
2
|
import { bindWireRefresh, refreshData } from './LWCLuvioBindings';
|
|
3
3
|
import { createWireAdapterConstructor } from './LWCLuvioWireAdapter';
|
|
4
4
|
import { createInfiniteScrollingWireAdapterConstructor } from './LWCInfiniteScrollingLuvioWireAdapter';
|
|
5
|
-
|
|
5
|
+
import { createGraphQLWireAdapterConstructor } from './LWCGraphQLLuvioWireAdapter';
|
|
6
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
@@ -3,7 +3,7 @@ export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): s
|
|
|
3
3
|
export declare function isFulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is FulfilledSnapshot<unknown, unknown>;
|
|
4
4
|
export declare function isStaleSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is StaleSnapshot<unknown, unknown>;
|
|
5
5
|
export declare function isUnfulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is UnfulfilledSnapshot<unknown, unknown>;
|
|
6
|
-
export declare type EmittableSnapshot = FulfilledSnapshot<
|
|
6
|
+
export declare type EmittableSnapshot<T = unknown> = FulfilledSnapshot<T> | StaleSnapshot<T> | ErrorSnapshot;
|
|
7
7
|
/**
|
|
8
8
|
* Transform a Snapshot into a payload suitable for passing to a DataCallback.
|
|
9
9
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/lwc-luvio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
4
4
|
"description": "Lightning Web Component bindings for Luvio",
|
|
5
5
|
"main": "dist/umd/es2018/lwcluvio.js",
|
|
6
6
|
"module": "dist/es/es2018/lwcluvio.js",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"dist/"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@luvio/adapter-test-library": "0.
|
|
37
|
-
"@luvio/cli": "0.
|
|
36
|
+
"@luvio/adapter-test-library": "0.99.0",
|
|
37
|
+
"@luvio/cli": "0.99.0",
|
|
38
38
|
"@lwc/jest-preset": "11.2.2"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@luvio/engine": "0.
|
|
41
|
+
"@luvio/engine": "0.99.0",
|
|
42
42
|
"@lwc/engine-core": "2.11.3"
|
|
43
43
|
},
|
|
44
44
|
"bundlesize": [
|