Stripe integration flow
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const IS_NODE =
|
||||
export const IS_NODE =
|
||||
typeof process !== "undefined" &&
|
||||
process.versions?.node != null
|
||||
|
||||
@@ -9,9 +9,7 @@ async function bridgeSend(name, args) {
|
||||
args: args
|
||||
})
|
||||
|
||||
const json = await res.json()
|
||||
if (!res.ok) throw new Error(json.error)
|
||||
return json.result
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,8 +22,6 @@ export function createBridge(funcs) {
|
||||
get(target, prop) {
|
||||
const orig = target[prop]
|
||||
|
||||
if (typeof orig !== "function") return orig
|
||||
|
||||
return function (...args) {
|
||||
if (IS_NODE) {
|
||||
return orig(...args)
|
||||
|
||||
14
ui/_/code/bridge/handlers.js
Normal file
14
ui/_/code/bridge/handlers.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import fs from "fs"
|
||||
|
||||
const handlers = {
|
||||
getProfile(one, two) {
|
||||
fs.writeFileSync("output.txt", `${one} ${two}`)
|
||||
return "written to disk"
|
||||
},
|
||||
|
||||
async getStripeProfile(networkId) {
|
||||
return global.payments.getProfile(networkId)
|
||||
}
|
||||
}
|
||||
|
||||
export default handlers
|
||||
@@ -1,11 +1,10 @@
|
||||
import fs from "fs"
|
||||
import { createBridge } from "./bridge.js"
|
||||
import { createBridge, IS_NODE } from "./bridge.js"
|
||||
|
||||
const handlers = {
|
||||
getProfile(one, two) {
|
||||
fs.writeFileSync("output.txt", `${one} ${two}`)
|
||||
return "written to disk"
|
||||
},
|
||||
let handlers = {}
|
||||
|
||||
if (IS_NODE) {
|
||||
const mod = await import("./handlers.js")
|
||||
handlers = mod.default
|
||||
}
|
||||
|
||||
export const { getProfile } = createBridge(handlers)
|
||||
export default createBridge(handlers)
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Sam Russell
|
||||
Captured Sun
|
||||
3.4.26 - Making horizontalAlign() and verticalAlign() methods of checking for stacks more robust
|
||||
2.27.26 - Adding parentShadow() function
|
||||
2.16.26 - Adding event objects to the onTouch callbacks
|
||||
1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr()
|
||||
@@ -673,11 +674,11 @@ HTMLElement.prototype.centerY = function () {
|
||||
};
|
||||
|
||||
HTMLElement.prototype.verticalAlign = function (value) {
|
||||
// if(!this.classList.contains("HStack") && !this.classList.contains("VStack")) {
|
||||
// throw new Error("verticalAlign can be only be used on HStacks or VStacks!")
|
||||
// }
|
||||
|
||||
const direction = getComputedStyle(this).flexDirection;
|
||||
if(!direction) {
|
||||
throw new Error("verticalAlign can be only be used on HStacks or VStacks!")
|
||||
}
|
||||
|
||||
if (direction === "column" || direction === "column-reverse") {
|
||||
this.style.justifyContent = value;
|
||||
} else {
|
||||
@@ -687,11 +688,11 @@ HTMLElement.prototype.verticalAlign = function (value) {
|
||||
}
|
||||
|
||||
HTMLElement.prototype.horizontalAlign = function (value) {
|
||||
const direction = getComputedStyle(this).flexDirection;
|
||||
if(!direction) {
|
||||
if(!this.classList.contains("HStack") && !this.classList.contains("VStack")) {
|
||||
throw new Error("horizontalAlign can be only be used on HStacks or VStacks!")
|
||||
}
|
||||
|
||||
|
||||
const direction = getComputedStyle(this).flexDirection;
|
||||
if (direction === "column" || direction === "column-reverse") {
|
||||
this.style.alignItems = value;
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,7 @@ class Connection {
|
||||
|
||||
constructor(receiveCB) {
|
||||
this.receiveCB = receiveCB;
|
||||
this.init()
|
||||
}
|
||||
|
||||
init = async () => {
|
||||
|
||||
Reference in New Issue
Block a user