2024-09-17
This commit is contained in:
parent
3ae978e4e8
commit
82040ce0fb
543 changed files with 5727 additions and 4898 deletions
|
|
@ -11,6 +11,10 @@
|
|||
"file": "exports.js",
|
||||
"name": "exports"
|
||||
},
|
||||
"_index.js": {
|
||||
"file": "index.js",
|
||||
"name": "index"
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts": {
|
||||
"file": "api.js",
|
||||
"name": "api",
|
||||
|
|
@ -81,6 +85,33 @@
|
|||
"_Either.js"
|
||||
]
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-add.item.ts": {
|
||||
"file": "cart-add.item.js",
|
||||
"name": "cart-add.item",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-add.item.ts",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_index.js"
|
||||
]
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart.ts": {
|
||||
"file": "cart.js",
|
||||
"name": "cart",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart.ts",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_index.js"
|
||||
]
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/erreurs.ts": {
|
||||
"file": "erreurs2.js",
|
||||
"name": "erreurs",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/erreurs.ts",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_index.js"
|
||||
]
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts": {
|
||||
"file": "utils.js",
|
||||
"name": "utils",
|
||||
|
|
@ -101,13 +132,16 @@
|
|||
"isEntry": true,
|
||||
"imports": [
|
||||
"_chunk-7BKSRZNG.js",
|
||||
"_index.js",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/dom.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/gardes.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-add.item.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/erreurs.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart-add-item.ts",
|
||||
"_Either.js",
|
||||
"_exports.js"
|
||||
]
|
||||
|
|
@ -117,11 +151,5 @@
|
|||
"name": "cart-add-item",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart-add-item.ts",
|
||||
"isEntry": true
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart.ts": {
|
||||
"file": "cart.js",
|
||||
"name": "cart",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart.ts",
|
||||
"isEntry": true
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1 @@
|
|||
var y;function g(e){return{lang:e?.lang??y?.lang,message:e?.message,abortEarly:e?.abortEarly??y?.abortEarly,abortPipeEarly:e?.abortPipeEarly??y?.abortPipeEarly}}var E;function d(e){return E?.get(e)}var k;function _(e){return k?.get(e)}var A;function I(e,s){return A?.get(e)?.get(s)}function S(e){const s=typeof e;return s==="string"?`"${e}"`:s==="number"||s==="bigint"||s==="boolean"?`${e}`:s==="object"||s==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":s}function c(e,s,r,n,t){const i=r.value,o=e.expects??null,u=S(i),l={kind:e.kind,type:e.type,input:i,expected:o,received:u,message:`Invalid ${s}: ${o?`Expected ${o} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},a=e.kind==="schema",f=e.message??I(e.reference,l.lang)??(a?_(l.lang):null)??n.message??d(l.lang);f&&(l.message=typeof f=="function"?f(l):f),a&&(r.typed=!1),r.issues?r.issues.push(l):r.issues=[l]}var j=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function C(e,s,r){return typeof e.default=="function"?e.default(s,r):e.default}function b(e,s){return{kind:"schema",type:"array",reference:b,expects:"Array",async:!1,item:e,message:s,_run(r,n){const t=r.value;if(Array.isArray(t)){r.typed=!0,r.value=[];for(let i=0;i<t.length;i++){const o=t[i],u=this.item._run({typed:!1,value:o},n);if(u.issues){const l={type:"array",origin:"value",input:t,key:i,value:o};for(const a of u.issues)a.path?a.path.unshift(l):a.path=[l],r.issues?.push(a);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else c(this,"type",r,n);return r}}}function v(e){return{kind:"schema",type:"number",reference:v,expects:"number",async:!1,message:e,_run(s,r){return typeof s.value=="number"&&!isNaN(s.value)?s.typed=!0:c(this,"type",s,r),s}}}function m(e,s){return{kind:"schema",type:"object",reference:m,expects:"Object",async:!1,entries:e,message:s,_run(r,n){const t=r.value;if(t&&typeof t=="object"){r.typed=!0,r.value={};for(const i in this.entries){const o=t[i],u=this.entries[i]._run({typed:!1,value:o},n);if(u.issues){const l={type:"object",origin:"value",input:t,key:i,value:o};for(const a of u.issues)a.path?a.path.unshift(l):a.path=[l],r.issues?.push(a);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||i in t)&&(r.value[i]=u.value)}}else c(this,"type",r,n);return r}}}function p(e,...s){const r={kind:"schema",type:"optional",reference:p,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,t){return n.value===void 0&&("default"in this&&(n.value=C(this,n,t)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,t)}};return 0 in s&&(r.default=s[0]),r}function h(e){return{kind:"schema",type:"string",reference:h,expects:"string",async:!1,message:e,_run(s,r){return typeof s.value=="string"?s.typed=!0:c(this,"type",s,r),s}}}function $(e,s,r){const n=e._run({typed:!1,value:s},g(r));if(n.issues)throw new j(n.issues);return n.value}const P=m({attribute:h(),value:h()}),x=m({id:p(v()),quantity:p(v()),variation:p(b(P))}),W=e=>$(x,e);export{W};
|
||||
//# sourceMappingURL=cart-add-item.js.map
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,2 @@
|
|||
import{o as s,a as t,p as o,n as a,b as m,s as r}from"./index.js";const n=s({attribute:r(),value:r()}),i=s({id:t(a()),quantity:t(a()),variation:t(m(n))}),p=e=>o(i,e);export{p};
|
||||
//# sourceMappingURL=cart-add.item.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"cart-add.item.js","sources":["../../src/scripts/lib/schemas/cart-add.item.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport type { WCStoreCartAddItemArgs } from \"../../types/api/cart-add-item.ts\";\n\nexport const WCStoreCartAddItemArgsItemsSchema = v.object({\n /** Variation attribute name. */\n attribute: v.string(),\n /** Variation attribute value. */\n value: v.string(),\n});\n\nexport const WCStoreCartAddItemArgsSchema = v.object({\n /** The basket item product or variation ID. */\n id: v.optional(v.number()),\n /** Quantity of this item to add to the basket. */\n quantity: v.optional(v.number()),\n /** Chosen attributes (for variations). */\n variation: v.optional(v.array(WCStoreCartAddItemArgsItemsSchema)),\n});\n\nexport const parseWCStoreCartAddItemArgs: (args: unknown) => WCStoreCartAddItemArgs = (args) =>\n v.parse(WCStoreCartAddItemArgsSchema, args);\n"],"names":["WCStoreCartAddItemArgsItemsSchema","v.object","v.string","WCStoreCartAddItemArgsSchema","v.optional","v.number","v.array","parseWCStoreCartAddItemArgs","args","v.parse"],"mappings":"kEAIa,MAAAA,EAAoCC,EAAS,CAExD,UAAWC,EAAS,EAEpB,MAAOA,EAAS,CAClB,CAAC,EAEYC,EAA+BF,EAAS,CAEnD,GAAIG,EAAWC,GAAU,EAEzB,SAAUD,EAAWC,GAAU,EAE/B,UAAWD,EAAWE,EAAQN,CAAiC,CAAC,CAClE,CAAC,EAEYO,EAA0EC,GACrFC,EAAQN,EAA8BK,CAAI"}
|
||||
|
|
@ -1 +1,2 @@
|
|||
import{o as a,s as e,u as i,n,c as s,b as t,d as r,i as o}from"./index.js";a({name:e(),package_id:i([n(),e()])});const m=a({billing_address:s(),coupons:s(),cross_sells:s(),errors:s(),extensions:s(),fees:s(),has_calculated_shipping:s(),items:t(s()),items_count:r(n(),o()),items_weight:s(),needs_payment:s(),needs_shipping:s(),payment_methods:s(),payment_requirements:s(),shipping_address:s(),shipping_rates:s(),totals:s()});export{m as W};
|
||||
//# sourceMappingURL=cart.js.map
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"cart.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
||||
{"version":3,"file":"cart.js","sources":["../../src/scripts/lib/schemas/cart.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nconst WCStoreCartItemTotalsSchema = v.object({\n currency_code: v.string(),\n currency_decimal_separator: v.string(),\n currency_minor_unit: v.number(),\n currency_prefix: v.string(),\n currency_suffix: v.string(),\n currency_symbol: v.string(),\n currency_thousand_separator: v.string(),\n total_discount: v.string(),\n total_discount_tax: v.string(),\n});\n\nconst WCStoreCartItemShippingRateSchema = v.object({\n name: v.string(),\n package_id: v.union([v.number(), v.string()]),\n});\n\nconst WCStoreCartItemSchema = v.object({\n code: v.string(),\n discount_type: v.string(),\n shipping_rates: v.array(WCStoreCartItemShippingRateSchema),\n totals: v.array(WCStoreCartItemTotalsSchema),\n});\n\nexport const WCStoreCartSchema = v.object({\n billing_address: v.unknown(),\n coupons: v.unknown(),\n cross_sells: v.unknown(),\n errors: v.unknown(),\n extensions: v.unknown(),\n fees: v.unknown(),\n has_calculated_shipping: v.unknown(),\n items: v.array(v.unknown()),\n items_count: v.pipe(v.number(), v.integer()),\n items_weight: v.unknown(),\n needs_payment: v.unknown(),\n needs_shipping: v.unknown(),\n payment_methods: v.unknown(),\n payment_requirements: v.unknown(),\n shipping_address: v.unknown(),\n shipping_rates: v.unknown(),\n totals: v.unknown(),\n});\n"],"names":["v.object","v.string","v.union","v.number","WCStoreCartSchema","v.unknown","v.array","v.pipe","v.integer"],"mappings":"AAc0CA,OAAAA,KAAAA,EAAAA,KAAAA,EAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,KAAAA,EAAAA,KAAAA,EAAAA,KAAAA,MAAAA,aAAAA,EAAS,CACjD,KAAMC,EAAS,EACf,WAAYC,EAAQ,CAACC,IAAYF,EAAU,CAAA,CAAC,CAC9C,CAAC,EASY,MAAAG,EAAoBJ,EAAS,CACxC,gBAAiBK,EAAU,EAC3B,QAASA,EAAU,EACnB,YAAaA,EAAU,EACvB,OAAQA,EAAU,EAClB,WAAYA,EAAU,EACtB,KAAMA,EAAU,EAChB,wBAAyBA,EAAU,EACnC,MAAOC,EAAQD,GAAW,EAC1B,YAAaE,EAAOJ,EAAY,EAAAK,GAAW,EAC3C,aAAcH,EAAU,EACxB,cAAeA,EAAU,EACzB,eAAgBA,EAAU,EAC1B,gBAAiBA,EAAU,EAC3B,qBAAsBA,EAAU,EAChC,iBAAkBA,EAAU,EAC5B,eAAgBA,EAAU,EAC1B,OAAQA,EAAU,CACpB,CAAC"}
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"chunk-7BKSRZNG.js","sources":["../../../../../../node_modules/.pnpm/remeda@2.12.0/node_modules/remeda/dist/chunk-ANXBDSUI.js","../../../../../../node_modules/.pnpm/remeda@2.12.0/node_modules/remeda/dist/chunk-7BKSRZNG.js"],"sourcesContent":["var e={done:!0,hasNext:!1},s={done:!1,hasNext:!1},a=()=>e,o=t=>({hasNext:!0,next:t,done:!1});export{s as a,a as b,o as c};\n","import{a as s}from\"./chunk-ANXBDSUI.js\";function x(t,...o){let n=t,u=o.map(e=>\"lazy\"in e?f(e):void 0),p=0;for(;p<o.length;){if(u[p]===void 0||!B(n)){let i=o[p];n=i(n),p+=1;continue}let r=[];for(let i=p;i<o.length;i++){let l=u[i];if(l===void 0||(r.push(l),l.isSingle))break}let a=[];for(let i of n)if(A(i,a,r))break;let{isSingle:y}=r.at(-1);n=y?a[0]:a,p+=r.length}return n}function A(t,o,n){if(n.length===0)return o.push(t),!1;let u=t,p=s,e=!1;for(let[r,a]of n.entries()){let{index:y,items:i}=a;if(i.push(u),p=a(u,y,i),a.index+=1,p.hasNext){if(p.hasMany??!1){for(let l of p.next)if(A(l,o,n.slice(r+1)))return!0;return e}u=p.next}if(!p.hasNext)break;p.done&&(e=!0)}return p.hasNext&&o.push(u),e}function f(t){let{lazy:o,lazyArgs:n}=t,u=o(...n);return Object.assign(u,{isSingle:o.single??!1,index:0,items:[]})}function B(t){return typeof t==\"string\"||typeof t==\"object\"&&t!==null&&Symbol.iterator in t}export{x as a};\n"],"names":["s","x","t","o","n","u","e","f","p","B","i","l","a","A","y","r"],"mappings":"AAAG,IAAwBA,EAAE,CAAC,KAAK,GAAG,QAAQ,EAAE,ECAR,SAASC,EAAEC,KAAKC,EAAE,CAAC,IAAIC,EAAEF,EAAEG,EAAEF,EAAE,IAAIG,GAAG,SAASA,EAAEC,EAAED,CAAC,EAAE,MAAM,EAAEE,EAAE,EAAE,KAAKA,EAAEL,EAAE,QAAQ,CAAC,GAAGE,EAAEG,CAAC,IAAI,QAAQ,CAACC,EAAEL,CAAC,EAAE,CAAC,IAAIM,EAAEP,EAAEK,CAAC,EAAEJ,EAAEM,EAAEN,CAAC,EAAEI,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAA,EAAG,QAAQE,EAAEF,EAAEE,EAAEP,EAAE,OAAOO,IAAI,CAAC,IAAIC,EAAEN,EAAEK,CAAC,EAAE,GAAGC,IAAI,SAAS,EAAE,KAAKA,CAAC,EAAEA,EAAE,UAAU,KAAK,CAAC,IAAIC,EAAE,GAAG,QAAQF,KAAKN,EAAE,GAAGS,EAAEH,EAAEE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,SAASE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAEV,EAAEU,EAAEF,EAAE,CAAC,EAAEA,EAAEJ,GAAG,EAAE,MAAM,CAAC,OAAOJ,CAAC,CAAC,SAASS,EAAEX,EAAEC,EAAEC,EAAE,CAAC,GAAGA,EAAE,SAAS,EAAE,OAAOD,EAAE,KAAKD,CAAC,EAAE,GAAG,IAAIG,EAAEH,EAAEM,EAAER,EAAEM,EAAE,GAAG,OAAO,CAACS,EAAEH,CAAC,IAAIR,EAAE,QAAS,EAAC,CAAC,GAAG,CAAC,MAAMU,EAAE,MAAMJ,CAAC,EAAEE,EAAE,GAAGF,EAAE,KAAKL,CAAC,EAAEG,EAAEI,EAAEP,EAAES,EAAEJ,CAAC,EAAEE,EAAE,OAAO,EAAEJ,EAAE,QAAQ,CAAC,GAAGA,EAAE,SAAS,GAAG,CAAC,QAAQG,KAAKH,EAAE,KAAK,GAAGK,EAAEF,EAAER,EAAEC,EAAE,MAAMW,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAOT,CAAC,CAACD,EAAEG,EAAE,IAAI,CAAC,GAAG,CAACA,EAAE,QAAQ,MAAMA,EAAE,OAAOF,EAAE,GAAG,CAAC,OAAOE,EAAE,SAASL,EAAE,KAAKE,CAAC,EAAEC,CAAC,CAAC,SAASC,EAAEL,EAAE,CAAC,GAAG,CAAC,KAAKC,EAAE,SAASC,CAAC,EAAEF,EAAEG,EAAEF,EAAE,GAAGC,CAAC,EAAE,OAAO,OAAO,OAAOC,EAAE,CAAC,SAASF,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAE,CAAA,CAAC,CAAC,CAAC,SAASM,EAAEP,EAAE,CAAC,OAAO,OAAOA,GAAG,UAAU,OAAOA,GAAG,UAAUA,IAAI,MAAM,OAAO,YAAYA,CAAC","x_google_ignoreList":[0,1]}
|
||||
{"version":3,"file":"chunk-7BKSRZNG.js","sources":["../../../../../../node_modules/.pnpm/remeda@2.12.1/node_modules/remeda/dist/chunk-ANXBDSUI.js","../../../../../../node_modules/.pnpm/remeda@2.12.1/node_modules/remeda/dist/chunk-7BKSRZNG.js"],"sourcesContent":["var e={done:!0,hasNext:!1},s={done:!1,hasNext:!1},a=()=>e,o=t=>({hasNext:!0,next:t,done:!1});export{s as a,a as b,o as c};\n","import{a as s}from\"./chunk-ANXBDSUI.js\";function x(t,...o){let n=t,u=o.map(e=>\"lazy\"in e?f(e):void 0),p=0;for(;p<o.length;){if(u[p]===void 0||!B(n)){let i=o[p];n=i(n),p+=1;continue}let r=[];for(let i=p;i<o.length;i++){let l=u[i];if(l===void 0||(r.push(l),l.isSingle))break}let a=[];for(let i of n)if(A(i,a,r))break;let{isSingle:y}=r.at(-1);n=y?a[0]:a,p+=r.length}return n}function A(t,o,n){if(n.length===0)return o.push(t),!1;let u=t,p=s,e=!1;for(let[r,a]of n.entries()){let{index:y,items:i}=a;if(i.push(u),p=a(u,y,i),a.index+=1,p.hasNext){if(p.hasMany??!1){for(let l of p.next)if(A(l,o,n.slice(r+1)))return!0;return e}u=p.next}if(!p.hasNext)break;p.done&&(e=!0)}return p.hasNext&&o.push(u),e}function f(t){let{lazy:o,lazyArgs:n}=t,u=o(...n);return Object.assign(u,{isSingle:o.single??!1,index:0,items:[]})}function B(t){return typeof t==\"string\"||typeof t==\"object\"&&t!==null&&Symbol.iterator in t}export{x as a};\n"],"names":["s","x","t","o","n","u","e","f","p","B","i","l","a","A","y","r"],"mappings":"AAAG,IAAwBA,EAAE,CAAC,KAAK,GAAG,QAAQ,EAAE,ECAR,SAASC,EAAEC,KAAKC,EAAE,CAAC,IAAIC,EAAEF,EAAEG,EAAEF,EAAE,IAAIG,GAAG,SAASA,EAAEC,EAAED,CAAC,EAAE,MAAM,EAAEE,EAAE,EAAE,KAAKA,EAAEL,EAAE,QAAQ,CAAC,GAAGE,EAAEG,CAAC,IAAI,QAAQ,CAACC,EAAEL,CAAC,EAAE,CAAC,IAAIM,EAAEP,EAAEK,CAAC,EAAEJ,EAAEM,EAAEN,CAAC,EAAEI,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAA,EAAG,QAAQE,EAAEF,EAAEE,EAAEP,EAAE,OAAOO,IAAI,CAAC,IAAIC,EAAEN,EAAEK,CAAC,EAAE,GAAGC,IAAI,SAAS,EAAE,KAAKA,CAAC,EAAEA,EAAE,UAAU,KAAK,CAAC,IAAIC,EAAE,GAAG,QAAQF,KAAKN,EAAE,GAAGS,EAAEH,EAAEE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,SAASE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAEV,EAAEU,EAAEF,EAAE,CAAC,EAAEA,EAAEJ,GAAG,EAAE,MAAM,CAAC,OAAOJ,CAAC,CAAC,SAASS,EAAEX,EAAEC,EAAEC,EAAE,CAAC,GAAGA,EAAE,SAAS,EAAE,OAAOD,EAAE,KAAKD,CAAC,EAAE,GAAG,IAAIG,EAAEH,EAAEM,EAAER,EAAEM,EAAE,GAAG,OAAO,CAACS,EAAEH,CAAC,IAAIR,EAAE,QAAS,EAAC,CAAC,GAAG,CAAC,MAAMU,EAAE,MAAMJ,CAAC,EAAEE,EAAE,GAAGF,EAAE,KAAKL,CAAC,EAAEG,EAAEI,EAAEP,EAAES,EAAEJ,CAAC,EAAEE,EAAE,OAAO,EAAEJ,EAAE,QAAQ,CAAC,GAAGA,EAAE,SAAS,GAAG,CAAC,QAAQG,KAAKH,EAAE,KAAK,GAAGK,EAAEF,EAAER,EAAEC,EAAE,MAAMW,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAOT,CAAC,CAACD,EAAEG,EAAE,IAAI,CAAC,GAAG,CAACA,EAAE,QAAQ,MAAMA,EAAE,OAAOF,EAAE,GAAG,CAAC,OAAOE,EAAE,SAASL,EAAE,KAAKE,CAAC,EAAEC,CAAC,CAAC,SAASC,EAAEL,EAAE,CAAC,GAAG,CAAC,KAAKC,EAAE,SAASC,CAAC,EAAEF,EAAEG,EAAEF,EAAE,GAAGC,CAAC,EAAE,OAAO,OAAO,OAAOC,EAAE,CAAC,SAASF,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAE,CAAA,CAAC,CAAC,CAAC,SAASM,EAAEP,EAAE,CAAC,OAAO,OAAOA,GAAG,UAAU,OAAOA,GAAG,UAAUA,IAAI,MAAM,OAAO,YAAYA,CAAC","x_google_ignoreList":[0,1]}
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
import{x as m}from"./chunk-7BKSRZNG.js";import{c as n,r as a,E as c,a as o}from"./erreurs.js";import{E as s,r as E,l as i}from"./Either.js";import"./exports.js";function p(e){return e!==null}function l(e){return e===void 0?!0:typeof e=="string"||Array.isArray(e)?e.length===0:Object.keys(e).length===0}const f=e=>e,R=e=>r=>s.encase(()=>e.querySelector(r)).mapLeft(t=>n(c(r))).chain(t=>p(t)?E(t):i(n(o(r)))),h=e=>r=>s.encase(()=>m(e.querySelectorAll(r),Array.from)).mapLeft(t=>n(c(r))).chain(t=>l(t)?i(n(o(r))):E(t)),S=e=>e.caseOf({Left:a,Right:f}),g=e=>e.caseOf({Left:a,Right:f});export{g as a,h as b,R as c,S as r};
|
||||
import{x as m}from"./chunk-7BKSRZNG.js";import{e as n,f as a,g as c,h as o}from"./erreurs.js";import{E as s,r as E,l as i}from"./Either.js";import"./exports.js";function p(e){return e!==null}function l(e){return e===void 0?!0:typeof e=="string"||Array.isArray(e)?e.length===0:Object.keys(e).length===0}const f=e=>e,L=e=>r=>s.encase(()=>e.querySelector(r)).mapLeft(t=>n(c(r))).chain(t=>p(t)?E(t):i(n(o(r)))),R=e=>r=>s.encase(()=>m(e.querySelectorAll(r),Array.from)).mapLeft(t=>n(c(r))).chain(t=>l(t)?i(n(o(r))):E(t)),S=e=>e.caseOf({Left:a,Right:f}),g=e=>e.caseOf({Left:a,Right:f});export{L as a,S as b,g as c,R as r};
|
||||
//# sourceMappingURL=dom2.js.map
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
import{c as r}from"./exports.js";const E=e=>`Le selecteur "${e}" est invalide`,a=e=>`La requête "${e}" n'a retourné aucun Élément.`,n=e=>new SyntaxError(e),o=e=>{throw r(e),e};export{E,a,n as c,o as r};
|
||||
import{c as o}from"./exports.js";const u=r=>`Le selecteur "${r}" est invalide`,d=r=>`La requête "${r}" n'a retourné aucun Élément.`,h=r=>new SyntaxError(r);class s extends Error{constructor(e="400 BadRequestError"){super(e),this.name="BadRequestError"}}class t extends Error{constructor(e="401 UnauthorizedError"){super(e),this.name="UnauthorizedError"}}class n extends Error{constructor(e="404 NotFoundError"){super(e),this.name="NotFoundError"}}class a extends Error{constructor(e="500 ServerError"){super(e),this.name="ServerError"}}class E extends Error{constructor(e){super(JSON.stringify(e)),this.name="UnknownError"}}const i=r=>new E(r),l=r=>{throw r},w=r=>{throw new s(`(${r.code}) ${r.message}`)},m=r=>{throw new t(`(${r.code}) ${r.message}`)},p=r=>{throw new n(`(${r.code}) ${r.message}`)},v=r=>{throw new a(`(${r.code}) ${r.message}`)},R=r=>o(r),S=r=>{throw o(r),r};export{i as E,m as a,p as b,v as c,l as d,h as e,S as f,u as g,d as h,w as l,R as r};
|
||||
//# sourceMappingURL=erreurs.js.map
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"erreurs.js","sources":["../../src/scripts/lib/erreurs.ts"],"sourcesContent":["/**\n * Fonctions pour la création d'Erreurs.\n */\n\nimport { captureException } from \"@sentry/browser\";\n\n/* Messages d'erreur */\nexport const ERREUR_SYNTAXE_INVALIDE: (selecteur: string) => string = (selecteur) =>\n `Le selecteur \"${selecteur}\" est invalide`;\nexport const ERREUR_SELECTEUR_INEXISTANT: (selecteur: string) => string = (selecteur) =>\n `La requête \"${selecteur}\" n'a retourné aucun Élément.`;\n\n/* Création d'erreurs */\nexport const creeSyntaxError: (message: string) => SyntaxError = (message) => new SyntaxError(message);\n\n/* Fonction utilitaire pour lever une Error */\nexport const leveErreur = (erreur: Error): never => {\n throw erreur;\n};\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer\n le type d'Erreur à l'appel de la fonction. */\nexport const reporteEtLeveErreur = <E extends Error>(erreur: E): never => {\n captureException(erreur);\n throw erreur;\n};\n"],"names":["ERREUR_SYNTAXE_INVALIDE","selecteur","ERREUR_SELECTEUR_INEXISTANT","creeSyntaxError","message","reporteEtLeveErreur","erreur","captureException"],"mappings":"iCAOO,MAAMA,EAA0DC,GACrE,iBAAiBA,CAAS,iBACfC,EAA8DD,GACzE,eAAeA,CAAS,gCAGbE,EAAqDC,GAAY,IAAI,YAAYA,CAAO,EASxFC,EAAwCC,GAAqB,CACxE,MAAAC,EAAiBD,CAAM,EACjBA,CACR"}
|
||||
{"version":3,"file":"erreurs.js","sources":["../../src/scripts/lib/erreurs.ts"],"sourcesContent":["/**\n * Fonctions pour la création d'Erreurs.\n */\n\nimport { captureException } from \"@sentry/browser\";\n\nimport type { WCErrorBody } from \"../types/api/erreurs\";\n\n/* Messages d'erreur */\nexport const ERREUR_SYNTAXE_INVALIDE = (selecteur: string): string => `Le selecteur \"${selecteur}\" est invalide`;\nexport const ERREUR_SELECTEUR_INEXISTANT = (selecteur: string): string =>\n `La requête \"${selecteur}\" n'a retourné aucun Élément.`;\n\n/* Création d'erreurs */\nexport const creeSyntaxError = (message: string): SyntaxError => new SyntaxError(message);\n\n/* Types d'erreurs */\nexport class BadRequestError extends Error {\n constructor(message = \"400 BadRequestError\") {\n super(message);\n this.name = \"BadRequestError\";\n }\n}\nexport class UnauthorizedError extends Error {\n constructor(message = \"401 UnauthorizedError\") {\n super(message);\n this.name = \"UnauthorizedError\";\n }\n}\nexport class NotFoundError extends Error {\n constructor(message = \"404 NotFoundError\") {\n super(message);\n this.name = \"NotFoundError\";\n }\n}\nexport class ServerError extends Error {\n constructor(message = \"500 ServerError\") {\n super(message);\n this.name = \"ServerError\";\n }\n}\nexport class UnknownError extends Error {\n constructor(message: unknown) {\n super(JSON.stringify(message));\n this.name = \"UnknownError\";\n }\n}\n\n/* Fonction utilitaire pour créer ou lever des Erreurs */\nexport const Erreur = (message: string): Error => new Error(message);\nexport const ErreurInconnue = (erreur: unknown): UnknownError => new UnknownError(erreur);\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer\nle type d'Erreur à l'appel de la fonction. */\nexport const leveErreur = <E extends Error = Error>(erreur: E): never => {\n throw erreur;\n};\nexport const leveBadRequestError = (erreur: WCErrorBody): never => {\n throw new BadRequestError(`(${erreur.code}) ${erreur.message}`);\n};\nexport const leveUnauthorizedError = (erreur: WCErrorBody): never => {\n throw new UnauthorizedError(`(${erreur.code}) ${erreur.message}`);\n};\nexport const leveNotFoundError = (erreur: WCErrorBody): never => {\n throw new NotFoundError(`(${erreur.code}) ${erreur.message}`);\n};\nexport const leveServerError = (erreur: WCErrorBody): never => {\n throw new ServerError(`(${erreur.code}) ${erreur.message}`);\n};\nexport const leveUnknownError = (erreur: unknown): never => {\n throw new UnknownError(erreur);\n};\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer\nle type d'Erreur à l'appel de la fonction. */\nexport const reporteErreur = <E extends Error>(erreur: E): string => captureException(erreur);\n\n/**\n * Reporte une Erreur au service GlitchTip puis la lève sous forme d'Exception.\n * @param erreur\n */\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer\nle type d'Erreur à l'appel de la fonction. */\nexport const reporteEtLeveErreur = <E extends Error>(erreur: E): never => {\n captureException(erreur);\n throw erreur;\n};\n"],"names":["ERREUR_SYNTAXE_INVALIDE","selecteur","ERREUR_SELECTEUR_INEXISTANT","creeSyntaxError","message","BadRequestError","UnauthorizedError","NotFoundError","ServerError","UnknownError","ErreurInconnue","erreur","leveErreur","leveBadRequestError","leveUnauthorizedError","leveNotFoundError","leveServerError","reporteErreur","captureException","reporteEtLeveErreur"],"mappings":"iCASO,MAAMA,EAA2BC,GAA8B,iBAAiBA,CAAS,iBACnFC,EAA+BD,GAC1C,eAAeA,CAAS,gCAGbE,EAAmBC,GAAiC,IAAI,YAAYA,CAAO,EAGjF,MAAMC,UAAwB,KAAM,CACzC,YAAYD,EAAU,sBAAuB,CAC3C,MAAMA,CAAO,EACb,KAAK,KAAO,iBACd,CACF,CACO,MAAME,UAA0B,KAAM,CAC3C,YAAYF,EAAU,wBAAyB,CAC7C,MAAMA,CAAO,EACb,KAAK,KAAO,mBACd,CACF,CACO,MAAMG,UAAsB,KAAM,CACvC,YAAYH,EAAU,oBAAqB,CACzC,MAAMA,CAAO,EACb,KAAK,KAAO,eACd,CACF,CACO,MAAMI,UAAoB,KAAM,CACrC,YAAYJ,EAAU,kBAAmB,CACvC,MAAMA,CAAO,EACb,KAAK,KAAO,aACd,CACF,CACO,MAAMK,UAAqB,KAAM,CACtC,YAAYL,EAAkB,CACtB,MAAA,KAAK,UAAUA,CAAO,CAAC,EAC7B,KAAK,KAAO,cACd,CACF,CAIO,MAAMM,EAAkBC,GAAkC,IAAIF,EAAaE,CAAM,EAI3EC,EAAuCD,GAAqB,CACjE,MAAAA,CACR,EACaE,EAAuBF,GAA+B,CAC3D,MAAA,IAAIN,EAAgB,IAAIM,EAAO,IAAI,KAAKA,EAAO,OAAO,EAAE,CAChE,EACaG,EAAyBH,GAA+B,CAC7D,MAAA,IAAIL,EAAkB,IAAIK,EAAO,IAAI,KAAKA,EAAO,OAAO,EAAE,CAClE,EACaI,EAAqBJ,GAA+B,CACzD,MAAA,IAAIJ,EAAc,IAAII,EAAO,IAAI,KAAKA,EAAO,OAAO,EAAE,CAC9D,EACaK,EAAmBL,GAA+B,CACvD,MAAA,IAAIH,EAAY,IAAIG,EAAO,IAAI,KAAKA,EAAO,OAAO,EAAE,CAC5D,EAOaM,EAAkCN,GAAsBO,EAAiBP,CAAM,EAQ/EQ,EAAwCR,GAAqB,CACxE,MAAAO,EAAiBP,CAAM,EACjBA,CACR"}
|
||||
2
web/app/themes/haiku-atelier-2024/assets/js/erreurs2.js
Normal file
2
web/app/themes/haiku-atelier-2024/assets/js/erreurs2.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import{e as t,o as s,n as r,s as o}from"./index.js";const e=s({code:o(),data:s({status:r()}),message:o()}),c=s({body:e,status:r()}),n=a=>t(c,a);export{n as i};
|
||||
//# sourceMappingURL=erreurs2.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"erreurs2.js","sources":["../../src/scripts/lib/schemas/erreurs.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport type { WCError } from \"../../types/api/erreurs\";\n\nexport const WCErrorBodySchema = v.object({\n code: v.string(),\n data: v.object({\n status: v.number(),\n }),\n message: v.string(),\n});\n\nexport const WCErrorSchema = v.object({\n body: WCErrorBodySchema,\n status: v.number(),\n});\n\nexport const isWCError = (donnees: unknown): donnees is WCError => v.is(WCErrorSchema, donnees);\n"],"names":["WCErrorBodySchema","v.object","v.string","v.number","WCErrorSchema","isWCError","donnees","v.is"],"mappings":"oDAIa,MAAAA,EAAoBC,EAAS,CACxC,KAAMC,EAAS,EACf,KAAMD,EAAS,CACb,OAAQE,EAAS,CAAA,CAClB,EACD,QAASD,EAAS,CACpB,CAAC,EAEYE,EAAgBH,EAAS,CACpC,KAAMD,EACN,OAAQG,EAAS,CACnB,CAAC,EAEYE,EAAaC,GAAyCC,EAAKH,EAAeE,CAAO"}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
const n=e=>t=>t instanceof e,s=n(HTMLSelectElement);export{s as e};
|
||||
const n=e=>t=>t instanceof e,s=n(HTMLSelectElement),o=e=>e instanceof Error;export{o as a,s as e};
|
||||
//# sourceMappingURL=gardes.js.map
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"gardes.js","sources":["../../src/scripts/lib/gardes.ts"],"sourcesContent":["type Constructor<T> = new(...args: unknown[]) => T;\n\nconst estElement = <T extends HTMLElement>(typeElement: Constructor<T>) => (element: unknown): element is T =>\n element instanceof typeElement;\n\nexport const estHTMLSelectElement = estElement<HTMLSelectElement>(HTMLSelectElement);\n"],"names":["estElement","typeElement","element","estHTMLSelectElement"],"mappings":"AAEA,MAAMA,EAAqCC,GAAiCC,GAC1EA,aAAmBD,EAERE,EAAuBH,EAA8B,iBAAiB"}
|
||||
{"version":3,"file":"gardes.js","sources":["../../src/scripts/lib/gardes.ts"],"sourcesContent":["import type { Constructor } from \"../types/classes\";\n\nconst estElement = <T extends HTMLElement>(typeElement: Constructor<T>) => (element: unknown): element is T =>\n element instanceof typeElement;\n\nexport const estHTMLSelectElement = estElement<HTMLSelectElement>(HTMLSelectElement);\n\nexport const estError = (erreur: unknown): erreur is Error => erreur instanceof Error;\n"],"names":["estElement","typeElement","element","estHTMLSelectElement","estError","erreur"],"mappings":"AAEA,MAAMA,EAAqCC,GAAiCC,GAC1EA,aAAmBD,EAERE,EAAuBH,EAA8B,iBAAiB,EAEtEI,EAAYC,GAAqCA,aAAkB"}
|
||||
File diff suppressed because one or more lines are too long
2
web/app/themes/haiku-atelier-2024/assets/js/index.js
Normal file
2
web/app/themes/haiku-atelier-2024/assets/js/index.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var h=Object.defineProperty;var m=(e,s,r)=>s in e?h(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r;var y=(e,s,r)=>m(e,typeof s!="symbol"?s+"":s,r);var c;function b(e){return{lang:e?.lang??c?.lang,message:e?.message,abortEarly:e?.abortEarly??c?.abortEarly,abortPipeEarly:e?.abortPipeEarly??c?.abortPipeEarly}}var g;function k(e){return g?.get(e)}var E;function _(e){return E?.get(e)}var d;function x(e,s){return d?.get(e)?.get(s)}function j(e){const s=typeof e;return s==="string"?`"${e}"`:s==="number"||s==="bigint"||s==="boolean"?`${e}`:s==="object"||s==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":s}function o(e,s,r,n,u){const i=u&&"input"in u?u.input:r.value,f=u?.expected??e.expects??null,l=u?.received??j(i),t={kind:e.kind,type:e.type,input:i,expected:f,received:l,message:`Invalid ${s}: ${f?`Expected ${f} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:u?.path,issues:u?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},a=e.kind==="schema",p=u?.message??e.message??x(e.reference,t.lang)??(a?_(t.lang):null)??n.message??k(t.lang);p&&(t.message=typeof p=="function"?p(t):p),a&&(r.typed=!1),r.issues?r.issues.push(t):r.issues=[t]}function $(e,s){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${s} `)})`:r[0]??"never"}var D=class extends Error{constructor(s){super(s[0].message);y(this,"issues");this.name="ValiError",this.issues=s}};function P(e){return{kind:"validation",type:"integer",reference:P,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(s,r){return s.typed&&!this.requirement(s.value)&&o(this,"integer",s,r),s}}}function w(e,s,r){return typeof e.default=="function"?e.default(s,r):e.default}function V(e,s){return!e._run({typed:!1,value:s},{abortEarly:!0}).issues}function I(e,s){return{kind:"schema",type:"array",reference:I,expects:"Array",async:!1,item:e,message:s,_run(r,n){const u=r.value;if(Array.isArray(u)){r.typed=!0,r.value=[];for(let i=0;i<u.length;i++){const f=u[i],l=this.item._run({typed:!1,value:f},n);if(l.issues){const t={type:"array",origin:"value",input:u,key:i,value:f};for(const a of l.issues)a.path?a.path.unshift(t):a.path=[t],r.issues?.push(a);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value.push(l.value)}}else o(this,"type",r,n);return r}}}function q(e){return{kind:"schema",type:"number",reference:q,expects:"number",async:!1,message:e,_run(s,r){return typeof s.value=="number"&&!isNaN(s.value)?s.typed=!0:o(this,"type",s,r),s}}}function S(e,s){return{kind:"schema",type:"object",reference:S,expects:"Object",async:!1,entries:e,message:s,_run(r,n){const u=r.value;if(u&&typeof u=="object"){r.typed=!0,r.value={};for(const i in this.entries){const f=u[i],l=this.entries[i]._run({typed:!1,value:f},n);if(l.issues){const t={type:"object",origin:"value",input:u,key:i,value:f};for(const a of l.issues)a.path?a.path.unshift(t):a.path=[t],r.issues?.push(a);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),(l.value!==void 0||i in u)&&(r.value[i]=l.value)}}else o(this,"type",r,n);return r}}}function A(e,...s){const r={kind:"schema",type:"optional",reference:A,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,u){return n.value===void 0&&("default"in this&&(n.value=w(this,n,u)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,u)}};return 0 in s&&(r.default=s[0]),r}function M(e){return{kind:"schema",type:"string",reference:M,expects:"string",async:!1,message:e,_run(s,r){return typeof s.value=="string"?s.typed=!0:o(this,"type",s,r),s}}}function v(e){let s;if(e)for(const r of e)s?s.push(...r.issues):s=r.issues;return s}function N(e,s){return{kind:"schema",type:"union",reference:N,expects:$(e.map(r=>r.expects),"|"),async:!1,options:e,message:s,_run(r,n){let u,i,f;for(const l of this.options){const t=l._run({typed:!1,value:r.value},n);if(t.typed)if(t.issues)i?i.push(t):i=[t];else{u=t;break}else f?f.push(t):f=[t]}if(u)return u;if(i){if(i.length===1)return i[0];o(this,"type",r,n,{issues:v(i)}),r.typed=!0}else{if(f?.length===1)return f[0];o(this,"type",r,n,{issues:v(f)})}return r}}}function O(){return{kind:"schema",type:"unknown",reference:O,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}function C(e,s,r){const n=e._run({typed:!1,value:s},b(r));if(n.issues)throw new D(n.issues);return n.value}function R(...e){return{...e[0],pipe:e,_run(s,r){for(const n of e)if(n.kind!=="metadata"){if(s.issues&&(n.kind==="schema"||n.kind==="transformation")){s.typed=!1;break}(!s.issues||!r.abortEarly&&!r.abortPipeEarly)&&(s=n._run(s,r))}return s}}}export{A as a,I as b,O as c,R as d,V as e,P as i,q as n,S as o,C as p,M as s,N as u};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
web/app/themes/haiku-atelier-2024/assets/js/index.js.map
Normal file
1
web/app/themes/haiku-atelier-2024/assets/js/index.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
import{b as e,c as r}from"./dom2.js";import"./chunk-7BKSRZNG.js";import"./erreurs.js";import"./exports.js";import"./Either.js";const p=e(document),u=r(document);export{p as a,u as r};
|
||||
import{r as e,a as r}from"./dom2.js";import"./chunk-7BKSRZNG.js";import"./erreurs.js";import"./exports.js";import"./Either.js";const p=e(document),u=r(document);export{p as a,u as r};
|
||||
//# sourceMappingURL=utils.js.map
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"utils.js","sources":["../../src/scripts/lib/utils.ts"],"sourcesContent":["import type { Either } from \"purify-ts\";\n\nimport { recupereElementAvecSelecteur, recupereElementsAvecSelecteur } from \"./dom\";\n\nexport const recupereElementsDocument: <E extends Element = Element>(\n selecteur: string,\n) => Either<SyntaxError, Array<E>> = recupereElementsAvecSelecteur(document);\n\nexport const recupereElementDocument: <E extends Element = Element>(selecteur: string) => Either<SyntaxError, E> =\n recupereElementAvecSelecteur(document);\n"],"names":["recupereElementsAvecSelecteur","recupereElementAvecSelecteur","recupereElementsDocument","recupereElementDocument"],"mappings":"AAIa,OAAA,KAAAA,EAAA,KAAAC,MAAA,YAAA,MAAA,sBAAA,MAAA,eAAA,MAAA,eAAA,MAAA,cAAA,MAAAC,EAEwBF,EAA8B,QAAQ,EAE9DG,EACXF,EAA6B,QAAQ"}
|
||||
{"version":3,"file":"utils.js","sources":["../../src/scripts/lib/utils.ts"],"sourcesContent":["import type { Either } from \"purify-ts\";\n\nimport { recupereElementAvecSelecteur, recupereElementsAvecSelecteur } from \"./dom.ts\";\n\nexport const recupereElementsDocumentEither: <E extends Element = Element>(\n selecteur: string,\n) => Either<SyntaxError, Array<E>> = recupereElementsAvecSelecteur(document);\n\nexport const recupereElementDocumentEither: <E extends Element = Element>(selecteur: string) => Either<SyntaxError, E> =\n recupereElementAvecSelecteur(document);\n"],"names":["recupereElementsAvecSelecteur","recupereElementAvecSelecteur","recupereElementsDocumentEither","recupereElementDocumentEither"],"mappings":"AAIa,OAAA,KAAAA,EAAA,KAAAC,MAAA,YAAA,MAAA,sBAAA,MAAA,eAAA,MAAA,eAAA,MAAA,cAAA,MAAAC,EAEwBF,EAA8B,QAAQ,EAE9DG,EACXF,EAA6B,QAAQ"}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use Timber\Timber;
|
||||
use function Crell\fp\pipe;
|
||||
|
||||
require_once __DIR__ . "/src/inc/HTML.php";
|
||||
require_once __DIR__ . "/src/inc/TraitementInformations.php";
|
||||
|
|
@ -15,15 +16,27 @@ $contexte = Timber::context();
|
|||
$modeles = ["produit.twig"];
|
||||
|
||||
$produit = recupere_informations_produit_page_produit(wc_get_product());
|
||||
$produits_collection = array_map(
|
||||
"recupere_informations_produit_page_produit",
|
||||
recupere_produits_meme_collection($produit["collection"])($produit["id"]),
|
||||
$valeurs_attribut_tailles = pipe(
|
||||
wc_get_product(),
|
||||
fn($produit) => $produit->get_attribute("pa_sizes"),
|
||||
fn($string) => explode(",", $string),
|
||||
);
|
||||
$produits_meme_collection = array_map(
|
||||
callback: "recupere_informations_produit_page_produit",
|
||||
array: recupere_produits_meme_collection($produit["collection"])($produit["id"]),
|
||||
);
|
||||
$nonce = wp_create_nonce("wc_store_api");
|
||||
|
||||
$contexte["produit"] = $produit;
|
||||
$contexte["produits_collection"] = $produits_collection;
|
||||
$contexte["nonce"] = $nonce;
|
||||
$contexte["produits_meme_collection"] = $produits_meme_collection;
|
||||
$contexte["tailles_produit"] = $valeurs_attribut_tailles;
|
||||
|
||||
/* Nonce WooCommerce pour l'API Rest */
|
||||
$nonce_wc = wp_create_nonce("wc_store_api");
|
||||
$contexte["nonce_wc"] = $nonce_wc;
|
||||
|
||||
// echo "<pre>"
|
||||
// print_r($produit);
|
||||
// echo "</pre>";
|
||||
|
||||
/**
|
||||
* Charge les Scripts nécessaires pour la page Produit.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace HaikuAtelier;
|
||||
|
||||
use Timber\Site;
|
||||
use function Crell\fp\pipe;
|
||||
|
||||
class StarterSite extends Site {
|
||||
public function __construct() {
|
||||
|
|
@ -23,21 +24,22 @@ class StarterSite extends Site {
|
|||
*/
|
||||
public function ajoute_au_contexte_twig(array $context): array {
|
||||
$context["site"] = $this;
|
||||
$personnalisations_theme = get_theme_mods();
|
||||
|
||||
// Récupère les liens des réseaux sociaux définis dans la personnalisation du thème
|
||||
$liens_reseaux_sociaux = [];
|
||||
$liens_reseaux_sociaux["facebook"] = [
|
||||
"nom" => "Facebook",
|
||||
"url" => $personnalisations_theme["lien_facebook"] ?? "",
|
||||
];
|
||||
$liens_reseaux_sociaux["instagram"] = [
|
||||
"nom" => "Instagram",
|
||||
"url" => $personnalisations_theme["lien_instagram"] ?? "",
|
||||
];
|
||||
$liens_reseaux_sociaux["pinterest"] = [
|
||||
"nom" => "Pinterest",
|
||||
"url" => $personnalisations_theme["lien_pinterest"] ?? "",
|
||||
$personnalisations_theme = get_theme_mods();
|
||||
$liens_reseaux_sociaux = [
|
||||
"facebook" => [
|
||||
"nom" => "Facebook",
|
||||
"url" => $personnalisations_theme["lien_facebook"] ?? "",
|
||||
],
|
||||
"instagram" => [
|
||||
"nom" => "Instagram",
|
||||
"url" => $personnalisations_theme["lien_instagram"] ?? "",
|
||||
],
|
||||
"pinterest" => [
|
||||
"nom" => "Pinterest",
|
||||
"url" => $personnalisations_theme["lien_pinterest"] ?? "",
|
||||
],
|
||||
];
|
||||
$context["liens_reseaux_sociaux"] = $liens_reseaux_sociaux;
|
||||
|
||||
|
|
@ -49,9 +51,10 @@ class StarterSite extends Site {
|
|||
$context["descriptions_produits"] = $descriptions_produits;
|
||||
|
||||
// Logo personnalisée
|
||||
$logo_personnalisee_id = get_theme_mod("custom_logo");
|
||||
$logo_personnalisee = wp_get_attachment_image_src($logo_personnalisee_id, "full");
|
||||
$context["logo"] = $logo_personnalisee;
|
||||
$context["logo"] = pipe(
|
||||
get_theme_mod("custom_logo"),
|
||||
fn($id) => wp_get_attachment_image_src(attachment_id: $id, size: "full"),
|
||||
);
|
||||
|
||||
// Informations des Pages
|
||||
$recupere_informations_page = function ($slug) {
|
||||
|
|
@ -64,7 +67,7 @@ class StarterSite extends Site {
|
|||
};
|
||||
|
||||
// Pages spécifiques
|
||||
$pages = (object) [
|
||||
$context["pages"] = (object) [
|
||||
"about" => $recupere_informations_page("about"),
|
||||
"account" => $recupere_informations_page("account"),
|
||||
"cart" => $recupere_informations_page("cart"),
|
||||
|
|
@ -74,23 +77,27 @@ class StarterSite extends Site {
|
|||
"shop" => $recupere_informations_page("shop"),
|
||||
];
|
||||
|
||||
$context["pages"] = $pages;
|
||||
|
||||
// Politique de confidentialité
|
||||
$politique_confidentialite_lien = esc_url(get_privacy_policy_url());
|
||||
$politique_confidentialite_lien = pipe(get_privacy_policy_url(), fn($url) => esc_url($url));
|
||||
$context["lien_politique_confidentialite"] = $politique_confidentialite_lien;
|
||||
|
||||
// Chemin de base pour une Catégorie de Produit (p. ex. /product-category/<produit>)
|
||||
$context["base_categorie_produit"] = get_option("woocommerce_permalinks")["category_base"] ?? "";
|
||||
|
||||
/* Récupère les Catégories de Produits */
|
||||
$categories_produits = get_categories([
|
||||
"hide_empty" => false,
|
||||
"orderby" => "menu_order",
|
||||
"taxonomy" => "product_cat",
|
||||
]);
|
||||
$cree_entree_menu = fn($categorie) => [
|
||||
"nom" => $categorie->name,
|
||||
"slug" => $categorie->slug,
|
||||
];
|
||||
$entrees_menu_categories = array_map($callback = $cree_entree_menu, $array = $categories_produits);
|
||||
// $entrees_menu_categories = array_map($callback = $cree_entree_menu, $array = $categories_produits);
|
||||
$entrees_menu_categories = pipe(
|
||||
get_categories([
|
||||
"hide_empty" => false,
|
||||
"orderby" => "menu_order",
|
||||
"taxonomy" => "product_cat",
|
||||
]),
|
||||
fn($categories) => array_map(callback: $cree_entree_menu, array: $categories),
|
||||
);
|
||||
|
||||
$context["categories_produits"] = $entrees_menu_categories;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ function recupere_informations_produit_shop($produit) {
|
|||
*/
|
||||
function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
||||
return [
|
||||
/* Attributs du Produit */
|
||||
"attributs" => wc_get_product()->get_attributes(),
|
||||
/* Slug de la Collection */
|
||||
"collection" => get_the_terms($donnees_produit->get_id(), "collection")[0]->slug,
|
||||
/* Détails (Description) du Produit */
|
||||
|
|
@ -81,6 +83,8 @@ function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
|||
),
|
||||
/* Slug du Produit */
|
||||
"slug" => $donnees_produit->get_slug(),
|
||||
/* Variations du Produit */
|
||||
"variations_ids" => $donnees_produit->get_children(),
|
||||
/* URL du Produit */
|
||||
"url" => $donnees_produit->get_permalink(),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
functionToStringIntegration,
|
||||
getCurrentScope,
|
||||
globalHandlersIntegration,
|
||||
httpClientIntegration,
|
||||
httpContextIntegration,
|
||||
linkedErrorsIntegration,
|
||||
} from "@sentry/browser";
|
||||
|
|
@ -52,12 +53,13 @@ const creeTransportFetch = (options: BrowserTransportOptions): Transport => {
|
|||
/* Créé la configuration Sentry */
|
||||
const client = new BrowserClient({
|
||||
dsn: import.meta.env.VITE_GLITCHTIP_NSD,
|
||||
environment: "local",
|
||||
environment: "development",
|
||||
integrations: [
|
||||
breadcrumbsIntegration(),
|
||||
dedupeIntegration(),
|
||||
functionToStringIntegration(),
|
||||
globalHandlersIntegration(),
|
||||
httpClientIntegration(),
|
||||
httpContextIntegration(),
|
||||
linkedErrorsIntegration(),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Right } from "purify-ts";
|
||||
import wretch from "wretch";
|
||||
|
||||
import { ROUTE_API_PANIER } from "../constantes/api";
|
||||
import { ROUTE_API_PANIER } from "../constantes/api.ts";
|
||||
|
||||
export const get = async (
|
||||
url: string,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Either, identity, Left, Right } from "purify-ts";
|
||||
import { isEmpty, isNonNull, pipe } from "remeda";
|
||||
|
||||
import type { ElementParent } from "../types/dom";
|
||||
import type { ElementParent } from "../types/dom.d.ts";
|
||||
|
||||
import { creeSyntaxError, ERREUR_SELECTEUR_INEXISTANT, ERREUR_SYNTAXE_INVALIDE, reporteEtLeveErreur } from "./erreurs";
|
||||
|
||||
|
|
|
|||
|
|
@ -4,22 +4,83 @@
|
|||
|
||||
import { captureException } from "@sentry/browser";
|
||||
|
||||
import type { WCErrorBody } from "../types/api/erreurs";
|
||||
|
||||
/* Messages d'erreur */
|
||||
export const ERREUR_SYNTAXE_INVALIDE: (selecteur: string) => string = (selecteur) =>
|
||||
`Le selecteur "${selecteur}" est invalide`;
|
||||
export const ERREUR_SELECTEUR_INEXISTANT: (selecteur: string) => string = (selecteur) =>
|
||||
export const ERREUR_SYNTAXE_INVALIDE = (selecteur: string): string => `Le selecteur "${selecteur}" est invalide`;
|
||||
export const ERREUR_SELECTEUR_INEXISTANT = (selecteur: string): string =>
|
||||
`La requête "${selecteur}" n'a retourné aucun Élément.`;
|
||||
|
||||
/* Création d'erreurs */
|
||||
export const creeSyntaxError: (message: string) => SyntaxError = (message) => new SyntaxError(message);
|
||||
export const creeSyntaxError = (message: string): SyntaxError => new SyntaxError(message);
|
||||
|
||||
/* Fonction utilitaire pour lever une Error */
|
||||
export const leveErreur = (erreur: Error): never => {
|
||||
/* Types d'erreurs */
|
||||
export class BadRequestError extends Error {
|
||||
constructor(message = "400 BadRequestError") {
|
||||
super(message);
|
||||
this.name = "BadRequestError";
|
||||
}
|
||||
}
|
||||
export class UnauthorizedError extends Error {
|
||||
constructor(message = "401 UnauthorizedError") {
|
||||
super(message);
|
||||
this.name = "UnauthorizedError";
|
||||
}
|
||||
}
|
||||
export class NotFoundError extends Error {
|
||||
constructor(message = "404 NotFoundError") {
|
||||
super(message);
|
||||
this.name = "NotFoundError";
|
||||
}
|
||||
}
|
||||
export class ServerError extends Error {
|
||||
constructor(message = "500 ServerError") {
|
||||
super(message);
|
||||
this.name = "ServerError";
|
||||
}
|
||||
}
|
||||
export class UnknownError extends Error {
|
||||
constructor(message: unknown) {
|
||||
super(JSON.stringify(message));
|
||||
this.name = "UnknownError";
|
||||
}
|
||||
}
|
||||
|
||||
/* Fonction utilitaire pour créer ou lever des Erreurs */
|
||||
export const Erreur = (message: string): Error => new Error(message);
|
||||
export const ErreurInconnue = (erreur: unknown): UnknownError => new UnknownError(erreur);
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer
|
||||
le type d'Erreur à l'appel de la fonction. */
|
||||
export const leveErreur = <E extends Error = Error>(erreur: E): never => {
|
||||
throw erreur;
|
||||
};
|
||||
export const leveBadRequestError = (erreur: WCErrorBody): never => {
|
||||
throw new BadRequestError(`(${erreur.code}) ${erreur.message}`);
|
||||
};
|
||||
export const leveUnauthorizedError = (erreur: WCErrorBody): never => {
|
||||
throw new UnauthorizedError(`(${erreur.code}) ${erreur.message}`);
|
||||
};
|
||||
export const leveNotFoundError = (erreur: WCErrorBody): never => {
|
||||
throw new NotFoundError(`(${erreur.code}) ${erreur.message}`);
|
||||
};
|
||||
export const leveServerError = (message: string): never => {
|
||||
throw new ServerError(message);
|
||||
};
|
||||
export const leveUnknownError = (erreur: unknown): never => {
|
||||
throw new UnknownError(erreur);
|
||||
};
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer
|
||||
le type d'Erreur à l'appel de la fonction. */
|
||||
le type d'Erreur à l'appel de la fonction. */
|
||||
export const reporteErreur = <E extends Error>(erreur: E): string => captureException(erreur);
|
||||
|
||||
/**
|
||||
* Reporte une Erreur au service GlitchTip puis la lève sous forme d'Exception.
|
||||
* @param erreur
|
||||
*/
|
||||
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Permet d'indiquer
|
||||
le type d'Erreur à l'appel de la fonction. */
|
||||
export const reporteEtLeveErreur = <E extends Error>(erreur: E): never => {
|
||||
captureException(erreur);
|
||||
throw erreur;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
type Constructor<T> = new(...args: Array<unknown>) => T;
|
||||
import type { Constructor } from "../types/classes";
|
||||
|
||||
const estElement = <T extends HTMLElement>(typeElement: Constructor<T>) => (element: unknown): element is T =>
|
||||
element instanceof typeElement;
|
||||
|
||||
export const estHTMLSelectElement = estElement<HTMLSelectElement>(HTMLSelectElement);
|
||||
|
||||
export const estError = (erreur: unknown): erreur is Error => erreur instanceof Error;
|
||||
|
||||
export const estReponse500 = (reponse: Response): boolean => reponse.status === 500;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import { type Either, EitherAsync, Left, Right } from "purify-ts";
|
||||
|
||||
import { ENTETE_WC_NONCE, ROUTE_API_PANIER } from "../constantes/api";
|
||||
import { ENTETE_WC_NONCE, ROUTE_API_PANIER } from "../constantes/api.ts";
|
||||
|
||||
/** États utiles pour les scripts. */
|
||||
interface Etats {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
import * as v from "valibot";
|
||||
|
||||
const WCStoreCartAddItemArgsItemsSchema = v.object({
|
||||
import type { WCStoreCartAddItemArgs } from "../../types/api/cart-add-item.ts";
|
||||
|
||||
export const WCStoreCartAddItemArgsItemsSchema = v.object({
|
||||
/** Variation attribute name. */
|
||||
attribute: v.string(),
|
||||
/** Variation attribute value. */
|
||||
value: v.string(),
|
||||
});
|
||||
|
||||
const WCStoreCartAddItemArgsSchema = v.object({
|
||||
export const WCStoreCartAddItemArgsSchema = v.object({
|
||||
/** The basket item product or variation ID. */
|
||||
id: v.optional(v.number()),
|
||||
/** Quantity of this item to add to the basket. */
|
||||
|
|
@ -16,8 +18,5 @@ const WCStoreCartAddItemArgsSchema = v.object({
|
|||
variation: v.optional(v.array(WCStoreCartAddItemArgsItemsSchema)),
|
||||
});
|
||||
|
||||
export type WCStoreCartAddItemArgsItems = v.InferOutput<typeof WCStoreCartAddItemArgsItemsSchema>;
|
||||
export type WCStoreCartAddItemArgs = v.InferOutput<typeof WCStoreCartAddItemArgsSchema>;
|
||||
|
||||
export const WCStoreCartAddItemArgs: (args: unknown) => WCStoreCartAddItemArgs = (args) =>
|
||||
export const parseWCStoreCartAddItemArgs: (args: unknown) => WCStoreCartAddItemArgs = (args) =>
|
||||
v.parse(WCStoreCartAddItemArgsSchema, args);
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import * as v from "valibot";
|
||||
|
||||
const WCStoreCartItemTotalsSchema = v.object({
|
||||
currency_code: v.string(),
|
||||
currency_decimal_separator: v.string(),
|
||||
currency_minor_unit: v.number(),
|
||||
currency_prefix: v.string(),
|
||||
currency_suffix: v.string(),
|
||||
currency_symbol: v.string(),
|
||||
currency_thousand_separator: v.string(),
|
||||
total_discount: v.string(),
|
||||
total_discount_tax: v.string(),
|
||||
});
|
||||
|
||||
const WCStoreCartItemShippingRateSchema = v.object({
|
||||
name: v.string(),
|
||||
package_id: v.union([v.number(), v.string()]),
|
||||
});
|
||||
|
||||
const WCStoreCartItemSchema = v.object({
|
||||
code: v.string(),
|
||||
discount_type: v.string(),
|
||||
shipping_rates: v.array(WCStoreCartItemShippingRateSchema),
|
||||
totals: v.array(WCStoreCartItemTotalsSchema),
|
||||
});
|
||||
|
||||
export const WCStoreCartSchema = v.object({
|
||||
billing_address: v.unknown(),
|
||||
coupons: v.unknown(),
|
||||
cross_sells: v.unknown(),
|
||||
errors: v.unknown(),
|
||||
extensions: v.unknown(),
|
||||
fees: v.unknown(),
|
||||
has_calculated_shipping: v.unknown(),
|
||||
items: v.array(v.unknown()),
|
||||
items_count: v.pipe(v.number(), v.integer()),
|
||||
items_weight: v.unknown(),
|
||||
needs_payment: v.unknown(),
|
||||
needs_shipping: v.unknown(),
|
||||
payment_methods: v.unknown(),
|
||||
payment_requirements: v.unknown(),
|
||||
shipping_address: v.unknown(),
|
||||
shipping_rates: v.unknown(),
|
||||
totals: v.unknown(),
|
||||
});
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import * as v from "valibot";
|
||||
|
||||
import type { WCError } from "../../types/api/erreurs";
|
||||
|
||||
export const WCErrorBodySchema = v.object({
|
||||
code: v.string(),
|
||||
data: v.object({
|
||||
status: v.number(),
|
||||
}),
|
||||
message: v.string(),
|
||||
});
|
||||
|
||||
export const WCErrorSchema = v.object({
|
||||
body: WCErrorBodySchema,
|
||||
status: v.number(),
|
||||
});
|
||||
|
||||
export const isWCError = (donnees: unknown): donnees is WCError => v.is(WCErrorSchema, donnees);
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import type { Either } from "purify-ts";
|
||||
|
||||
import { recupereElementAvecSelecteur, recupereElementsAvecSelecteur } from "./dom";
|
||||
import { recupereElementAvecSelecteur, recupereElementsAvecSelecteur } from "./dom.ts";
|
||||
|
||||
export const recupereElementsDocument: <E extends Element = Element>(
|
||||
export const recupereElementsDocumentEither: <E extends Element = Element>(
|
||||
selecteur: string,
|
||||
) => Either<SyntaxError, Array<E>> = recupereElementsAvecSelecteur(document);
|
||||
|
||||
export const recupereElementDocument: <E extends Element = Element>(selecteur: string) => Either<SyntaxError, E> =
|
||||
export const recupereElementDocumentEither: <E extends Element = Element>(selecteur: string) => Either<SyntaxError, E> =
|
||||
recupereElementAvecSelecteur(document);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
// Scripts pour la Page Produit
|
||||
|
||||
import { Either, Maybe } from "purify-ts";
|
||||
import { pipe } from "remeda";
|
||||
import { pipe, prop, tap } from "remeda";
|
||||
import { match, P } from "ts-pattern";
|
||||
import { parse, value } from "valibot";
|
||||
|
||||
import { ENTETE_WC_NONCE, ROUTE_API_AJOUTE_ARTICLE_PANIER } from "./constantes/api";
|
||||
import type { WCStoreCart } from "./types/api/cart";
|
||||
import type { WCStoreCartAddItemArgs } from "./types/api/cart-add-item.ts";
|
||||
|
||||
import { ENTETE_WC_NONCE, ROUTE_API_AJOUTE_ARTICLE_PANIER } from "./constantes/api.ts";
|
||||
import {
|
||||
ATTRIBUT_ARIA_SELECTED,
|
||||
ATTRIBUT_CONTIENT_ARTICLES,
|
||||
|
|
@ -15,11 +20,22 @@ import {
|
|||
SELECTEUR_SECTIONS_CONTENUS,
|
||||
SELECTEUR_SELECTEUR_QUANTITE,
|
||||
} from "./constantes/dom";
|
||||
import { recupereElementOuLeve, recupereElementsOuLeve } from "./lib/dom";
|
||||
import { reporteEtLeveErreur } from "./lib/erreurs";
|
||||
import { estHTMLSelectElement } from "./lib/gardes";
|
||||
import { recupereElementDocument, recupereElementsDocument } from "./lib/utils";
|
||||
import { WCStoreCartAddItemArgs } from "./types/api/cart-add-item";
|
||||
import { recupereElementOuLeve, recupereElementsOuLeve } from "./lib/dom.ts";
|
||||
import {
|
||||
ErreurInconnue,
|
||||
leveBadRequestError,
|
||||
leveErreur,
|
||||
leveNotFoundError,
|
||||
leveServerError,
|
||||
leveUnauthorizedError,
|
||||
reporteErreur,
|
||||
type UnknownError,
|
||||
} from "./lib/erreurs.ts";
|
||||
import { estError, estHTMLSelectElement, estReponse500 } from "./lib/gardes.ts";
|
||||
import { parseWCStoreCartAddItemArgs } from "./lib/schemas/cart-add.item.ts";
|
||||
import { WCStoreCartSchema } from "./lib/schemas/cart.ts";
|
||||
import { isWCError } from "./lib/schemas/erreurs.ts";
|
||||
import { recupereElementDocumentEither, recupereElementsDocumentEither } from "./lib/utils.ts";
|
||||
|
||||
/** États utiles pour les scripts de la page. */
|
||||
type EtatsPage = {
|
||||
|
|
@ -46,45 +62,44 @@ const deplieToutesSections = (ensembleLiensContenus: Array<EnsembleLienContenu>)
|
|||
};
|
||||
|
||||
// Éléments d'intérêt
|
||||
// TODO: C'est stupide de conserver des Either, en cas d'absence de ces éléments lever une Error, afficher un message à l'Utilisateur et arrêter le script
|
||||
/** Le « Bouton » vers le Panier dont le texte est un indicateur du nombre de Produits dedans. */
|
||||
const BOUTON_PANIER: HTMLAnchorElement = pipe(
|
||||
recupereElementDocument<HTMLAnchorElement>(SELECTEUR_BOUTON_PANIER),
|
||||
recupereElementDocumentEither<HTMLAnchorElement>(SELECTEUR_BOUTON_PANIER),
|
||||
recupereElementOuLeve,
|
||||
);
|
||||
/** Le Bouton permettant l'ajout d'un Produit dans le Panier. */
|
||||
const BOUTON_AJOUT_PANIER: HTMLButtonElement = pipe(
|
||||
recupereElementDocument<HTMLButtonElement>(SELECTEUR_BOUTON_AJOUT_PANIER),
|
||||
recupereElementDocumentEither<HTMLButtonElement>(SELECTEUR_BOUTON_AJOUT_PANIER),
|
||||
recupereElementOuLeve,
|
||||
);
|
||||
/** Le Sélecteur de Variation de Produit. */
|
||||
const SELECTEUR_VARIATION: HTMLSelectElement = pipe(
|
||||
recupereElementDocument<HTMLSelectElement>(SELECTEUR_SELECTEUR_QUANTITE),
|
||||
recupereElementDocumentEither<HTMLSelectElement>(SELECTEUR_SELECTEUR_QUANTITE),
|
||||
recupereElementOuLeve,
|
||||
);
|
||||
/** */
|
||||
const LIENS_ONGLETS: Array<HTMLAnchorElement> = pipe(
|
||||
recupereElementsDocument<HTMLAnchorElement>(SELECTEUR_LIENS_ONGLETS),
|
||||
recupereElementsDocumentEither<HTMLAnchorElement>(SELECTEUR_LIENS_ONGLETS),
|
||||
recupereElementsOuLeve,
|
||||
);
|
||||
/** */
|
||||
const SECTIONS_CONTENUS: Array<HTMLElement> = pipe(
|
||||
recupereElementsDocument<HTMLElement>(SELECTEUR_SECTIONS_CONTENUS),
|
||||
recupereElementsDocumentEither<HTMLElement>(SELECTEUR_SECTIONS_CONTENUS),
|
||||
recupereElementsOuLeve,
|
||||
);
|
||||
|
||||
const suitMutationsBoutonAjoutPanier = (boutonAjoutPanier: HTMLButtonElement): void => {
|
||||
const mutationCallback: MutationCallback = (mutationsList: Array<MutationRecord>) => {
|
||||
for (const mutation of mutationsList) {
|
||||
if (mutation.type !== "attributes" || mutation.attributeName !== ATTRIBUT_DESACTIVE) return;
|
||||
// const suitMutationsBoutonAjoutPanier = (boutonAjoutPanier: HTMLButtonElement): void => {
|
||||
// const mutationCallback: MutationCallback = (mutationsList: Array<MutationRecord>) => {
|
||||
// for (const mutation of mutationsList) {
|
||||
// if (mutation.type !== "attributes" || mutation.attributeName !== ATTRIBUT_DESACTIVE) return;
|
||||
|
||||
console.log("old:", mutation.oldValue);
|
||||
console.log("new:", (mutation.target as HTMLButtonElement).getAttribute(ATTRIBUT_DESACTIVE));
|
||||
}
|
||||
};
|
||||
const observer = new MutationObserver(mutationCallback);
|
||||
observer.observe(boutonAjoutPanier, { attributes: true });
|
||||
};
|
||||
// console.log("old:", mutation.oldValue);
|
||||
// console.log("new:", (mutation.target as HTMLButtonElement).getAttribute(ATTRIBUT_DESACTIVE));
|
||||
// }
|
||||
// };
|
||||
// const observer = new MutationObserver(mutationCallback);
|
||||
// observer.observe(boutonAjoutPanier, { attributes: true });
|
||||
// };
|
||||
|
||||
const gereBoiteInformationsProduit = () => {
|
||||
const onglets = new Map<string, EnsembleLienContenu>();
|
||||
|
|
@ -131,19 +146,20 @@ const gereBoiteInformationsProduit = () => {
|
|||
|
||||
// TODO: Traiter le cas des Produits avec variations
|
||||
const ajouteProduitAuPanier = () => {
|
||||
const requeteInvalide: WCStoreCartAddItemArgs = {
|
||||
id: ETATS_PAGE.idProduit,
|
||||
quantity: 1,
|
||||
};
|
||||
|
||||
/* État de chargement */
|
||||
BOUTON_AJOUT_PANIER.textContent = "Adding...";
|
||||
|
||||
// TODO: Traiter les cas d'erreurs avec ts-pattern
|
||||
// TODO: Rendre ça moins long
|
||||
// TODO: Créer une méthode pour fetch()
|
||||
// TODO: Créer une méthode pour traiter les codes HTTP
|
||||
/* Exécution de la requête */
|
||||
Either
|
||||
.encase<Error, WCStoreCartAddItemArgs>(() => WCStoreCartAddItemArgs(requeteInvalide))
|
||||
.ifLeft(e => console.error(e))
|
||||
.encase<Error, WCStoreCartAddItemArgs>(() =>
|
||||
parseWCStoreCartAddItemArgs({
|
||||
id: Number(SELECTEUR_VARIATION.value),
|
||||
quantity: 1,
|
||||
})
|
||||
)
|
||||
.map((args: WCStoreCartAddItemArgs) => {
|
||||
fetch(
|
||||
ROUTE_API_AJOUTE_ARTICLE_PANIER,
|
||||
|
|
@ -160,26 +176,57 @@ const ajouteProduitAuPanier = () => {
|
|||
signal: AbortSignal.timeout(5000),
|
||||
},
|
||||
)
|
||||
.then((reponse: Response) => reponse.json())
|
||||
.then((corps: unknown) => {
|
||||
// TODO: Validation du corps de la Réponse
|
||||
/**
|
||||
* À la réception du nouveau Panier du backend :
|
||||
* 1. Met à jour la quantité de Produits dans le Bouton du Panier
|
||||
* 2. Met à jour le Bouton d'ajout au Panier avec un message de succès
|
||||
* 3. (3 secondes) Réinitialise le Sélecteur de Quantité et le Bouton d'Ajout au Panier
|
||||
*/
|
||||
BOUTON_PANIER.textContent = `cart (${corps.items.length})`;
|
||||
BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(corps.items.length > 0));
|
||||
BOUTON_AJOUT_PANIER.textContent = "Added to cart!";
|
||||
.then(async (reponse: Response) => {
|
||||
// Traite le cas d'erreur 500
|
||||
if (estReponse500(reponse)) leveServerError("500 Server Error");
|
||||
|
||||
setTimeout(() => {
|
||||
SELECTEUR_VARIATION.value = SELECTEUR_VARIATION.options.item(0)?.value ?? "--";
|
||||
BOUTON_AJOUT_PANIER.textContent = "Add to cart";
|
||||
BOUTON_AJOUT_PANIER.toggleAttribute(ATTRIBUT_DESACTIVE, true);
|
||||
}, 3000);
|
||||
pipe(
|
||||
// Récupère la Réponse
|
||||
await reponse.json(),
|
||||
// Traite tous les codes HTTPs possibles
|
||||
(corpsReponse: unknown) =>
|
||||
match(corpsReponse)
|
||||
// Réponses problématiques
|
||||
.with({ body: P.select(), status: 400 }, isWCError, leveBadRequestError)
|
||||
.with({ body: P.select(), status: 401 }, isWCError, leveUnauthorizedError)
|
||||
.with({ body: P.select(), status: 404 }, isWCError, leveNotFoundError)
|
||||
// Réponse OK (201)
|
||||
.with(P._, corpsOkInconnu => parse(WCStoreCartSchema, corpsOkInconnu))
|
||||
// Réponses inconnues
|
||||
.otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>)),
|
||||
tap((panier: WCStoreCart) => console.debug("Panier", panier)),
|
||||
// Récupère le nombre de Produits dans la Panier
|
||||
prop("items"),
|
||||
prop("length"),
|
||||
// Déclenche les effets pour la mise à jour de l'IU
|
||||
tap((nombreArticlesPanier: number) => {
|
||||
/**
|
||||
* À la réception du nouveau Panier du backend :
|
||||
* 1. Met à jour la quantité de Produits dans le Bouton du Panier
|
||||
* 2. Met à jour le Bouton d'ajout au Panier avec un message de succès
|
||||
* 3. (3 secondes) Réinitialise le Sélecteur de Quantité et le Bouton d'Ajout au Panier
|
||||
*/
|
||||
BOUTON_PANIER.textContent = `cart (${String(nombreArticlesPanier)})`;
|
||||
BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(nombreArticlesPanier > 0));
|
||||
BOUTON_AJOUT_PANIER.textContent = "Added to cart!";
|
||||
|
||||
setTimeout(() => {
|
||||
SELECTEUR_VARIATION.value = SELECTEUR_VARIATION.options.item(0)?.value ?? "--";
|
||||
BOUTON_AJOUT_PANIER.toggleAttribute(ATTRIBUT_DESACTIVE, true);
|
||||
BOUTON_AJOUT_PANIER.textContent = "Add to cart";
|
||||
}, 3000);
|
||||
}),
|
||||
);
|
||||
})
|
||||
.catch(reporteEtLeveErreur);
|
||||
.catch((e: unknown) => {
|
||||
if (estError(e)) {
|
||||
reporteErreur(e);
|
||||
console.error(e);
|
||||
} else {
|
||||
console.error("e n'est pas une Erreur ?!", e);
|
||||
}
|
||||
BOUTON_AJOUT_PANIER.textContent = "Add to cart";
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
9
web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart-add-item.d.ts
vendored
Normal file
9
web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart-add-item.d.ts
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import type { InferOutput } from "valibot";
|
||||
|
||||
import type {
|
||||
WCStoreCartAddItemArgsItemsSchema,
|
||||
WCStoreCartAddItemArgsSchema,
|
||||
} from "../../lib/schemas/cart-add.item.ts";
|
||||
|
||||
export type WCStoreCartAddItemArgsItems = InferOutput<typeof WCStoreCartAddItemArgsItemsSchema>;
|
||||
export type WCStoreCartAddItemArgs = InferOutput<typeof WCStoreCartAddItemArgsSchema>;
|
||||
5
web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart.d.ts
vendored
Normal file
5
web/app/themes/haiku-atelier-2024/src/scripts/types/api/cart.d.ts
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import type { InferOutput } from "valibot";
|
||||
|
||||
import type { WCStoreCartSchema } from "../../lib/schemas/cart.ts";
|
||||
|
||||
export type WCStoreCart = InferOutput<typeof WCStoreCartSchema>;
|
||||
6
web/app/themes/haiku-atelier-2024/src/scripts/types/api/erreurs.d.ts
vendored
Normal file
6
web/app/themes/haiku-atelier-2024/src/scripts/types/api/erreurs.d.ts
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import type { InferOutput } from "valibot";
|
||||
|
||||
import type { WCErrorBodySchema, WCErrorSchema } from "../../lib/schemas/erreurs.ts";
|
||||
|
||||
export type WCErrorBody = InferOutput<typeof WCErrorBodySchema>;
|
||||
export type WCError = InferOutput<typeof WCErrorSchema>;
|
||||
1
web/app/themes/haiku-atelier-2024/src/scripts/types/classes.d.ts
vendored
Normal file
1
web/app/themes/haiku-atelier-2024/src/scripts/types/classes.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export type Constructor<T> = new(...args: Array<unknown>) => T;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<li><a href="{{ pages.shop.lien }}">All</a></li>
|
||||
{% for categorie in categories_produits %}
|
||||
<li id="categorie-{{ categorie.slug|e }}">
|
||||
<a href="/categorie-produit/{{ categorie.slug|e }}">{{ categorie.nom|e }}</a>
|
||||
<a href="/{{ base_categorie_produit }}/{{ categorie.slug|e }}">{{ categorie.nom|e }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="grille-produits-similaires">
|
||||
{% for produit in produits_collection %}
|
||||
{% for produit in produits_meme_collection %}
|
||||
{# TODO: Trouver une meilleure arborescence et des noms de classe #}
|
||||
<article class="produit">
|
||||
<figure>
|
||||
|
|
|
|||
|
|
@ -45,13 +45,9 @@
|
|||
name="variations"
|
||||
>
|
||||
<option disabled selected value="">--</option>
|
||||
<option value="50">50</option>
|
||||
<option value="52">52</option>
|
||||
<option value="54">54</option>
|
||||
<option value="56">56</option>
|
||||
<option value="58">58</option>
|
||||
<option value="60">60</option>
|
||||
<option value="62">62</option>
|
||||
{% for taille in tailles_produit %}
|
||||
<option value="{{ produit.variations_ids[loop.index0] }}">{{ taille }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
{# <div aria-hidden="true" class="selecteur-personnalise">
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
/** @type {Etats} */
|
||||
const _etats = {
|
||||
idProduit: {{ produit.id }},
|
||||
nonce: "{{ nonce }}",
|
||||
nonce: "{{ nonce_wc }}",
|
||||
};
|
||||
</script>
|
||||
{% endblock head %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue