@radhya/mach 2.6.7 → 2.6.8
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.js +6 -2
- package/expo-plugin/index.js +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2302,6 +2302,10 @@ const path = require('path')
|
|
|
2302
2302
|
const unique = values => Array.from(new Set(values.filter(Boolean)))
|
|
2303
2303
|
const nonEmpty = value => typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined
|
|
2304
2304
|
const first = (...values) => values.map(nonEmpty).find(Boolean)
|
|
2305
|
+
const mergeScheme = (current, machScheme) => {
|
|
2306
|
+
const values = unique([machScheme, ...(Array.isArray(current) ? current : [current])])
|
|
2307
|
+
return values.length === 1 ? values[0] : values
|
|
2308
|
+
}
|
|
2305
2309
|
|
|
2306
2310
|
const sanitizeScheme = value => {
|
|
2307
2311
|
const normalized = nonEmpty(value)
|
|
@@ -2391,7 +2395,7 @@ module.exports = function withMachDeepLinks(config, options) {
|
|
|
2391
2395
|
const deepLinks = resolveDeepLinks(config, options)
|
|
2392
2396
|
if (!deepLinks.baseUrl || !deepLinks.domain) return config
|
|
2393
2397
|
|
|
2394
|
-
config.scheme = deepLinks.scheme
|
|
2398
|
+
config.scheme = mergeScheme(config.scheme, deepLinks.scheme)
|
|
2395
2399
|
config.extra = { ...(config.extra || {}), deepLinkBaseUrl: deepLinks.baseUrl }
|
|
2396
2400
|
|
|
2397
2401
|
config.ios = config.ios || {}
|
|
@@ -2419,7 +2423,7 @@ module.exports = function withMachDeepLinks(config, options) {
|
|
|
2419
2423
|
config.android.intentFilters = intentFilters
|
|
2420
2424
|
return config
|
|
2421
2425
|
}
|
|
2422
|
-
`,si=e=>{if(typeof e=="string"){if(e===Xt)return Xt;if(e===wn||e===wn.replace(/^\.\//,""))return wn}},lh=["app.config.ts","app.config.js","app.config.json","app.json"],Zc=["app.config.ts","app.config.js"],Qc=["app.config.json","app.json"],ir=(e,t=lh)=>t.find(n=>ge.existsSync(Z.join(e,n)));function li(e){let t=Z.resolve(e);for(;;){if(ir(t))return t;let n=Z.dirname(t);if(n===t)return Z.resolve(e);t=n}}var ch=[2,6,
|
|
2426
|
+
`,si=e=>{if(typeof e=="string"){if(e===Xt)return Xt;if(e===wn||e===wn.replace(/^\.\//,""))return wn}},lh=["app.config.ts","app.config.js","app.config.json","app.json"],Zc=["app.config.ts","app.config.js"],Qc=["app.config.json","app.json"],ir=(e,t=lh)=>t.find(n=>ge.existsSync(Z.join(e,n)));function li(e){let t=Z.resolve(e);for(;;){if(ir(t))return t;let n=Z.dirname(t);if(n===t)return Z.resolve(e);t=n}}var ch=[2,6,8],dh=e=>{let t=e.split(Z.sep).join("/");return t.startsWith(".")?t:`./${t}`},ed=(e,t)=>{if(Z.resolve(e)!==Z.resolve(t))return{machConfigPath:dh(Z.relative(t,Z.join(e,"mach.config.json")))}},uh=e=>{let t=Z.join(e,"node_modules/@radhya/mach/package.json");if(ge.existsSync(t))try{let n=JSON.parse(ge.readFileSync(t,"utf-8")).version;return typeof n=="string"?n:void 0}catch{return}},ph=(e,t)=>{let n=e?.match(/^(\d+)\.(\d+)\.(\d+)/)?.slice(1).map(Number);return!n||n.length!==3?!1:n.some((r,i)=>r!==t[i]&&r>t[i])||n.every((r,i)=>r===t[i])},Jo=(e,t)=>Ah(e)?t?.machConfigPath?ph(uh(e),ch):!0:!1;function td(e){let t=li(e);return!Jo(t,ed(e,t))}var fh=e=>{if(!Array.isArray(e)||!e[1]||typeof e[1]!="object")return;let t=typeof e[1].machConfigPath=="string"?e[1].machConfigPath:void 0;return t?{machConfigPath:t}:void 0},Xo=e=>Array.isArray(e)?Xo(e[0]):si(e),nd=e=>!!Xo(e),mh=(e,t)=>{let n=si(t)||t;return Xo(e)===n},gh=(e,t)=>fh(e)?.machConfigPath===t?.machConfigPath,rd=(e,t)=>t?[e,t]:e,qc=(e,t,n)=>!n&&Array.isArray(e)?[t,...e.slice(1)]:rd(t,n),hh=(e,t,n)=>{let r=Array.isArray(e.plugins)?e.plugins:[],i=r.findIndex(s=>mh(s,t));if(i>=0)return gh(r[i],n)?(e.plugins=r,"already"):(r[i]=qc(r[i],t,n),e.plugins=r,"updated");let o=r.findIndex(nd);return o>=0?(r[o]=qc(r[o],t,n),e.plugins=r,"updated"):(r.push(rd(t,n)),e.plugins=r,"inserted")},id=String.raw`(?:\.\/)?plugins\/withMachDeepLinks|@radhya\/mach\/expo-plugin`,Zo='[\\x27\\"`]',ai=new RegExp(`(${Zo})(${id})\\1`,"g"),yh=new RegExp(`\\[\\s*(${Zo})(${id})\\1\\s*,\\s*\\{[^{}]*\\}\\s*\\]`,"g"),od=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),Jc=(e,t)=>t?.machConfigPath?`['${e}', { machConfigPath: '${od(t.machConfigPath)}' }]`:`'${e}'`,bh=(e,t,n)=>{let r=si(t)||t;if(!Array.from(e.matchAll(ai)).some(a=>si(a[2])===r))return!1;if(!n?.machConfigPath)return!0;let o=od(n.machConfigPath).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`\\[\\s*(${Zo})${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\1\\s*,\\s*\\{[^{}]*machConfigPath\\s*:\\s*[\\x27\\"]${o}[\\x27\\"][^{}]*\\}\\s*\\]`).test(e)},sd=e=>{let t=Z.join(e,"plugins");if(!ge.existsSync(t))return!1;try{return ge.readdirSync(t).filter(n=>/\.(?:c?js|ts)$/.test(n)).some(n=>{let r=ge.readFileSync(Z.join(t,n),"utf-8");return r.includes(Xt)||r.includes("withMachDeepLinks")})}catch{return!1}};function Ah(e){let t=Z.join(e,"package.json");if(!ge.existsSync(t))return!1;try{let n=JSON.parse(ge.readFileSync(t,"utf-8"));return!!(n.dependencies?.["@radhya/mach"]||n.devDependencies?.["@radhya/mach"])}catch{return!1}}function Sh(e){return ge.existsSync(Z.join(e,"pnpm-lock.yaml"))?{command:"pnpm",args:["add","-D","@radhya/mach@latest"],label:"pnpm add -D @radhya/mach@latest"}:ge.existsSync(Z.join(e,"yarn.lock"))?{command:"yarn",args:["add","-D","@radhya/mach@latest"],label:"yarn add -D @radhya/mach@latest"}:ge.existsSync(Z.join(e,"bun.lockb"))||ge.existsSync(Z.join(e,"bun.lock"))?{command:"bun",args:["add","-d","@radhya/mach@latest"],label:"bun add -d @radhya/mach@latest"}:{command:"npm",args:["install","--save-dev","@radhya/mach@latest"],label:"npm install --save-dev @radhya/mach@latest"}}function Eh(e){let t=Sh(e),n=Xc(t.command,t.args,{cwd:e,stdio:"inherit",env:{...process.env}});return n.error?{ok:!1,label:t.label,error:n.error.message}:n.status!==0?{ok:!1,label:t.label,error:`${t.command} exited with code ${n.status}`}:{ok:!0,label:t.label}}function Ih(e,t,n){let r=ge.readFileSync(e,"utf-8");if(Array.from(r.matchAll(ai)).length>0){if(bh(r,t,n))return"already";let h=Jc(t,n),g=r.replace(yh,h);return g===r&&(g=r.replace(ai,h)),g===r?"unsupported":(ge.writeFileSync(e,g),"updated")}let o=/(^[ \t]*)plugins\s*:\s*\[([\s\S]*?)\]/m.exec(r);if(!o||o.index===void 0)return"unsupported";let s=r.includes(`\r
|
|
2423
2427
|
`)?`\r
|
|
2424
2428
|
`:`
|
|
2425
2429
|
`,a=o[1]||"",l=o[2]||"",c=l.match(/\r?\n([ \t]+)\S/)?.[1]||`${a} `,u=Jc(t,n),f=l.trim().length===0?`${s}${c}${u},${s}${a}`:l.includes(`
|
package/expo-plugin/index.js
CHANGED
|
@@ -4,6 +4,10 @@ const path = require('path')
|
|
|
4
4
|
const unique = values => Array.from(new Set(values.filter(Boolean)))
|
|
5
5
|
const nonEmpty = value => typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined
|
|
6
6
|
const first = (...values) => values.map(nonEmpty).find(Boolean)
|
|
7
|
+
const mergeScheme = (current, machScheme) => {
|
|
8
|
+
const values = unique([machScheme, ...(Array.isArray(current) ? current : [current])])
|
|
9
|
+
return values.length === 1 ? values[0] : values
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
const withoutRuntimeVersion = platformConfig => {
|
|
9
13
|
if (!platformConfig || typeof platformConfig !== 'object' || !Object.prototype.hasOwnProperty.call(platformConfig, 'runtimeVersion')) {
|
|
@@ -216,7 +220,7 @@ module.exports = function withMachDeepLinks(config, options) {
|
|
|
216
220
|
|
|
217
221
|
if (!deepLinks.baseUrl || !deepLinks.domain) return config
|
|
218
222
|
|
|
219
|
-
config.scheme = deepLinks.scheme
|
|
223
|
+
config.scheme = mergeScheme(config.scheme, deepLinks.scheme)
|
|
220
224
|
config.extra.deepLinkBaseUrl = deepLinks.baseUrl
|
|
221
225
|
|
|
222
226
|
config.ios = config.ios || {}
|