@conduit-client/adapter-module-init 3.8.0 → 3.10.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.
@@ -1,4 +1,4 @@
1
- import { type CommandWireAdapterConstructor } from '@conduit-client/lwc-bindings';
1
+ import { type CommandWireAdapterConstructor } from '@conduit-client/service-bindings-lwc/v1';
2
2
  import { type ConcreteConstructor } from '@conduit-client/utils';
3
3
  import { type WireAdapterConstructor, type WireConfigValue } from '@conduit-client/lwc-types';
4
4
  export type ConcreteCommandWireAdapterConstructor<Data, Config extends WireConfigValue = WireConfigValue> = ConcreteConstructor<typeof CommandWireAdapterConstructor<Data, Config>>;
package/dist/v1/index.js CHANGED
@@ -21,10 +21,10 @@ class StubWireAdapterConstructor {
21
21
  // we did an initial emit above, real wire adapter should not do another
22
22
  skipEmptyEmit: true
23
23
  });
24
- if (this.connected) {
24
+ if (this.connected && this.realWireAdapter) {
25
25
  this.realWireAdapter.connect();
26
26
  }
27
- if (this.config) {
27
+ if (this.config && this.realWireAdapter) {
28
28
  this.realWireAdapter.update(this.config, this.context);
29
29
  }
30
30
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/v1/CommandWireAdapterConstructor-stub.ts","../../src/v1/async-function-stub.ts"],"sourcesContent":["import { type CommandWireAdapterConstructor } from '@conduit-client/lwc-bindings';\nimport {\n type ConcreteConstructor,\n rejectedPromiseLike,\n resolvedPromiseLike,\n toError,\n} from '@conduit-client/utils';\nimport {\n type WireAdapter,\n type WireAdapterConstructor,\n type WireConfigValue,\n type WireContextValue,\n type WireDataCallback,\n} from '@conduit-client/lwc-types';\n\nexport type ConcreteCommandWireAdapterConstructor<\n Data,\n Config extends WireConfigValue = WireConfigValue,\n> = ConcreteConstructor<typeof CommandWireAdapterConstructor<Data, Config>>;\n\nclass StubWireAdapterConstructor<Data, Config extends WireConfigValue = WireConfigValue>\n implements WireAdapter\n{\n // queued state to be forwarded to the real wire adapter\n connected = false;\n config?: Config;\n context?: WireContextValue;\n realWireAdapter?: WireAdapter;\n\n constructor(\n realWireAdapterConstructor: PromiseLike<\n ConcreteCommandWireAdapterConstructor<Data, Config>\n >,\n protected callback: WireDataCallback,\n protected sourceContext?: {\n tagName?: string;\n }\n ) {\n try {\n this.callback({ data: undefined, error: undefined });\n } catch (e) {\n // TODO - need to handle this better\n throw toError(e);\n }\n\n realWireAdapterConstructor.then(\n (realWAC) => {\n this.realWireAdapter = new realWAC(this.callback, this.sourceContext, {\n // we did an initial emit above, real wire adapter should not do another\n skipEmptyEmit: true,\n });\n\n // copy queued state to new WireAdapter\n if (this.connected) {\n this.realWireAdapter.connect();\n }\n\n if (this.config) {\n this.realWireAdapter.update(this.config, this.context);\n }\n },\n (err) => {\n try {\n this.callback({ data: undefined, error: toError(err) });\n } catch (e) {\n // TODO - need to log this somewhere\n }\n }\n );\n }\n\n connect(): void {\n if (this.realWireAdapter) {\n this.realWireAdapter.connect();\n return;\n }\n\n this.connected = true;\n }\n\n disconnect(): void {\n if (this.realWireAdapter) {\n this.realWireAdapter.disconnect();\n return;\n }\n\n this.connected = false;\n }\n\n update(config: Config, context?: WireContextValue): void {\n if (this.realWireAdapter) {\n this.realWireAdapter.update(config, context);\n return;\n }\n\n this.config = config;\n this.context = context;\n }\n}\n\n/**\n * Returns a stub WireAdapterConstructor. If used, the stub will queue state until\n * a real wire adapter constructor is supplied.\n *\n * The stub is guaranteed to forward the wire adapter calls to the real wire adapter\n * synchronously iff realImplementation resolves synchronously. Once realImplementation\n * settles, all future calls to the stub are guaranteed to be forwarded/rejected\n * synchronously.\n *\n * @param realImplementation PromiseLike for the real implementation of the wire\n * adapter constructor. If realImplementation rejects, the stub will emit with the\n * same error.\n * @returns stub wire adapter constructor\n */\n\nexport function buildStubWireAdapterConstructor<\n Data,\n Config extends WireConfigValue = WireConfigValue,\n>(\n realWireAdapterConstructor: PromiseLike<ConcreteCommandWireAdapterConstructor<Data, Config>>\n): WireAdapterConstructor {\n let wacPromise = realWireAdapterConstructor;\n\n realWireAdapterConstructor.then(\n (realWAC) => {\n wacPromise = resolvedPromiseLike(realWAC);\n },\n (err) => {\n wacPromise = rejectedPromiseLike(err);\n }\n );\n\n return class extends StubWireAdapterConstructor<Data, Config> {\n constructor(\n callback: WireDataCallback,\n sourceContext?: {\n tagName?: string;\n }\n ) {\n super(wacPromise, callback, sourceContext);\n }\n };\n}\n","import { rejectedPromiseLike } from '@conduit-client/utils';\n\n/**\n * Returns a stub implementation of an async function. If called, the stub will\n * queue the call until a real implementation of the async function is supplied.\n *\n * The stub is guaranteed to forward the call to the real function synchronously\n * iff realImplementation resolves synchronously. Once realImplementation settles,\n * all future calls to the stub are guaranteed to be forwarded/rejected\n * synchronously.\n *\n * @param realImplementation PromiseLike for the real implementation of the async\n * function. If realImplementation rejects, all calls to the stub will reject\n * with the same error.\n * @returns async stub function\n */\nexport function buildAsyncFunctionStub<\n AsyncFunc extends (...params: Array<any>) => PromiseLike<unknown>,\n>(realImplementation: PromiseLike<AsyncFunc>): AsyncFunc {\n let realFunction: AsyncFunc | undefined;\n let errorResult: ReturnType<AsyncFunc> | undefined;\n\n return ((...params: Array<unknown>): PromiseLike<unknown> => {\n // synchronously passthrough to real function if we know it\n if (realFunction) {\n return realFunction(...params);\n }\n\n // synchronously reject if realImplementation previously rejected\n else if (errorResult) {\n return errorResult;\n }\n\n return realImplementation.then(\n (f) => {\n // save real function for next time\n realFunction = f;\n return f(...params);\n },\n (err) => {\n // save error for next time\n errorResult = rejectedPromiseLike(err) as ReturnType<AsyncFunc>;\n throw err;\n }\n );\n }) as AsyncFunc;\n}\n"],"names":[],"mappings":";;;;;;;AAoBA,MAAM,2BAEN;AAAA,EAOI,YACI,4BAGU,UACA,eAGZ;AAJY,SAAA,WAAA;AACA,SAAA,gBAAA;AAVd,SAAA,YAAY;AAcR,QAAI;AACA,WAAK,SAAS,EAAE,MAAM,QAAW,OAAO,QAAW;AAAA,IACvD,SAAS,GAAG;AAER,YAAM,Q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uBAEd,oBAAuD;AACrD,MAAI;AACJ,MAAI;AAEJ,UAAQ,IAAI,WAAiD;AAEzD,QAAI,cAAc;AACd,aAAO,aAAa,GAAG,MAAM;AAAA,IACjC,WAGS,aAAa;AAClB,aAAO;AAAA,IACX;AAEA,WAAO,mBAAmB;AAAA,MACtB,CAAC,MAAM;AAEH,uBAAe;AACf,eAAO,EAAE,GAAG,MAAM;AAAA,MACtB;AAAA,MACA,CAAC,QAAQ;AAEL,sBAAc,oBAAoB,GAAG;AACrC,cAAM;AAAA,MACV;AAAA,IAAA;AAAA,EAER;AACJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/CommandWireAdapterConstructor-stub.ts","../../src/v1/async-function-stub.ts"],"sourcesContent":["import { type CommandWireAdapterConstructor } from '@conduit-client/service-bindings-lwc/v1';\nimport {\n type ConcreteConstructor,\n rejectedPromiseLike,\n resolvedPromiseLike,\n toError,\n} from '@conduit-client/utils';\nimport {\n type WireAdapter,\n type WireAdapterConstructor,\n type WireConfigValue,\n type WireContextValue,\n type WireDataCallback,\n} from '@conduit-client/lwc-types';\n\nexport type ConcreteCommandWireAdapterConstructor<\n Data,\n Config extends WireConfigValue = WireConfigValue,\n> = ConcreteConstructor<typeof CommandWireAdapterConstructor<Data, Config>>;\n\nclass StubWireAdapterConstructor<Data, Config extends WireConfigValue = WireConfigValue>\n implements WireAdapter\n{\n // queued state to be forwarded to the real wire adapter\n connected = false;\n config?: Config;\n context?: WireContextValue;\n realWireAdapter?: WireAdapter;\n\n constructor(\n realWireAdapterConstructor: PromiseLike<\n ConcreteCommandWireAdapterConstructor<Data, Config>\n >,\n protected callback: WireDataCallback,\n protected sourceContext?: {\n tagName?: string;\n }\n ) {\n try {\n this.callback({ data: undefined, error: undefined });\n } catch (e) {\n // TODO - need to handle this better\n throw toError(e);\n }\n\n realWireAdapterConstructor.then(\n (realWAC) => {\n this.realWireAdapter = new realWAC(this.callback, this.sourceContext, {\n // we did an initial emit above, real wire adapter should not do another\n skipEmptyEmit: true,\n });\n\n // copy queued state to new WireAdapter\n if (this.connected && this.realWireAdapter) {\n this.realWireAdapter.connect();\n }\n\n if (this.config && this.realWireAdapter) {\n this.realWireAdapter.update(this.config, this.context);\n }\n },\n (err) => {\n try {\n this.callback({ data: undefined, error: toError(err) });\n } catch (e) {\n // TODO - need to log this somewhere\n }\n }\n );\n }\n\n connect(): void {\n if (this.realWireAdapter) {\n this.realWireAdapter.connect();\n return;\n }\n\n this.connected = true;\n }\n\n disconnect(): void {\n if (this.realWireAdapter) {\n this.realWireAdapter.disconnect();\n return;\n }\n\n this.connected = false;\n }\n\n update(config: Config, context?: WireContextValue): void {\n if (this.realWireAdapter) {\n this.realWireAdapter.update(config, context);\n return;\n }\n\n this.config = config;\n this.context = context;\n }\n}\n\n/**\n * Returns a stub WireAdapterConstructor. If used, the stub will queue state until\n * a real wire adapter constructor is supplied.\n *\n * The stub is guaranteed to forward the wire adapter calls to the real wire adapter\n * synchronously iff realImplementation resolves synchronously. Once realImplementation\n * settles, all future calls to the stub are guaranteed to be forwarded/rejected\n * synchronously.\n *\n * @param realImplementation PromiseLike for the real implementation of the wire\n * adapter constructor. If realImplementation rejects, the stub will emit with the\n * same error.\n * @returns stub wire adapter constructor\n */\n\nexport function buildStubWireAdapterConstructor<\n Data,\n Config extends WireConfigValue = WireConfigValue,\n>(\n realWireAdapterConstructor: PromiseLike<ConcreteCommandWireAdapterConstructor<Data, Config>>\n): WireAdapterConstructor {\n let wacPromise = realWireAdapterConstructor;\n\n realWireAdapterConstructor.then(\n (realWAC) => {\n wacPromise = resolvedPromiseLike(realWAC);\n },\n (err) => {\n wacPromise = rejectedPromiseLike(err);\n }\n );\n\n return class extends StubWireAdapterConstructor<Data, Config> {\n constructor(\n callback: WireDataCallback,\n sourceContext?: {\n tagName?: string;\n }\n ) {\n super(wacPromise, callback, sourceContext);\n }\n };\n}\n","import { rejectedPromiseLike } from '@conduit-client/utils';\n\n/**\n * Returns a stub implementation of an async function. If called, the stub will\n * queue the call until a real implementation of the async function is supplied.\n *\n * The stub is guaranteed to forward the call to the real function synchronously\n * iff realImplementation resolves synchronously. Once realImplementation settles,\n * all future calls to the stub are guaranteed to be forwarded/rejected\n * synchronously.\n *\n * @param realImplementation PromiseLike for the real implementation of the async\n * function. If realImplementation rejects, all calls to the stub will reject\n * with the same error.\n * @returns async stub function\n */\nexport function buildAsyncFunctionStub<\n AsyncFunc extends (...params: Array<any>) => PromiseLike<unknown>,\n>(realImplementation: PromiseLike<AsyncFunc>): AsyncFunc {\n let realFunction: AsyncFunc | undefined;\n let errorResult: ReturnType<AsyncFunc> | undefined;\n\n return ((...params: Array<unknown>): PromiseLike<unknown> => {\n // synchronously passthrough to real function if we know it\n if (realFunction) {\n return realFunction(...params);\n }\n\n // synchronously reject if realImplementation previously rejected\n else if (errorResult) {\n return errorResult;\n }\n\n return realImplementation.then(\n (f) => {\n // save real function for next time\n realFunction = f;\n return f(...params);\n },\n (err) => {\n // save error for next time\n errorResult = rejectedPromiseLike(err) as ReturnType<AsyncFunc>;\n throw err;\n }\n );\n }) as AsyncFunc;\n}\n"],"names":[],"mappings":";;;;;;;AAoBA,MAAM,2BAEN;AAAA,EAOI,YACI,4BAGU,UACA,eAGZ;AAJY,SAAA,WAAA;AACA,SAAA,gBAAA;AAVd,SAAA,YAAY;AAcR,QAAI;AACA,WAAK,SAAS,EAAE,MAAM,QAAW,OAAO,QAAW;AAAA,IACvD,SAAS,GAAG;AAER,YAAM,QAAQ,CAAC;AAAA,IACnB;AAEA,+BAA2B;AAAA,MACvB,CAAC,YAAY;AACT,aAAK,kBAAkB,IAAI,QAAQ,KAAK,UAAU,KAAK,eAAe;AAAA;AAAA,UAElE,eAAe;AAAA,QAAA,CAClB;AAGD,YAAI,KAAK,aAAa,KAAK,iBAAiB;AACxC,eAAK,gBAAgB,QAAA;AAAA,QACzB;AAEA,YAAI,KAAK,UAAU,KAAK,iBAAiB;AACrC,eAAK,gBAAgB,OAAO,KAAK,QAAQ,KAAK,O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Ac,oBAAoB,GAAG;AACrC,cAAM;AAAA,MACV;AAAA,IAAA;AAAA,EAER;AACJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduit-client/adapter-module-init",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "private": false,
5
5
  "description": "Luvio Adapter Module initialization",
6
6
  "type": "module",
@@ -31,11 +31,9 @@
31
31
  "watch": "npm run build --watch"
32
32
  },
33
33
  "dependencies": {
34
- "@conduit-client/lwc-types": "3.8.0",
35
- "@conduit-client/utils": "3.8.0"
36
- },
37
- "devDependencies": {
38
- "@conduit-client/lwc-bindings": "3.8.0"
34
+ "@conduit-client/lwc-types": "3.10.0",
35
+ "@conduit-client/service-bindings-lwc": "3.10.0",
36
+ "@conduit-client/utils": "3.10.0"
39
37
  },
40
38
  "volta": {
41
39
  "extends": "../../../package.json"
@@ -43,7 +41,7 @@
43
41
  "size-limit": [
44
42
  {
45
43
  "path": "./dist/v1/index.js",
46
- "limit": "700 B"
44
+ "limit": "750 B"
47
45
  }
48
46
  ]
49
47
  }