@anker-in/lib 1.1.3 → 1.1.4

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,20 +1,20 @@
1
1
 
2
- > @anker-in/lib@1.1.2-beta.2 build /Users/anker/Code/headless-ui/packages/lib
2
+ > @anker-in/lib@1.1.3 build /Users/anker/Code/headless-ui/packages/lib
3
3
  > pnpm run build:js:esm & pnpm run build:js:cjs & pnpm run build:types:esm & pnpm run build:types:cjs
4
4
 
5
5
 
6
- > @anker-in/lib@1.1.2-beta.2 build:js:cjs /Users/anker/Code/headless-ui/packages/lib
6
+ > @anker-in/lib@1.1.3 build:js:cjs /Users/anker/Code/headless-ui/packages/lib
7
7
  > node esbuild-cjs.mjs
8
8
 
9
9
 
10
- > @anker-in/lib@1.1.2-beta.2 build:js:esm /Users/anker/Code/headless-ui/packages/lib
10
+ > @anker-in/lib@1.1.3 build:js:esm /Users/anker/Code/headless-ui/packages/lib
11
11
  > node esbuild-esm.mjs
12
12
 
13
13
 
14
- > @anker-in/lib@1.1.2-beta.2 build:types:cjs /Users/anker/Code/headless-ui/packages/lib
15
- > tsc --outdir dist/cjs
14
+ > @anker-in/lib@1.1.3 build:types:esm /Users/anker/Code/headless-ui/packages/lib
15
+ > tsc --outdir dist/esm
16
16
 
17
17
 
18
- > @anker-in/lib@1.1.2-beta.2 build:types:esm /Users/anker/Code/headless-ui/packages/lib
19
- > tsc --outdir dist/esm
18
+ > @anker-in/lib@1.1.3 build:types:cjs /Users/anker/Code/headless-ui/packages/lib
19
+ > tsc --outdir dist/cjs
20
20
 
@@ -1,15 +1,4 @@
1
- import { SWRResponse } from 'swr';
2
- export interface Subscription {
3
- preference: {
4
- subscribe: boolean;
5
- brand: string;
6
- }[];
7
- }
8
- export type SubscriptionApiResponse = {
9
- data: Subscription;
10
- };
11
- export type FetchSubscriptionResponse = SWRResponse<Subscription>;
12
1
  export declare function useSubscriptions({ email }: {
13
2
  email?: string;
14
- }): FetchSubscriptionResponse;
3
+ }): import("swr").SWRResponse<any, any, any>;
15
4
  //# sourceMappingURL=useSubscriptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSubscriptions.d.ts","sourceRoot":"","sources":["../../../../src/registration/hooks/useSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAKzC,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE,OAAO,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ;AAED,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAA;AAC5D,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,YAAY,CAAC,CAAA;AAEjE,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,yBAAyB,CAoBzF"}
1
+ {"version":3,"file":"useSubscriptions.d.ts","sourceRoot":"","sources":["../../../../src/registration/hooks/useSubscriptions.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,4CAgB7D"}
@@ -1,2 +1,2 @@
1
- "use strict";var b=Object.create;var i=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var m=(e,s)=>{for(var t in s)i(e,t,{get:s[t],enumerable:!0})},p=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of R(s))!l.call(e,o)&&o!==t&&i(e,o,{get:()=>s[o],enumerable:!(n=S(s,o))||n.enumerable});return e};var f=(e,s,t)=>(t=e!=null?b(d(e)):{},p(s||!e||!e.__esModule?i(t,"default",{value:e,enumerable:!0}):t,e)),h=e=>p(i({},"__esModule",{value:!0}),e);var y={};m(y,{useSubscriptions:()=>x});module.exports=h(y);var r=f(require("swr")),c=require("../../context"),a=require("../../utils");function x({email:e}){const{locale:s}=(0,c.useHeadlessContext)(),{data:t,...n}=(0,r.default)(e?["/api/multipass/account/subscriptions",e]:null,async([o,u])=>(0,a.fetcher)({method:"GET",url:o,body:{email:u},action:"login",locale:s,headers:{},type:""}));return{data:t?.data,...n}}
1
+ "use strict";var a=Object.create;var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var b=(o,t)=>{for(var s in t)i(o,s,{get:t[s],enumerable:!0})},n=(o,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of l(t))!d.call(o,e)&&e!==s&&i(o,e,{get:()=>t[e],enumerable:!(r=m(t,e))||r.enumerable});return o};var h=(o,t,s)=>(s=o!=null?a(f(o)):{},n(t||!o||!o.__esModule?i(s,"default",{value:o,enumerable:!0}):s,o)),y=o=>n(i({},"__esModule",{value:!0}),o);var x={};b(x,{useSubscriptions:()=>g});module.exports=y(x);var c=h(require("swr")),u=require("../../context"),p=require("../../utils");function g({email:o}){const{locale:t}=(0,u.useHeadlessContext)();return(0,c.default)(o?["/api/multipass/account/subscriptions",o]:null,async([s,r])=>(0,p.fetcher)({method:"GET",url:s,body:{email:r},action:"login",locale:t,headers:{},type:""}))}
2
2
  //# sourceMappingURL=useSubscriptions.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/registration/hooks/useSubscriptions.ts"],
4
- "sourcesContent": ["import useSWR, { SWRResponse } from 'swr'\n\nimport { useHeadlessContext } from '../../context'\nimport { fetcher } from '../../utils'\n\nexport interface Subscription {\n preference: {\n subscribe: boolean\n brand: string\n }[]\n}\n\nexport type SubscriptionApiResponse = { data: Subscription }\nexport type FetchSubscriptionResponse = SWRResponse<Subscription>\n\nexport function useSubscriptions({ email }: { email?: string }): FetchSubscriptionResponse {\n const { locale } = useHeadlessContext()\n\n const { data, ...rest } = useSWR<SubscriptionApiResponse>(\n email ? ['/api/multipass/account/subscriptions', email] : null,\n async ([url, email]) =>\n fetcher({\n method: 'GET',\n url,\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n )\n\n return { data: data?.data, ...rest } as unknown as FetchSubscriptionResponse\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,kBAEpCC,EAAmC,yBACnCC,EAAwB,uBAYjB,SAASJ,EAAiB,CAAE,MAAAK,CAAM,EAAkD,CACzF,KAAM,CAAE,OAAAC,CAAO,KAAI,sBAAmB,EAEhC,CAAE,KAAAC,EAAM,GAAGC,CAAK,KAAI,EAAAC,SACxBJ,EAAQ,CAAC,uCAAwCA,CAAK,EAAI,KAC1D,MAAO,CAACK,EAAKL,CAAK,OAChB,WAAQ,CACN,OAAQ,MACR,IAAAK,EACA,KAAM,CACJ,MAAAL,CACF,EACA,OAAQ,QACR,OAAAC,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,CACL,EAEA,MAAO,CAAE,KAAMC,GAAM,KAAM,GAAGC,CAAK,CACrC",
6
- "names": ["useSubscriptions_exports", "__export", "useSubscriptions", "__toCommonJS", "import_swr", "import_context", "import_utils", "email", "locale", "data", "rest", "useSWR", "url"]
4
+ "sourcesContent": ["import useSWR from 'swr'\n\nimport { useHeadlessContext } from '../../context'\nimport { fetcher } from '../../utils'\n\nexport function useSubscriptions({ email }: { email?: string }) {\n const { locale } = useHeadlessContext()\n\n return useSWR(email ? ['/api/multipass/account/subscriptions', email] : null, async ([url, email]) =>\n fetcher({\n method: 'GET',\n url,\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmB,kBAEnBC,EAAmC,yBACnCC,EAAwB,uBAEjB,SAASJ,EAAiB,CAAE,MAAAK,CAAM,EAAuB,CAC9D,KAAM,CAAE,OAAAC,CAAO,KAAI,sBAAmB,EAEtC,SAAO,EAAAC,SAAOF,EAAQ,CAAC,uCAAwCA,CAAK,EAAI,KAAM,MAAO,CAACG,EAAKH,CAAK,OAC9F,WAAQ,CACN,OAAQ,MACR,IAAAG,EACA,KAAM,CACJ,MAAAH,CACF,EACA,OAAQ,QACR,OAAAC,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,CACH,CACF",
6
+ "names": ["useSubscriptions_exports", "__export", "useSubscriptions", "__toCommonJS", "import_swr", "import_context", "import_utils", "email", "locale", "useSWR", "url"]
7
7
  }
@@ -1,15 +1,4 @@
1
- import { SWRResponse } from 'swr';
2
- export interface Subscription {
3
- preference: {
4
- subscribe: boolean;
5
- brand: string;
6
- }[];
7
- }
8
- export type SubscriptionApiResponse = {
9
- data: Subscription;
10
- };
11
- export type FetchSubscriptionResponse = SWRResponse<Subscription>;
12
1
  export declare function useSubscriptions({ email }: {
13
2
  email?: string;
14
- }): FetchSubscriptionResponse;
3
+ }): import("swr").SWRResponse<any, any, any>;
15
4
  //# sourceMappingURL=useSubscriptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSubscriptions.d.ts","sourceRoot":"","sources":["../../../../src/registration/hooks/useSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAKzC,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE,OAAO,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ;AAED,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAA;AAC5D,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,YAAY,CAAC,CAAA;AAEjE,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,yBAAyB,CAoBzF"}
1
+ {"version":3,"file":"useSubscriptions.d.ts","sourceRoot":"","sources":["../../../../src/registration/hooks/useSubscriptions.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,4CAgB7D"}
@@ -1,2 +1,2 @@
1
- import p from"swr";import{useHeadlessContext as r}from"../../context";import{fetcher as c}from"../../utils";function R({email:e}){const{locale:s}=r(),{data:t,...o}=p(e?["/api/multipass/account/subscriptions",e]:null,async([n,i])=>c({method:"GET",url:n,body:{email:i},action:"login",locale:s,headers:{},type:""}));return{data:t?.data,...o}}export{R as useSubscriptions};
1
+ import r from"swr";import{useHeadlessContext as i}from"../../context";import{fetcher as n}from"../../utils";function a({email:o}){const{locale:t}=i();return r(o?["/api/multipass/account/subscriptions",o]:null,async([s,e])=>n({method:"GET",url:s,body:{email:e},action:"login",locale:t,headers:{},type:""}))}export{a as useSubscriptions};
2
2
  //# sourceMappingURL=useSubscriptions.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/registration/hooks/useSubscriptions.ts"],
4
- "sourcesContent": ["import useSWR, { SWRResponse } from 'swr'\n\nimport { useHeadlessContext } from '../../context'\nimport { fetcher } from '../../utils'\n\nexport interface Subscription {\n preference: {\n subscribe: boolean\n brand: string\n }[]\n}\n\nexport type SubscriptionApiResponse = { data: Subscription }\nexport type FetchSubscriptionResponse = SWRResponse<Subscription>\n\nexport function useSubscriptions({ email }: { email?: string }): FetchSubscriptionResponse {\n const { locale } = useHeadlessContext()\n\n const { data, ...rest } = useSWR<SubscriptionApiResponse>(\n email ? ['/api/multipass/account/subscriptions', email] : null,\n async ([url, email]) =>\n fetcher({\n method: 'GET',\n url,\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n )\n\n return { data: data?.data, ...rest } as unknown as FetchSubscriptionResponse\n}\n"],
5
- "mappings": "AAAA,OAAOA,MAA6B,MAEpC,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,WAAAC,MAAe,cAYjB,SAASC,EAAiB,CAAE,MAAAC,CAAM,EAAkD,CACzF,KAAM,CAAE,OAAAC,CAAO,EAAIJ,EAAmB,EAEhC,CAAE,KAAAK,EAAM,GAAGC,CAAK,EAAIP,EACxBI,EAAQ,CAAC,uCAAwCA,CAAK,EAAI,KAC1D,MAAO,CAACI,EAAKJ,CAAK,IAChBF,EAAQ,CACN,OAAQ,MACR,IAAAM,EACA,KAAM,CACJ,MAAAJ,CACF,EACA,OAAQ,QACR,OAAAC,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,CACL,EAEA,MAAO,CAAE,KAAMC,GAAM,KAAM,GAAGC,CAAK,CACrC",
6
- "names": ["useSWR", "useHeadlessContext", "fetcher", "useSubscriptions", "email", "locale", "data", "rest", "url"]
4
+ "sourcesContent": ["import useSWR from 'swr'\n\nimport { useHeadlessContext } from '../../context'\nimport { fetcher } from '../../utils'\n\nexport function useSubscriptions({ email }: { email?: string }) {\n const { locale } = useHeadlessContext()\n\n return useSWR(email ? ['/api/multipass/account/subscriptions', email] : null, async ([url, email]) =>\n fetcher({\n method: 'GET',\n url,\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n )\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAY,MAEnB,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,WAAAC,MAAe,cAEjB,SAASC,EAAiB,CAAE,MAAAC,CAAM,EAAuB,CAC9D,KAAM,CAAE,OAAAC,CAAO,EAAIJ,EAAmB,EAEtC,OAAOD,EAAOI,EAAQ,CAAC,uCAAwCA,CAAK,EAAI,KAAM,MAAO,CAACE,EAAKF,CAAK,IAC9FF,EAAQ,CACN,OAAQ,MACR,IAAAI,EACA,KAAM,CACJ,MAAAF,CACF,EACA,OAAQ,QACR,OAAAC,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,CACH,CACF",
6
+ "names": ["useSWR", "useHeadlessContext", "fetcher", "useSubscriptions", "email", "locale", "url"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/lib",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Unified Anker headless library with shared context, Shopify integration, and cart utilities",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -1,36 +1,22 @@
1
- import useSWR, { SWRResponse } from 'swr'
1
+ import useSWR from 'swr'
2
2
 
3
3
  import { useHeadlessContext } from '../../context'
4
4
  import { fetcher } from '../../utils'
5
5
 
6
- export interface Subscription {
7
- preference: {
8
- subscribe: boolean
9
- brand: string
10
- }[]
11
- }
12
-
13
- export type SubscriptionApiResponse = { data: Subscription }
14
- export type FetchSubscriptionResponse = SWRResponse<Subscription>
15
-
16
- export function useSubscriptions({ email }: { email?: string }): FetchSubscriptionResponse {
6
+ export function useSubscriptions({ email }: { email?: string }) {
17
7
  const { locale } = useHeadlessContext()
18
8
 
19
- const { data, ...rest } = useSWR<SubscriptionApiResponse>(
20
- email ? ['/api/multipass/account/subscriptions', email] : null,
21
- async ([url, email]) =>
22
- fetcher({
23
- method: 'GET',
24
- url,
25
- body: {
26
- email,
27
- },
28
- action: 'login',
29
- locale,
30
- headers: {},
31
- type: '',
32
- })
9
+ return useSWR(email ? ['/api/multipass/account/subscriptions', email] : null, async ([url, email]) =>
10
+ fetcher({
11
+ method: 'GET',
12
+ url,
13
+ body: {
14
+ email,
15
+ },
16
+ action: 'login',
17
+ locale,
18
+ headers: {},
19
+ type: '',
20
+ })
33
21
  )
34
-
35
- return { data: data?.data, ...rest } as unknown as FetchSubscriptionResponse
36
22
  }