@obb871001/api-integration-sdk 1.0.9 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@tanstack/react-query");const A=require("react"),re=require("axios"),S=A.createContext(null),te=()=>{const s=A.useContext(S);if(!s)throw new Error("useApiContext must be used within ApiProvider");return s};var T={exports:{}},E={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var D;function ne(){if(D)return E;D=1;var s=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function f(m,u,l){var d=null;if(l!==void 0&&(d=""+l),u.key!==void 0&&(d=""+u.key),"key"in u){l={};for(var i in u)i!=="key"&&(l[i]=u[i])}else l=u;return u=l.ref,{$$typeof:s,type:m,key:d,ref:u!==void 0?u:null,props:l}}return E.Fragment=c,E.jsx=f,E.jsxs=f,E}var p={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var M;function ae(){return M||(M=1,process.env.NODE_ENV!=="production"&&(function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case z:return"Profiler";case W:return"StrictMode";case X:return"Suspense";case B:return"SuspenseList";case Z:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case U:return"Portal";case V:return e.displayName||"Context";case J:return(e._context.displayName||"Context")+".Consumer";case G:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case x:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function c(e){return""+e}function f(e){try{c(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),c(e)}}function m(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===x)return"<...>";try{var r=s(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function u(){var e=P.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function d(e){if(N.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function i(e,r){function t(){Y||(Y=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function o(){var e=s(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function v(e,r,t,n,b,h){var a=t.ref;return e={$$typeof:g,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:o}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:b}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:h}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function w(e,r,t,n,b,h){var a=r.children;if(a!==void 0)if(n)if(K(a)){for(n=0;n<a.length;n++)j(a[n]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(a);if(N.call(r,"key")){a=s(e);var _=Object.keys(r).filter(function(ee){return ee!=="key"});n=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",q[a+n]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,n,a,_,a),q[a+n]=!0)}if(a=null,t!==void 0&&(f(t),a=""+t),d(r)&&(f(r.key),a=""+r.key),"key"in r){t={};for(var y in r)y!=="key"&&(t[y]=r[y])}else t=r;return a&&i(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),v(e,a,t,u(),b,h)}function j(e){C(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===x&&(e._payload.status==="fulfilled"?C(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function C(e){return typeof e=="object"&&e!==null&&e.$$typeof===g}var R=A,g=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),J=Symbol.for("react.consumer"),V=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),P=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,K=Array.isArray,O=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var Y,$={},I=R.react_stack_bottom_frame.bind(R,l)(),F=O(m(l)),q={};p.Fragment=k,p.jsx=function(e,r,t){var n=1e4>P.recentlyCreatedOwnerStacks++;return w(e,r,t,!1,n?Error("react-stack-top-frame"):I,n?O(m(e)):F)},p.jsxs=function(e,r,t){var n=1e4>P.recentlyCreatedOwnerStacks++;return w(e,r,t,!0,n?Error("react-stack-top-frame"):I,n?O(m(e)):F)}})()),p}var L;function oe(){return L||(L=1,process.env.NODE_ENV==="production"?T.exports=ne():T.exports=ae()),T.exports}var se=oe();function ue({baseURL:s,getToken:c,timeoutMs:f=15e3,axiosInstance:m,currency:u,lng:l,onError:d}={}){const i=m??re.create({baseURL:s,timeout:f,headers:{"Content-Type":"application/json"}});return i.interceptors.request.use(async o=>{if(c){const v=await c();v&&(o.headers=o.headers||{},o.headers.Authorization=`Bearer ${v}`)}return o}),i.interceptors.request.use(o=>{o.headers.Currency=u,o.headers["currency-code"]=u,o.headers.lang=l}),i.interceptors.response.use(o=>o,o=>d?d(o,{instance:i}):Promise.reject(o)),i}function le({children:s,...c}){const f=A.useMemo(()=>ue(c),[c]);return se.jsx(S.Provider,{value:{client:f},children:s})}exports.ApiCtx=S;exports.ApiProvider=le;exports.useApiContext=te;
package/dist/index.js ADDED
@@ -0,0 +1,323 @@
1
+ import "@tanstack/react-query";
2
+ import ee, { createContext as re, useContext as te, useMemo as ne } from "react";
3
+ import ae from "axios";
4
+ const M = re(null), me = () => {
5
+ const s = te(M);
6
+ if (!s)
7
+ throw new Error("useApiContext must be used within ApiProvider");
8
+ return s;
9
+ };
10
+ var T = { exports: {} }, E = {};
11
+ /**
12
+ * @license React
13
+ * react-jsx-runtime.production.js
14
+ *
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+ var F;
21
+ function oe() {
22
+ if (F) return E;
23
+ F = 1;
24
+ var s = Symbol.for("react.transitional.element"), c = Symbol.for("react.fragment");
25
+ function f(m, u, l) {
26
+ var d = null;
27
+ if (l !== void 0 && (d = "" + l), u.key !== void 0 && (d = "" + u.key), "key" in u) {
28
+ l = {};
29
+ for (var i in u)
30
+ i !== "key" && (l[i] = u[i]);
31
+ } else l = u;
32
+ return u = l.ref, {
33
+ $$typeof: s,
34
+ type: m,
35
+ key: d,
36
+ ref: u !== void 0 ? u : null,
37
+ props: l
38
+ };
39
+ }
40
+ return E.Fragment = c, E.jsx = f, E.jsxs = f, E;
41
+ }
42
+ var p = {};
43
+ /**
44
+ * @license React
45
+ * react-jsx-runtime.development.js
46
+ *
47
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ */
52
+ var D;
53
+ function se() {
54
+ return D || (D = 1, process.env.NODE_ENV !== "production" && (function() {
55
+ function s(e) {
56
+ if (e == null) return null;
57
+ if (typeof e == "function")
58
+ return e.$$typeof === Z ? null : e.displayName || e.name || null;
59
+ if (typeof e == "string") return e;
60
+ switch (e) {
61
+ case A:
62
+ return "Fragment";
63
+ case q:
64
+ return "Profiler";
65
+ case W:
66
+ return "StrictMode";
67
+ case G:
68
+ return "Suspense";
69
+ case X:
70
+ return "SuspenseList";
71
+ case H:
72
+ return "Activity";
73
+ }
74
+ if (typeof e == "object")
75
+ switch (typeof e.tag == "number" && console.error(
76
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
77
+ ), e.$$typeof) {
78
+ case U:
79
+ return "Portal";
80
+ case J:
81
+ return e.displayName || "Context";
82
+ case z:
83
+ return (e._context.displayName || "Context") + ".Consumer";
84
+ case V:
85
+ var r = e.render;
86
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
87
+ case B:
88
+ return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
89
+ case k:
90
+ r = e._payload, e = e._init;
91
+ try {
92
+ return s(e(r));
93
+ } catch {
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ function c(e) {
99
+ return "" + e;
100
+ }
101
+ function f(e) {
102
+ try {
103
+ c(e);
104
+ var r = !1;
105
+ } catch {
106
+ r = !0;
107
+ }
108
+ if (r) {
109
+ r = console;
110
+ var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
111
+ return t.call(
112
+ r,
113
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
114
+ n
115
+ ), c(e);
116
+ }
117
+ }
118
+ function m(e) {
119
+ if (e === A) return "<>";
120
+ if (typeof e == "object" && e !== null && e.$$typeof === k)
121
+ return "<...>";
122
+ try {
123
+ var r = s(e);
124
+ return r ? "<" + r + ">" : "<...>";
125
+ } catch {
126
+ return "<...>";
127
+ }
128
+ }
129
+ function u() {
130
+ var e = x.A;
131
+ return e === null ? null : e.getOwner();
132
+ }
133
+ function l() {
134
+ return Error("react-stack-top-frame");
135
+ }
136
+ function d(e) {
137
+ if (C.call(e, "key")) {
138
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
139
+ if (r && r.isReactWarning) return !1;
140
+ }
141
+ return e.key !== void 0;
142
+ }
143
+ function i(e, r) {
144
+ function t() {
145
+ N || (N = !0, console.error(
146
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
147
+ r
148
+ ));
149
+ }
150
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
151
+ get: t,
152
+ configurable: !0
153
+ });
154
+ }
155
+ function o() {
156
+ var e = s(this.type);
157
+ return g[e] || (g[e] = !0, console.error(
158
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
159
+ )), e = this.props.ref, e !== void 0 ? e : null;
160
+ }
161
+ function R(e, r, t, n, b, O) {
162
+ var a = t.ref;
163
+ return e = {
164
+ $$typeof: j,
165
+ type: e,
166
+ key: r,
167
+ props: t,
168
+ _owner: n
169
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
170
+ enumerable: !1,
171
+ get: o
172
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
173
+ configurable: !1,
174
+ enumerable: !1,
175
+ writable: !0,
176
+ value: 0
177
+ }), Object.defineProperty(e, "_debugInfo", {
178
+ configurable: !1,
179
+ enumerable: !1,
180
+ writable: !0,
181
+ value: null
182
+ }), Object.defineProperty(e, "_debugStack", {
183
+ configurable: !1,
184
+ enumerable: !1,
185
+ writable: !0,
186
+ value: b
187
+ }), Object.defineProperty(e, "_debugTask", {
188
+ configurable: !1,
189
+ enumerable: !1,
190
+ writable: !0,
191
+ value: O
192
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
193
+ }
194
+ function w(e, r, t, n, b, O) {
195
+ var a = r.children;
196
+ if (a !== void 0)
197
+ if (n)
198
+ if (Q(a)) {
199
+ for (n = 0; n < a.length; n++)
200
+ y(a[n]);
201
+ Object.freeze && Object.freeze(a);
202
+ } else
203
+ console.error(
204
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
205
+ );
206
+ else y(a);
207
+ if (C.call(r, "key")) {
208
+ a = s(e);
209
+ var _ = Object.keys(r).filter(function(K) {
210
+ return K !== "key";
211
+ });
212
+ n = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", I[a + n] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
213
+ `A props object containing a "key" prop is being spread into JSX:
214
+ let props = %s;
215
+ <%s {...props} />
216
+ React keys must be passed directly to JSX without using spread:
217
+ let props = %s;
218
+ <%s key={someKey} {...props} />`,
219
+ n,
220
+ a,
221
+ _,
222
+ a
223
+ ), I[a + n] = !0);
224
+ }
225
+ if (a = null, t !== void 0 && (f(t), a = "" + t), d(r) && (f(r.key), a = "" + r.key), "key" in r) {
226
+ t = {};
227
+ for (var P in r)
228
+ P !== "key" && (t[P] = r[P]);
229
+ } else t = r;
230
+ return a && i(
231
+ t,
232
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
233
+ ), R(
234
+ e,
235
+ a,
236
+ t,
237
+ u(),
238
+ b,
239
+ O
240
+ );
241
+ }
242
+ function y(e) {
243
+ S(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? S(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
244
+ }
245
+ function S(e) {
246
+ return typeof e == "object" && e !== null && e.$$typeof === j;
247
+ }
248
+ var v = ee, j = Symbol.for("react.transitional.element"), U = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), W = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), z = Symbol.for("react.consumer"), J = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), X = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), x = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, Q = Array.isArray, h = console.createTask ? console.createTask : function() {
249
+ return null;
250
+ };
251
+ v = {
252
+ react_stack_bottom_frame: function(e) {
253
+ return e();
254
+ }
255
+ };
256
+ var N, g = {}, Y = v.react_stack_bottom_frame.bind(
257
+ v,
258
+ l
259
+ )(), $ = h(m(l)), I = {};
260
+ p.Fragment = A, p.jsx = function(e, r, t) {
261
+ var n = 1e4 > x.recentlyCreatedOwnerStacks++;
262
+ return w(
263
+ e,
264
+ r,
265
+ t,
266
+ !1,
267
+ n ? Error("react-stack-top-frame") : Y,
268
+ n ? h(m(e)) : $
269
+ );
270
+ }, p.jsxs = function(e, r, t) {
271
+ var n = 1e4 > x.recentlyCreatedOwnerStacks++;
272
+ return w(
273
+ e,
274
+ r,
275
+ t,
276
+ !0,
277
+ n ? Error("react-stack-top-frame") : Y,
278
+ n ? h(m(e)) : $
279
+ );
280
+ };
281
+ })()), p;
282
+ }
283
+ var L;
284
+ function ue() {
285
+ return L || (L = 1, process.env.NODE_ENV === "production" ? T.exports = oe() : T.exports = se()), T.exports;
286
+ }
287
+ var le = ue();
288
+ function ie({
289
+ baseURL: s,
290
+ getToken: c,
291
+ timeoutMs: f = 15e3,
292
+ axiosInstance: m,
293
+ currency: u,
294
+ lng: l,
295
+ onError: d
296
+ } = {}) {
297
+ const i = m ?? ae.create({
298
+ baseURL: s,
299
+ timeout: f,
300
+ headers: { "Content-Type": "application/json" }
301
+ });
302
+ return i.interceptors.request.use(async (o) => {
303
+ if (c) {
304
+ const R = await c();
305
+ R && (o.headers = o.headers || {}, o.headers.Authorization = `Bearer ${R}`);
306
+ }
307
+ return o;
308
+ }), i.interceptors.request.use((o) => {
309
+ o.headers.Currency = u, o.headers["currency-code"] = u, o.headers.lang = l;
310
+ }), i.interceptors.response.use(
311
+ (o) => o,
312
+ (o) => d ? d(o, { instance: i }) : Promise.reject(o)
313
+ ), i;
314
+ }
315
+ function _e({ children: s, ...c }) {
316
+ const f = ne(() => ie(c), [c]);
317
+ return /* @__PURE__ */ le.jsx(M.Provider, { value: { client: f }, children: s });
318
+ }
319
+ export {
320
+ M as ApiCtx,
321
+ _e as ApiProvider,
322
+ me as useApiContext
323
+ };
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@obb871001/api-integration-sdk",
3
3
  "private": false,
4
- "version": "1.0.9",
4
+ "version": "1.0.12",
5
5
  "description": "集成API",
6
- "main": "src/index.cjs",
7
- "module": "src/index.js",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
8
  "type": "module",
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./src/index.js",
12
- "require": "./src/index.cjs"
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
13
  }
14
14
  },
15
15
  "files": [
16
- "src",
16
+ "dist",
17
17
  "README.md"
18
18
  ],
19
19
  "scripts": {
package/src/App.css DELETED
@@ -1,42 +0,0 @@
1
- #root {
2
- max-width: 1280px;
3
- margin: 0 auto;
4
- padding: 2rem;
5
- text-align: center;
6
- }
7
-
8
- .logo {
9
- height: 6em;
10
- padding: 1.5em;
11
- will-change: filter;
12
- transition: filter 300ms;
13
- }
14
- .logo:hover {
15
- filter: drop-shadow(0 0 2em #646cffaa);
16
- }
17
- .logo.react:hover {
18
- filter: drop-shadow(0 0 2em #61dafbaa);
19
- }
20
-
21
- @keyframes logo-spin {
22
- from {
23
- transform: rotate(0deg);
24
- }
25
- to {
26
- transform: rotate(360deg);
27
- }
28
- }
29
-
30
- @media (prefers-reduced-motion: no-preference) {
31
- a:nth-of-type(2) .logo {
32
- animation: logo-spin infinite 20s linear;
33
- }
34
- }
35
-
36
- .card {
37
- padding: 2em;
38
- }
39
-
40
- .read-the-docs {
41
- color: #888;
42
- }
package/src/App.jsx DELETED
@@ -1,7 +0,0 @@
1
- import "./App.css";
2
-
3
- function App() {
4
- return <></>;
5
- }
6
-
7
- export default App;
package/src/api/client.js DELETED
@@ -1,59 +0,0 @@
1
- import axios from "axios";
2
-
3
- /**
4
- * 建立 axios instance(可選擇性注入 getToken / 其他攔截器)
5
- * @param {Object} options
6
- * @param {string} options.baseURL
7
- * @param {() => (string|undefined|Promise<string|undefined>)} [options.getToken]
8
- * @param {number} [options.timeoutMs=15000]
9
- * @param {import('axios').AxiosInstance} [options.axiosInstance] - 若有外部共用 instance,可直接注入
10
- * @param {string} [options.currency] - 預設貨幣代碼(可用於自訂攔截器)
11
- * @param {string} [options.lng] - 預設語言代碼(可用於自訂攔截器)
12
- * @param {(error:any, ctx:{instance:any}) => any} [options.onError] - 統一錯誤處理(可回傳 Promise.reject(error))
13
- * @returns {import('axios').AxiosInstance}
14
- */
15
- export function createAxiosClient({
16
- baseURL,
17
- getToken,
18
- timeoutMs = 15000,
19
- axiosInstance,
20
- currency,
21
- lng,
22
- onError,
23
- } = {}) {
24
- const instance =
25
- axiosInstance ??
26
- axios.create({
27
- baseURL: baseURL,
28
- timeout: timeoutMs,
29
- headers: { "Content-Type": "application/json" },
30
- });
31
-
32
- instance.interceptors.request.use(async (config) => {
33
- if (getToken) {
34
- const token = await getToken();
35
- if (token) {
36
- config.headers = config.headers || {};
37
- config.headers.Authorization = `Bearer ${token}`;
38
- }
39
- }
40
- return config;
41
- });
42
-
43
- instance.interceptors.request.use((config) => {
44
- config.headers.Currency = currency;
45
- config.headers[`currency-code`] = currency;
46
- config.headers[`lang`] = lng;
47
- });
48
-
49
- // Response: 統一錯誤處理(交由外部決定)
50
- instance.interceptors.response.use(
51
- (res) => res,
52
- (err) => {
53
- if (onError) return onError(err, { instance });
54
- return Promise.reject(err);
55
- }
56
- );
57
-
58
- return instance;
59
- }
@@ -1,19 +0,0 @@
1
- import { useQueries } from "@tanstack/react-query";
2
- import React from "react";
3
- import useUserApi from "../services/useUserApi.jsx";
4
-
5
- const usePeriodicDataUpdater = () => {
6
- const { userInfoApi } = useUserApi();
7
- const { data, isFetching } = useQueries({
8
- queries: [
9
- {
10
- queryKey: ["getMemberInfo"],
11
- queryFn: userInfoApi,
12
- refetchInterval: 50000,
13
- },
14
- ],
15
- });
16
- return { data, isFetching };
17
- };
18
-
19
- export default usePeriodicDataUpdater;
@@ -1,10 +0,0 @@
1
- import React, { createContext, useContext } from "react";
2
-
3
- const ApiCtx = createContext(null);
4
-
5
- export const useAxios = () => {
6
- const ctx = useContext(ApiCtx);
7
-
8
- if (!ctx) throw new Error("useAxios must be used inside <ApiProvider>");
9
- return ctx.client;
10
- };
package/src/index.css DELETED
@@ -1,68 +0,0 @@
1
- :root {
2
- font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
4
- font-weight: 400;
5
-
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
9
-
10
- font-synthesis: none;
11
- text-rendering: optimizeLegibility;
12
- -webkit-font-smoothing: antialiased;
13
- -moz-osx-font-smoothing: grayscale;
14
- }
15
-
16
- a {
17
- font-weight: 500;
18
- color: #646cff;
19
- text-decoration: inherit;
20
- }
21
- a:hover {
22
- color: #535bf2;
23
- }
24
-
25
- body {
26
- margin: 0;
27
- display: flex;
28
- place-items: center;
29
- min-width: 320px;
30
- min-height: 100vh;
31
- }
32
-
33
- h1 {
34
- font-size: 3.2em;
35
- line-height: 1.1;
36
- }
37
-
38
- button {
39
- border-radius: 8px;
40
- border: 1px solid transparent;
41
- padding: 0.6em 1.2em;
42
- font-size: 1em;
43
- font-weight: 500;
44
- font-family: inherit;
45
- background-color: #1a1a1a;
46
- cursor: pointer;
47
- transition: border-color 0.25s;
48
- }
49
- button:hover {
50
- border-color: #646cff;
51
- }
52
- button:focus,
53
- button:focus-visible {
54
- outline: 4px auto -webkit-focus-ring-color;
55
- }
56
-
57
- @media (prefers-color-scheme: light) {
58
- :root {
59
- color: #213547;
60
- background-color: #ffffff;
61
- }
62
- a:hover {
63
- color: #747bff;
64
- }
65
- button {
66
- background-color: #f9f9f9;
67
- }
68
- }
package/src/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from "./function/usePeriodicDataUpdater.js";
2
- export * from "./services/index.js";
3
- export * from "./hooks/useAxios.js";
4
- export * from "./provider.jsx";
package/src/main.jsx DELETED
@@ -1,10 +0,0 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import './index.css'
4
- import App from './App.jsx'
5
-
6
- createRoot(document.getElementById('root')).render(
7
- <StrictMode>
8
- <App />
9
- </StrictMode>,
10
- )
package/src/provider.jsx DELETED
@@ -1,15 +0,0 @@
1
- import { useMemo } from "react";
2
- import { createAxiosClient } from "./api/client";
3
-
4
- /**
5
- * ApiProvider props:
6
- * - baseURL: string
7
- * - getToken?: () => string | undefined | Promise<string | undefined>
8
- * - timeoutMs?: number
9
- * - axiosInstance?: AxiosInstance // 注入你自己的 axios(可共用攔截器)
10
- * - onError?: (error, ctx) => any // 全域錯誤處理
11
- */
12
- export default function ApiProvider({ children, ...opts }) {
13
- const client = useMemo(() => createAxiosClient(opts), [opts]);
14
- return <ApiCtx.Provider value={{ client }}>{children}</ApiCtx.Provider>;
15
- }
@@ -1,2 +0,0 @@
1
- export * from "./useCommonApi.jsx";
2
- export * from "./useUserApi.jsx";
@@ -1,28 +0,0 @@
1
- import React, { useCallback } from "react";
2
- import { useAxios } from "../hooks/useAxios";
3
-
4
- const useCommonApi = () => {
5
- const axios = useAxios();
6
-
7
- /**
8
- * @description 取得輪播圖資訊
9
- * @return {Promise<Object>} 輪播圖資訊
10
- */
11
- const carouselApi = useCallback(async () => {
12
- const { data } = await axios.get("/carousels");
13
- return data;
14
- }, [axios]);
15
-
16
- /**
17
- * @description 取得跑馬燈資訊
18
- * @return {Promise<Object>} 跑馬燈資訊
19
- */
20
- const marqueeApi = useCallback(async () => {
21
- const { data } = await axios.get("/marquees");
22
- return data;
23
- }, [axios]);
24
-
25
- return { carouselApi, marqueeApi };
26
- };
27
-
28
- export default useCommonApi;
@@ -1,78 +0,0 @@
1
- import React, { useCallback } from "react";
2
- import { useAxios } from "../hooks/useAxios";
3
-
4
- /**
5
- * @description 使用者相關 API
6
- * @returns {Object} API 方法集合
7
- * @property {Function} machineLoginApi 機台登入 API
8
- * @property {Function} userInfoApi 取得使用者資訊 API
9
- */
10
- const useUserApi = () => {
11
- const axios = useAxios();
12
-
13
- /**
14
- * @description 機台登入
15
- * @param {Object} params
16
- * @param {string} params.mac_address 機台 MAC 地址
17
- * @param {string} params.app_version 應用程式版本
18
- * @param {string} params.anydesk_id 遠端協助軟體 ID
19
- */
20
- const machineLoginApi = useCallback(
21
- async (params) => {
22
- const { mac_address = "", app_version = "", anydesk_id = "" } = params;
23
- const { data } = await axios.post("/cash-register/login", {
24
- mac_address,
25
- app_version,
26
- anydesk_id,
27
- });
28
- return data;
29
- },
30
- [axios]
31
- );
32
-
33
- /**
34
- * @description 取得使用者資訊
35
- * @return {Promise<Object>} 使用者資訊
36
- */
37
- const userInfoApi = useCallback(async () => {
38
- const { data } = await axios.get("/getMemberInfo");
39
- return data;
40
- }, [axios]);
41
-
42
- /**
43
- * @description 取得使用者遊戲列表
44
- * @return {Promise<Object>} 使用者遊戲列表
45
- */
46
- const userGameListApi = useCallback(async () => {
47
- const { data } = await axios.get("/getGameList");
48
- return data;
49
- }, [axios]);
50
-
51
- /**
52
- * @description 取得即時匯率資訊
53
- * @return {Promise<Object>} 即時匯率資訊
54
- */
55
- const userCurrencyExchangeApi = useCallback(async () => {
56
- const { data } = await axios.get("/getNowCurrencyExchange");
57
- return data;
58
- }, [axios]);
59
-
60
- /**
61
- * @description 取得使用者最愛遊戲列表
62
- * @return {Promise<Object>} 使用者最愛遊戲列表
63
- */
64
- const userFavoriteGameApi = useCallback(async () => {
65
- const { data } = await axios.get("/getFavoriteGame");
66
- return data;
67
- }, [axios]);
68
-
69
- return {
70
- machineLoginApi,
71
- userInfoApi,
72
- userGameListApi,
73
- userFavoriteGameApi,
74
- userCurrencyExchangeApi,
75
- };
76
- };
77
-
78
- export default useUserApi;