fix: 接入抖音原生支付并修复App支付服务缺失
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# Preserve vendor SDK bytes, including signed framework resources, across platforms.
|
||||
uni_modules/tb-douyin-pay/utssdk/app-ios/Frameworks/** -text
|
||||
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { resumeDouyinPay } from '@/utils/douyin-pay.js';
|
||||
import {
|
||||
resumeKefuRealtime,
|
||||
suspendKefuRealtime,
|
||||
@@ -29,6 +30,7 @@ export default {
|
||||
console.log("App Show");
|
||||
uni.$emit("kefu-app-show");
|
||||
resumeKefuRealtime();
|
||||
resumeDouyinPay();
|
||||
// 隐藏原生tabbar
|
||||
/*#ifdef APP-PLUS*/
|
||||
uni.hideTabBar({
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# 抖音 App 支付接入与打包
|
||||
|
||||
2026-09-09,基于 develop / b350f1c 修复。
|
||||
|
||||
## 本次故障
|
||||
|
||||
普通 uni-app App 中调用 uni.requestPayment({ provider: "toutiao" }) 无法找到该通道,
|
||||
会报 requestPayment:fail service not found。配置 Scheme 白名单不会注册支付 SDK。
|
||||
后端 prepayId 不能由前端直接当成 pay_token 拼接收银台 URL。
|
||||
|
||||
## 统一调用
|
||||
|
||||
订单页、订单补付、充值使用 utils/douyin-pay.js 的 appDypayFun(payment),传入
|
||||
/order/payment 等接口的 data 对象(含 orderNum、douyin),不要传整个 HTTP response。
|
||||
utils/payUtils.js 保留 douyinPayFun(douyin, orderId, orderNum) 兼容入口,
|
||||
也委托给同一原生调用与查单逻辑。
|
||||
|
||||
适配器支持 douyin 的旧扁平字段以及新 orderInfo 对象/JSON,
|
||||
最终传给 SDK 的字段为 appid、partnerid、prepayid、package、noncestr、timestamp、sign。
|
||||
签名仍由服务端产生,前端不自行签名或改写签名字段。
|
||||
|
||||
uni_modules/tb-douyin-pay 是本地源码 UTS 插件,不是 uni.requestPayment provider;
|
||||
无需将它添加成 manifest 的 toutiao 支付通道。
|
||||
Android 原生依赖由 utssdk/app-android/config.json 声明;
|
||||
iOS SDK 位于 utssdk/app-ios/Frameworks/DypaySDK.xcframework。
|
||||
需要将整个插件目录纳入版本控制,不能只提交 utils 和页面。
|
||||
|
||||
## 打包与验收
|
||||
|
||||
1. 在支持插件配置的 HBuilderX(插件声明最低 4.36)打开 frontend-app。
|
||||
2. 安装对应 UTS 编译与 App 打包扩展,Android 打包需能解析插件 Maven 依赖。
|
||||
3. 制作包含本插件的自定义调试基座或完整 Android/iOS 安装包,使用平台登记的包名和签名。
|
||||
4. 安装新的原生包。单独更新 WGT 或服务器部署无法给旧安装包加入 SDK。
|
||||
5. 从真实订单调用支付;测试页也可粘贴 /order/payment 成功返回 JSON。
|
||||
6. 覆盖成功、取消、网络失败、重复点击、回前台、冷启动恢复场景。
|
||||
|
||||
仅服务端 /payment/queryResult 返回 state=2 才提示支付成功。
|
||||
SDK 成功或跳回 App 本身不作为到账依据。结果未知时保留待查订单并阻止重复发起。
|
||||
测试页不再提供模拟 pay_token 链接,不在页面日志输出完整签名。
|
||||
H5/小程序不会调用原生 App SDK。
|
||||
|
||||
## 验证边界
|
||||
|
||||
2026-09-09 实测:14 项自动化测试通过,6 个 Vue 文件的 SFC/脚本/模板检查通过。
|
||||
HBuilderX 5.24 执行 App appResource 导出成功,产物位于 unpackage/resources,
|
||||
包含 tb-douyin-pay 的 Android 原生源码/配置和 iOS SDK 源码/框架。
|
||||
编译有既有 CSS Autoprefixer 注释警告,不影响此次资源导出。
|
||||
这次没有构建、安装完整 APK/IPA,也没有进行真机交易。
|
||||
|
||||
npm run test:douyin 覆盖参数适配、旧调用入口、服务端确认、重复支付及异常恢复。
|
||||
这些自动化测试使用模拟 SDK/接口,不会产生真实交易,不能替代完整原生包与真机验收。
|
||||
+4
-1
@@ -3,7 +3,10 @@
|
||||
"name": "tb",
|
||||
"displayName": "tb",
|
||||
"version": "1.0.2",
|
||||
"description": "信任桥",
|
||||
"description": "信任桥",
|
||||
"scripts": {
|
||||
"test:douyin": "node --test tests/douyin-integration.test.cjs"
|
||||
},
|
||||
"keywords": [
|
||||
"tb",
|
||||
"信任桥"
|
||||
|
||||
@@ -268,6 +268,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, douyinPayTypes, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import { ORDER_TYPE, ORDER_STATUS, getValue, LOGISTICS_STATUS_UPDATE } from "@/utils/enumUtils.js";
|
||||
import QrcodePreview from "@/components/qrcode-preview.vue";
|
||||
import {
|
||||
@@ -285,7 +286,6 @@ import {
|
||||
import {
|
||||
appWxpayFun,
|
||||
zfbPayFun,
|
||||
douyinPayFun,
|
||||
jumpWayOk,
|
||||
jumpWayError,
|
||||
} from "@/utils/payUtils.js";
|
||||
@@ -357,7 +357,7 @@ export default {
|
||||
async getWayOption() {
|
||||
console.log("orderInfo", this.orderInfo);
|
||||
let params = {
|
||||
types: "1,2,3",
|
||||
types: douyinPayTypes("1,2,3"),
|
||||
};
|
||||
// #ifdef APP-PLUS
|
||||
params.types = "1,2,3,6"
|
||||
@@ -365,10 +365,10 @@ export default {
|
||||
|
||||
const result = await getSupportPay(params);
|
||||
if (result && result.bizcode === 100) {
|
||||
const data = result.data || [];
|
||||
const data = filterDouyinPayWays(result.data);
|
||||
const amount = this.orderInfo.sumAmount;
|
||||
let flag = data.some((item) =>
|
||||
["wechat", "alipay"].includes(item.type)
|
||||
["wechat", "alipay", "douyin"].includes(item.type)
|
||||
);
|
||||
// 没有支付宝和微信支付
|
||||
if (flag) {
|
||||
@@ -410,6 +410,9 @@ export default {
|
||||
},
|
||||
// 去支付
|
||||
async goPay() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
const payway = this.wayForm.payway;
|
||||
if (!payway || payway === 0) {
|
||||
this.$refs.uToastRef.show({
|
||||
@@ -422,6 +425,7 @@ export default {
|
||||
id: this.orderInfo.id,
|
||||
payway,
|
||||
};
|
||||
if (!await prepareDouyinPay(payway)) return;
|
||||
const resp = await payment(params);
|
||||
// 提交订单成功,就唤起支付
|
||||
if (resp && resp.bizcode === 100) {
|
||||
@@ -430,7 +434,9 @@ export default {
|
||||
jumpWayOk();
|
||||
return;
|
||||
}
|
||||
if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
if (item.douyin) {
|
||||
await appDypayFun(item);
|
||||
} else if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum);
|
||||
} else if (
|
||||
item.alipay &&
|
||||
@@ -438,9 +444,6 @@ export default {
|
||||
item.alipay
|
||||
) {
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum);
|
||||
} else if (item.douyin && Object.keys(item.douyin).length !== 0) {
|
||||
// 抖音支付
|
||||
this.appDouying(item.douyin, item.orderId, item.orderNum);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
@@ -453,19 +456,10 @@ export default {
|
||||
} else {
|
||||
this.getOrderInfo();
|
||||
}
|
||||
},
|
||||
// app 抖音支付
|
||||
async appDouying(douyin, orderId, orderNum) {
|
||||
try {
|
||||
const result = await douyinPayFun(douyin, orderId, orderNum);
|
||||
console.log("抖音支付发起成功", result);
|
||||
// 处理支付发起成功后的逻辑
|
||||
} catch (error) {
|
||||
console.error("抖音支付失败", error);
|
||||
// 处理支付失败后的逻辑
|
||||
}
|
||||
uni.showToast({ title: error.message || error.msg || '支付请求失败,请查看订单后重试', icon: 'none' });
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum) {
|
||||
try {
|
||||
@@ -888,4 +882,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import Header from '@/components/header.vue';
|
||||
import {
|
||||
getRechargeSupportPay,
|
||||
@@ -103,11 +104,14 @@
|
||||
async getWayOption() {
|
||||
const result = await getRechargeSupportPay();
|
||||
if (result && result.bizcode === 100) {
|
||||
this.wayOption = result.data;
|
||||
this.wayOption = filterDouyinPayWays(result.data);
|
||||
}
|
||||
},
|
||||
// 立即充值
|
||||
async rechargeOk() {
|
||||
async rechargeOk() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
console.log('aaaaa', this.form);
|
||||
const params = this.form;
|
||||
if (!params.amount) {
|
||||
@@ -145,12 +149,15 @@
|
||||
|
||||
console.log("params---", params);
|
||||
|
||||
const result = await recharge(params);
|
||||
if (!await prepareDouyinPay(params.payway)) return;
|
||||
const result = await recharge(params);
|
||||
console.log("result", result);
|
||||
if (result && result.bizcode === 100) {
|
||||
const item = result.data;
|
||||
console.log("item", item);
|
||||
if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
if (item.douyin) {
|
||||
await appDypayFun(item);
|
||||
} else if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum);
|
||||
} else if (item.alipay && Object.keys(item.alipay).length !== 0 && item.alipay) {
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum);
|
||||
@@ -162,8 +169,11 @@
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
// app 微信支付
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error.message || error.msg || '充值请求失败,请查看订单后重试', icon: 'none' });
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum) {
|
||||
try {
|
||||
const result = await appWxpayFun(alipay, orderId, orderNum);
|
||||
@@ -263,4 +273,4 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
@@ -218,10 +218,13 @@
|
||||
<image v-if="item.type == 'alipay'" src="https://static.tbmall.xin/static/new/zfb.png"></image>
|
||||
<image v-if="item.type == 'balance'" src="https://static.tbmall.xin/static/new/bank.png"></image>
|
||||
<image v-if="item.type == 'redpacket'" src="https://static.tbmall.xin/static/new/jf.png"></image>
|
||||
<image v-if="item.type == 'douyin'" src="https://static.tbmall.xin/static/new/jf.png"></image>
|
||||
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}</text>
|
||||
<text v-if="item.type == 'douyin'" aria-hidden="true" style="display: inline-flex; align-items: center; justify-content: center; width: 48rpx; height: 48rpx; border-radius: 50%; background: #161823; color: #fff; font-size: 32rpx; flex-shrink: 0;">♪</text>
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay' || item.type == 'douyin'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}
|
||||
<!-- #ifdef H5 -->
|
||||
<text v-if="item.type == 'douyin'" style="font-size: 24rpx; color: #777; margin-left: 12rpx;">仅 App 支持</text>
|
||||
<!-- #endif -->
|
||||
</text>
|
||||
<text v-else style="margin-left: 20rpx" class="text-32 text-zu">{{ item.name }}
|
||||
<text style="color: #999; margin: 0 10rpx">可用:</text>
|
||||
{{ item.balance }}
|
||||
@@ -317,6 +320,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, douyinPayTypes, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import Address from "@/components/address.vue";
|
||||
import { getGoodsDetail } from "@/api/product.js";
|
||||
import { getAddress } from "@/api/address.js";
|
||||
@@ -340,7 +344,6 @@ import { getUserInfo } from "@/api/auth.js";
|
||||
import {
|
||||
appWxpayFun,
|
||||
zfbPayFun,
|
||||
douyinPayFun,
|
||||
jumpWayOk,
|
||||
jumpWayError,
|
||||
} from "@/utils/payUtils.js";
|
||||
@@ -609,9 +612,10 @@ export default {
|
||||
|
||||
|
||||
|
||||
parmas.types = douyinPayTypes(parmas.types);
|
||||
const result = await getSupportPay(parmas);
|
||||
if (result && result.bizcode === 100) {
|
||||
const data = result.data || [];
|
||||
const data = filterDouyinPayWays(result.data);
|
||||
// const amount = this.orderInfo.amount;
|
||||
// let flag = data.some((item) =>
|
||||
// ["wechat", "alipay"].includes(item.type)
|
||||
@@ -978,6 +982,10 @@ export default {
|
||||
}
|
||||
},
|
||||
async passPay() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
if (!await prepareDouyinPay(this.orderInfo.paymentMethod)) return;
|
||||
let params = {
|
||||
addrId: this.orderInfo.address.id, // 收货地址ID
|
||||
//结算的购物车ID,多个以逗号分割,ALL表示全选
|
||||
@@ -1069,7 +1077,9 @@ export default {
|
||||
jumpWayOk();
|
||||
return;
|
||||
}
|
||||
if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
if (item.douyin) {
|
||||
await appDypayFun(item);
|
||||
} else if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum);
|
||||
} else if (
|
||||
item.alipay &&
|
||||
@@ -1077,10 +1087,6 @@ export default {
|
||||
item.alipay
|
||||
) {
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum);
|
||||
} else if (item.douyin &&
|
||||
Object.keys(item.douyin).length !== 0 &&
|
||||
item.douyin) {
|
||||
this.appDouying(item.douyin, item.orderId, item.orderNum);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
@@ -1093,20 +1099,10 @@ export default {
|
||||
} else {
|
||||
this.getOrder();
|
||||
}
|
||||
},
|
||||
|
||||
// app 抖音支付
|
||||
async appDouying(douyin, orderId, orderNum) {
|
||||
try {
|
||||
const result = await douyinPayFun(douyin, orderId, orderNum);
|
||||
console.log("抖音支付发起成功", result);
|
||||
// 处理支付发起成功后的逻辑
|
||||
} catch (error) {
|
||||
console.error("抖音支付失败", error);
|
||||
// 处理支付失败后的逻辑
|
||||
}
|
||||
uni.showToast({ title: error.message || error.msg || '支付请求失败,请查看订单后重试', icon: 'none' });
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum) {
|
||||
try {
|
||||
|
||||
@@ -215,8 +215,13 @@
|
||||
<image v-if="item.type == 'alipay'" src="https://static.tbmall.xin/static/new/zfb.png"></image>
|
||||
<image v-if="item.type == 'balance'" src="https://static.tbmall.xin/static/new/bank.png"></image>
|
||||
<image v-if="item.type == 'redpacket'" src="https://static.tbmall.xin/static/new/jf.png"></image>
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}</text>
|
||||
<text v-if="item.type == 'douyin'" aria-hidden="true" style="display: inline-flex; align-items: center; justify-content: center; width: 48rpx; height: 48rpx; border-radius: 50%; background: #161823; color: #fff; font-size: 32rpx; flex-shrink: 0;">♪</text>
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay' || item.type == 'douyin'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}
|
||||
<!-- #ifdef H5 -->
|
||||
<text v-if="item.type == 'douyin'" style="font-size: 24rpx; color: #777; margin-left: 12rpx;">仅 App 支持</text>
|
||||
<!-- #endif -->
|
||||
</text>
|
||||
<text v-else style="margin-left: 20rpx" class="text-32 text-zu">{{ item.name }}
|
||||
<text style="color: #999; margin: 0 10rpx">可用:</text>
|
||||
{{ item.balance }}
|
||||
@@ -309,7 +314,8 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, douyinPayTypes, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import Address from "@/components/address.vue";
|
||||
import { getGoodsDetail } from "@/api/product.js";
|
||||
import { getAddress } from "@/api/address.js";
|
||||
@@ -597,9 +603,10 @@ export default {
|
||||
|
||||
|
||||
|
||||
const result = await getSupportPay(parmas);
|
||||
parmas.types = douyinPayTypes(parmas.types);
|
||||
const result = await getSupportPay(parmas);
|
||||
if (result && result.bizcode === 100) {
|
||||
const data = result.data || [];
|
||||
const data = filterDouyinPayWays(result.data);
|
||||
// const amount = this.orderInfo.amount;
|
||||
// let flag = data.some((item) =>
|
||||
// ["wechat", "alipay"].includes(item.type)
|
||||
@@ -943,7 +950,11 @@ export default {
|
||||
this.passPay();
|
||||
}
|
||||
},
|
||||
async passPay() {
|
||||
async passPay() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
if (!await prepareDouyinPay(this.orderInfo.paymentMethod)) return;
|
||||
let params = {
|
||||
addrId: this.orderInfo.address.id, // 收货地址ID
|
||||
//结算的购物车ID,多个以逗号分割,ALL表示全选
|
||||
@@ -1034,7 +1045,9 @@ export default {
|
||||
jumpWayOk();
|
||||
return;
|
||||
}
|
||||
if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
if (item.douyin) {
|
||||
await appDypayFun(item);
|
||||
} else if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum);
|
||||
} else if (
|
||||
item.alipay &&
|
||||
@@ -1054,8 +1067,11 @@ export default {
|
||||
} else {
|
||||
this.getOrder();
|
||||
}
|
||||
},
|
||||
// app 微信支付
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error.message || error.msg || '支付请求失败,请查看订单后重试', icon: 'none' });
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum) {
|
||||
try {
|
||||
const result = await appWxpayFun(alipay, orderId, orderNum);
|
||||
@@ -1509,4 +1525,4 @@ export default {
|
||||
align-items: baseline;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -1,333 +1,61 @@
|
||||
<template>
|
||||
<view class="test_page">
|
||||
<!-- 顶部导航 -->
|
||||
<NavHeader leftTitle="抖音支付测试" leftPathType="navigateTo" />
|
||||
|
||||
<view class="test_container">
|
||||
<!-- 状态与设备信息卡片 -->
|
||||
<view class="card_box">
|
||||
<view class="card_title">
|
||||
<text class="title_text">📱 设备与环境信息</text>
|
||||
<view class="tag_badge" :class="isApp ? 'badge_app' : 'badge_h5'">
|
||||
{{ envText }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="info_grid">
|
||||
<view class="info_row">
|
||||
<text class="info_label">运行平台:</text>
|
||||
<text class="info_val">{{ platformText }}</text>
|
||||
</view>
|
||||
<view class="info_row">
|
||||
<text class="info_label">抖音安装状态:</text>
|
||||
<text class="info_val" :style="{ color: isDyInstalled ? '#00B578' : '#FA5151' }">
|
||||
{{ dyInstallStatusText }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn_row" style="margin-top: 20rpx;">
|
||||
<button class="mini_btn check_btn" @click="checkDouyinInstalled">
|
||||
🔍 检测是否安装抖音
|
||||
</button>
|
||||
<button class="mini_btn open_btn" @click="testDirectOpenDouyin">
|
||||
🚀 直接打开抖音客户端
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 支付测试参数配置 -->
|
||||
<view class="card_box">
|
||||
<view class="card_title">
|
||||
<text class="title_text">⚙️ 支付测试参数</text>
|
||||
</view>
|
||||
|
||||
<!-- 快捷预设模版 -->
|
||||
<view class="preset_section">
|
||||
<text class="section_label">快速填充测试数据:</text>
|
||||
<view class="preset_btn_group">
|
||||
<view class="preset_chip" @click="applyPreset('scheme')">普通App唤起 Scheme</view>
|
||||
<view class="preset_chip" @click="applyPreset('cashier')">模拟收银台 Scheme</view>
|
||||
<view class="preset_chip" @click="applyPreset('h5')">H5收银台链接</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="tip_box">
|
||||
<text class="tip_text">💡 提示:普通的 "snssdk1128://open" 仅能拉起抖音 App 首页。如需弹出【抖音收银台支付窗口】,orderStr 必须包含后端从字节/抖音开放平台获取的真实 pay_token 或收银台参数(如 snssdk1128://pay?pay_token=xxx 或 https://cashier.douyin.com/pay?token=xxx)。</text>
|
||||
</view>
|
||||
|
||||
<view class="form_item">
|
||||
<text class="form_label">支付类型 (type)</text>
|
||||
<radio-group class="radio_group" @change="onTypeChange">
|
||||
<label class="radio_item">
|
||||
<radio value="app" :checked="payType === 'app'" color="#7934F6" style="transform: scale(0.8);" />
|
||||
<text>app</text>
|
||||
</label>
|
||||
<label class="radio_item">
|
||||
<radio value="h5" :checked="payType === 'h5'" color="#7934F6" style="transform: scale(0.8);" />
|
||||
<text>h5</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
|
||||
<view class="form_item">
|
||||
<text class="form_label">支付串 / Scheme / URL (orderStr)</text>
|
||||
<textarea
|
||||
class="form_textarea"
|
||||
v-model="orderStr"
|
||||
placeholder="请输入或粘贴抖音支付链接 / Scheme(如 snssdk1128://... 或 https://...)"
|
||||
></textarea>
|
||||
</view>
|
||||
|
||||
<view class="form_row">
|
||||
<view class="form_item half">
|
||||
<text class="form_label">订单ID (orderId)</text>
|
||||
<input class="form_input" type="number" v-model="orderId" placeholder="例如: 10001" />
|
||||
</view>
|
||||
<view class="form_item half">
|
||||
<text class="form_label">订单编号 (orderNum)</text>
|
||||
<input class="form_input" v-model="orderNum" placeholder="例如: ORD20260905001" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 支付操作区域 -->
|
||||
<view class="action_section">
|
||||
<button class="main_pay_btn" :loading="loading" @click="handleTestPay">
|
||||
⚡ 调用 douyinPayFun 测试支付
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 运行日志与调试面板 -->
|
||||
<view class="card_box">
|
||||
<view class="card_title">
|
||||
<text class="title_text">📋 运行日志与回调</text>
|
||||
<text class="clear_link" @click="clearLogs">清空日志</text>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" class="log_console">
|
||||
<view v-if="logs.length === 0" class="empty_log">暂无测试日志,点击上方按钮开始测试</view>
|
||||
<view v-for="(log, idx) in logs" :key="idx" class="log_item" :class="'log_' + log.level">
|
||||
<text class="log_time">[{{ log.time }}]</text>
|
||||
<text class="log_content">{{ log.msg }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="test_page">
|
||||
<NavHeader leftTitle="抖音支付测试" leftPathType="navigateTo" />
|
||||
<view class="test_container">
|
||||
<view class="card_box">
|
||||
<view class="card_title">抖音 App 原生支付联调</view>
|
||||
<view class="tip_box">
|
||||
<text class="tip_text">粘贴 /order/payment 返回的完整 JSON(含 data.orderNum 和 data.douyin)。使用已集成 tb-douyin-pay 的自定义基座或完整安装包。测试将使用真实订单发起支付;最终结果以服务端查单为准。</text>
|
||||
</view>
|
||||
<view class="form_item">
|
||||
<text class="form_label">接口返回 JSON</text>
|
||||
<textarea class="form_textarea" v-model="paymentJson" placeholder="粘贴接口返回 JSON;也支持直接粘贴含 orderNum、douyin 的 data 对象" />
|
||||
</view>
|
||||
<button class="main_pay_btn" :loading="loading" :disabled="loading" @click="handleTestPay">发起该订单支付</button>
|
||||
</view>
|
||||
<view class="card_box">
|
||||
<view class="card_title">联调结果</view>
|
||||
<text>{{ resultText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NavHeader from "@/components/header.vue";
|
||||
import { douyinPayFun, jumpWayOk, jumpWayError } from "@/utils/payUtils.js";
|
||||
import { appDypayFun } from "@/utils/douyin-pay.js";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
NavHeader,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
payType: "app",
|
||||
orderStr: "snssdk1128://open", // 默认测试 scheme
|
||||
orderId: 99999,
|
||||
orderNum: "TEST_ORDER_" + Date.now(),
|
||||
loading: false,
|
||||
isApp: false,
|
||||
platformText: "未知",
|
||||
envText: "H5 / 网页",
|
||||
dyInstallStatusText: "待检测",
|
||||
isDyInstalled: false,
|
||||
logs: [],
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.initPlatformInfo();
|
||||
this.addLog("页面初始化完成", "info");
|
||||
},
|
||||
methods: {
|
||||
initPlatformInfo() {
|
||||
// #ifdef APP-PLUS
|
||||
this.isApp = true;
|
||||
this.envText = "App 端 (App-Plus)";
|
||||
const platform = uni.getSystemInfoSync().platform;
|
||||
this.platformText = platform === "ios" ? "iOS App" : "Android App";
|
||||
this.checkDouyinInstalled();
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
this.isApp = false;
|
||||
this.envText = "H5 浏览器";
|
||||
this.platformText = "Web / H5";
|
||||
this.dyInstallStatusText = "Web端不支持检测安装";
|
||||
// #endif
|
||||
},
|
||||
addLog(msg, level = "info") {
|
||||
const now = new Date();
|
||||
const timeStr = `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}:${String(now.getSeconds()).padStart(2, "0")}`;
|
||||
const formattedMsg = typeof msg === "object" ? JSON.stringify(msg, null, 2) : String(msg);
|
||||
this.logs.unshift({
|
||||
time: timeStr,
|
||||
msg: formattedMsg,
|
||||
level: level,
|
||||
});
|
||||
},
|
||||
clearLogs() {
|
||||
this.logs = [];
|
||||
},
|
||||
onTypeChange(e) {
|
||||
this.payType = e.detail.value;
|
||||
this.addLog(`切换支付类型为: ${this.payType}`, "info");
|
||||
},
|
||||
applyPreset(presetType) {
|
||||
if (presetType === "scheme") {
|
||||
this.payType = "app";
|
||||
this.orderStr = "snssdk1128://open";
|
||||
this.addLog("已加载基础唤起 Scheme: snssdk1128://open (仅打开App首页)", "info");
|
||||
} else if (presetType === "cashier") {
|
||||
this.payType = "app";
|
||||
this.orderStr = "snssdk1128://pay?pay_token=DEMO_PAY_TOKEN_123456&order_id=TEST_ORDER_001";
|
||||
this.addLog("已加载模拟收银台 Scheme 结构 (真实支付需要后端接口返回的合法 pay_token)", "info");
|
||||
} else if (presetType === "h5") {
|
||||
this.payType = "h5";
|
||||
this.orderStr = "https://cashier.douyin.com/pay?token=DEMO_PAY_TOKEN_123456";
|
||||
this.addLog("已加载 H5 收银台链接预设", "info");
|
||||
}
|
||||
},
|
||||
// 检测抖音是否已安装 (iOS & Android)
|
||||
checkDouyinInstalled() {
|
||||
// #ifdef APP-PLUS
|
||||
const platform = uni.getSystemInfoSync().platform;
|
||||
let installed = false;
|
||||
let foundPkg = "";
|
||||
try {
|
||||
if (platform === "android") {
|
||||
const androidPkgs = [
|
||||
{ name: "抖音", pname: "com.ss.android.ugc.aweme" },
|
||||
{ name: "抖音极速版", pname: "com.ss.android.ugc.aweme.lite" },
|
||||
{ name: "抖音火山版", pname: "com.ss.android.ugc.live" },
|
||||
];
|
||||
for (const pkg of androidPkgs) {
|
||||
if (plus.runtime.isApplicationExist({ pname: pkg.pname })) {
|
||||
installed = true;
|
||||
foundPkg = pkg.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (platform === "ios") {
|
||||
const iosSchemes = [
|
||||
{ name: "抖音", action: "snssdk1128://" },
|
||||
{ name: "抖音(douyin)", action: "douyin://" },
|
||||
{ name: "抖音极速版", action: "snssdk141://" },
|
||||
];
|
||||
for (const sch of iosSchemes) {
|
||||
if (plus.runtime.isApplicationExist({ action: sch.action })) {
|
||||
installed = true;
|
||||
foundPkg = sch.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.isDyInstalled = installed;
|
||||
this.dyInstallStatusText = installed ? `已检测到 (${foundPkg}) ✅` : "未检测到 ❌";
|
||||
this.addLog(`检测抖音客户端安装状态: ${this.dyInstallStatusText}`, installed ? "success" : "warn");
|
||||
if (!installed && platform === "ios") {
|
||||
this.addLog("说明: iOS检测需要将 Scheme 加入 LSApplicationQueriesSchemes。若在【标准基座】中调试,因标准基座无此配置会返回未检测到,需使用【自定义基座】运行", "info");
|
||||
}
|
||||
} catch (e) {
|
||||
this.dyInstallStatusText = "检测异常";
|
||||
this.addLog(`检测安装状态发生异常: ${e.message}`, "error");
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
this.addLog("当前环境为非 App 环境,无法直接调用 5+ isApplicationExist", "warn");
|
||||
// #endif
|
||||
},
|
||||
// 直接测试打开抖音客户端
|
||||
testDirectOpenDouyin() {
|
||||
this.addLog(`尝试打开抖音: ${this.orderStr || 'snssdk1128://open'}`, "info");
|
||||
const targetUrl = this.orderStr || "snssdk1128://open";
|
||||
// #ifdef APP-PLUS
|
||||
let opened = false;
|
||||
if (plus.os.name === "iOS") {
|
||||
try {
|
||||
const UIApplication = plus.ios.importClass("UIApplication");
|
||||
const NSURL = plus.ios.importClass("NSURL");
|
||||
const app = UIApplication.sharedApplication();
|
||||
const nsUrl = NSURL.URLWithString(targetUrl);
|
||||
if (app && nsUrl) {
|
||||
if (app.openURL(nsUrl)) {
|
||||
opened = true;
|
||||
this.addLog("iOS 原生 Native.js 成功拉起客户端", "success");
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
} else if (plus.os.name === "Android") {
|
||||
try {
|
||||
const Intent = plus.android.importClass("android.content.Intent");
|
||||
const Uri = plus.android.importClass("android.net.Uri");
|
||||
const main = plus.android.runtimeMainActivity();
|
||||
const intent = new Intent(Intent.ACTION_VIEW, Uri.parse(targetUrl));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
main.startActivity(intent);
|
||||
opened = true;
|
||||
this.addLog("Android 原生 Native.js Intent 成功拉起客户端", "success");
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
}
|
||||
if (!opened) {
|
||||
plus.runtime.openURL(
|
||||
targetUrl,
|
||||
(err) => {
|
||||
this.addLog(`打开抖音失败: ${JSON.stringify(err)}`, "error");
|
||||
const isSim = plus.navigator && plus.navigator.isSimulator ? plus.navigator.isSimulator() : false;
|
||||
if (isSim) {
|
||||
this.addLog("提示: iOS模拟器未安装抖音客户端,无法响应 snssdk1128:// Scheme,请使用安装了抖音的真机测试", "warn");
|
||||
} else if (err && err.code === -3) {
|
||||
this.addLog("提示: 错误 code -3 说明设备上未检测到抖音应用或Scheme未添加白名单,请确认真机上已安装抖音", "warn");
|
||||
}
|
||||
uni.showToast({
|
||||
title: isSim ? "模拟器不支持打开Scheme,请在真机测试" : "拉起失败,请确认是否已安装抖音",
|
||||
icon: "none",
|
||||
duration: 3000,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
window.location.href = targetUrl;
|
||||
this.addLog("已在 H5 环境尝试跳转: " + targetUrl, "info");
|
||||
// #endif
|
||||
},
|
||||
// 调用 payUtils.js 中的 douyinPayFun
|
||||
async handleTestPay() {
|
||||
if (!this.orderStr) {
|
||||
uni.showToast({
|
||||
title: "请先输入支付串或链接",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const payParams = {
|
||||
type: this.payType,
|
||||
orderStr: this.orderStr,
|
||||
};
|
||||
|
||||
this.loading = true;
|
||||
this.addLog(`开始调用 douyinPayFun,入参: ${JSON.stringify(payParams)}`, "info");
|
||||
|
||||
try {
|
||||
const result = await douyinPayFun(payParams, this.orderId, this.orderNum);
|
||||
this.addLog(`douyinPayFun 调用完成返回: ${JSON.stringify(result)}`, "success");
|
||||
} catch (err) {
|
||||
this.addLog(`douyinPayFun 抛出错误: ${JSON.stringify(err)}`, "error");
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
components: { NavHeader },
|
||||
data() {
|
||||
return { paymentJson: "", loading: false, resultText: "尚未调用支付" };
|
||||
},
|
||||
methods: {
|
||||
async handleTestPay() {
|
||||
if (this.loading) return;
|
||||
// #ifndef APP-PLUS
|
||||
this.resultText = "请使用已集成原生插件的 Android/iOS App 测试";
|
||||
return;
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = JSON.parse(this.paymentJson);
|
||||
if (response.bizcode != null && response.bizcode !== 100) throw new Error("请使用下单成功的接口返回");
|
||||
const payment = response.data || response;
|
||||
if (!payment.orderNum || !payment.douyin) throw new Error("缺少 orderNum 或 douyin");
|
||||
this.resultText = "正在调用原生 SDK,返回后查询订单状态";
|
||||
const result = await appDypayFun(payment);
|
||||
const labels = { paid: "服务端确认支付成功", failed: "服务端确认支付未成功", pending: "结果待确认,请稍后查看订单", error: "调用失败" };
|
||||
this.resultText = result ? (result.message || labels[result.state] || "结果待确认") : "支付正在处理中";
|
||||
} catch (error) {
|
||||
this.resultText = error.message || "调用失败";
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const vm = require('node:vm');
|
||||
const root = path.resolve(__dirname, '..');
|
||||
|
||||
function preprocess(source, app) {
|
||||
const stack = [true];
|
||||
return source.split('\n').filter(line => {
|
||||
const directive = line.match(/\/\/\s*#(ifdef|ifndef) (APP-PLUS|H5)/);
|
||||
if (directive) {
|
||||
const enabled = directive[2] === 'APP-PLUS' ? app === true : app === 'h5';
|
||||
stack.push(stack.at(-1) && (directive[1] === 'ifdef' ? enabled : !enabled)); return false;
|
||||
}
|
||||
if (/\/\/\s*#endif/.test(line)) { stack.pop(); return false; }
|
||||
return stack.at(-1);
|
||||
}).join('\n');
|
||||
}
|
||||
function loadModule(file, context, app = true) {
|
||||
const source = preprocess(fs.readFileSync(path.join(root, file), 'utf8'), app)
|
||||
.replace(/^import .*;\r?$/gm, '')
|
||||
.replace(/export (async function|function)/g, '$1')
|
||||
.replace(/export const /g, 'const ')
|
||||
.replace(/export default request;/g, '');
|
||||
vm.createContext(context);
|
||||
vm.runInContext(source, context, { filename: file });
|
||||
return context;
|
||||
}
|
||||
function uniMock() {
|
||||
const storage = new Map([['token', 'test-token'], ['user', { userId: 7 }]]);
|
||||
const messages = [];
|
||||
return { storage, messages, getStorageSync: k => storage.get(k), setStorageSync: (k,v) => storage.set(k,v),
|
||||
removeStorageSync: k => storage.delete(k), showToast: v => messages.push(v.title), $emit() {},
|
||||
showLoading() {}, hideLoading() {}, navigateTo() {} };
|
||||
}
|
||||
const payment = { orderNum: 'order-1', douyin: { appId: 'app', mchId: 'mch', prepayId: 'prepay',
|
||||
packageValue: 'Sign=DYPay', nonceStr: 'nonce', timeStamp: '1780000000', sign: 'sig' } };
|
||||
async function payContext(overrides = {}, app = true) {
|
||||
const adapter = await import('../utils/douyin-pay-adapter.mjs');
|
||||
const context = { uni: uniMock(), BASE_URL: 'test-api', TOKEN_NAME: 'token', USER_DATA: 'user',
|
||||
...adapter, canOpenDypay: () => true, initDypay: () => true,
|
||||
openDypay: (_, cb) => cb({ resultCode: '0' }),
|
||||
request: async () => ({ bizcode: 100, data: { state: 2 } }), ...overrides };
|
||||
return loadModule('utils/douyin-pay.js', context, app);
|
||||
}
|
||||
test('SDK success is confirmed with server before showing success', async () => {
|
||||
let queries = 0;
|
||||
const ctx = await payContext({ request: async () => { queries++; return { bizcode:100, data:{state:2} }; } });
|
||||
await ctx.appDypayFun(payment);
|
||||
assert.equal(queries, 1);
|
||||
assert.equal(ctx.uni.messages.at(-1), '支付成功');
|
||||
assert.equal(ctx.uni.storage.has('tb-douyin:test-api:7'), false);
|
||||
});
|
||||
test('SDK success plus network failure remains recoverable, never success', async () => {
|
||||
const ctx = await payContext({ request: async () => { throw new Error('offline'); } });
|
||||
await ctx.appDypayFun(payment);
|
||||
assert.equal(ctx.uni.storage.get('tb-douyin:test-api:7'), 'order-1');
|
||||
assert.equal(ctx.uni.messages.includes('支付成功'), false);
|
||||
});
|
||||
test('cancel still queries authoritative server state', async () => {
|
||||
const ctx = await payContext({ openDypay: (_, cb) => cb({ resultCode:'1' }) });
|
||||
await ctx.appDypayFun(payment);
|
||||
assert.equal(ctx.uni.messages.at(-1), '支付成功');
|
||||
});
|
||||
test('old backend parameters never invoke native SDK', async () => {
|
||||
let calls = 0;
|
||||
const ctx = await payContext({ openDypay: () => calls++ });
|
||||
await ctx.appDypayFun({ orderNum:'old', douyin:{appId:'app'} });
|
||||
assert.equal(calls, 0);
|
||||
assert.match(ctx.uni.messages.at(-1), /缺少支付参数/);
|
||||
});
|
||||
test('new backend orderInfo (object or JSON) reaches native SDK with exact signed fields', async () => {
|
||||
const { toSdkPayInfo } = await import('../utils/douyin-pay-adapter.mjs');
|
||||
const expected = toSdkPayInfo(payment);
|
||||
for (const orderInfo of [expected, JSON.stringify(expected)]) {
|
||||
let received;
|
||||
const ctx = await payContext({ openDypay: (options, cb) => { received = options.payInfo; cb({resultCode:'0'}); } });
|
||||
const result = await ctx.appDypayFun({orderNum:'order-1', douyin:{type:'app', orderInfo}});
|
||||
assert.deepEqual(received, expected);
|
||||
assert.equal(result.state, 'paid');
|
||||
}
|
||||
});
|
||||
test('legacy douyinPayFun calls native bridge, never uni payment provider or URL fallback', async () => {
|
||||
let nativeCalls = 0;
|
||||
const ctx = await payContext({ openDypay: (_, cb) => { nativeCalls++; cb({resultCode:'0'}); } });
|
||||
ctx.uni.requestPayment = () => assert.fail('Must not use built-in payment provider for Douyin');
|
||||
ctx.plus = { runtime: { openURL: () => assert.fail('Must not synthesize cashier URLs') } };
|
||||
loadModule('utils/payUtils.js', ctx);
|
||||
const result = await ctx.douyinPayFun(payment.douyin, 1, payment.orderNum);
|
||||
assert.equal(nativeCalls, 1);
|
||||
assert.equal(result.state, 'paid');
|
||||
});
|
||||
test('invalid JSON and Scheme-only payload do not call SDK or create pending state', async () => {
|
||||
for (const douyin of [{orderInfo:'{'}, {orderStr:'snssdk1128://open'}, {type:'h5', prepayId:'prepay'}]) {
|
||||
const ctx = await payContext({openDypay: () => assert.fail('Invalid data reached SDK')});
|
||||
const result = await ctx.appDypayFun({orderNum:'invalid', douyin});
|
||||
assert.equal(result.state, 'error');
|
||||
assert.equal(ctx.uni.storage.has('tb-douyin:test-api:7'), false);
|
||||
}
|
||||
});
|
||||
test('legacy retry of settled order queries state without opening payment again', async () => {
|
||||
const ctx = await payContext({openDypay: () => assert.fail('Retry opened payment again')});
|
||||
ctx.uni.storage.set('tb-douyin:test-api:7', payment.orderNum);
|
||||
const result = await ctx.appDypayFun(payment);
|
||||
assert.equal(result.state, 'paid');
|
||||
});
|
||||
test('duplicate invocation does not open SDK twice', async () => {
|
||||
let done;
|
||||
let calls = 0;
|
||||
const ctx = await payContext({ openDypay: (_, cb) => { calls++; done = cb; } });
|
||||
const first = ctx.appDypayFun(payment);
|
||||
await ctx.appDypayFun(payment);
|
||||
done({resultCode:'0'});
|
||||
await first;
|
||||
assert.equal(calls, 1);
|
||||
});
|
||||
test('account switch suppresses old account result and retains its pending record', async () => {
|
||||
const ctx = await payContext();
|
||||
ctx.request = async () => { ctx.uni.storage.set('user', {userId:8}); return {bizcode:100,data:{state:2}}; };
|
||||
await ctx.appDypayFun(payment);
|
||||
assert.equal(ctx.uni.messages.includes('支付成功'), false);
|
||||
assert.equal(ctx.uni.storage.get('tb-douyin:test-api:7'), 'order-1');
|
||||
});
|
||||
test('cold start queries saved order; unavailable app does not create order', async () => {
|
||||
const ctx = await payContext({ canOpenDypay: () => false });
|
||||
assert.equal(await ctx.prepareDouyinPay('douyin'), false);
|
||||
ctx.uni.storage.set('tb-douyin:test-api:7', 'pending');
|
||||
await ctx.resumeDouyinPay();
|
||||
assert.equal(ctx.uni.messages.at(-1), '支付成功');
|
||||
});
|
||||
test('non-App excludes Douyin and never accesses native SDK', async () => {
|
||||
const ctx = await payContext({}, false);
|
||||
assert.equal(ctx.douyinPayTypes('1,2,3'), '1,2,3');
|
||||
assert.equal(ctx.filterDouyinPayWays([{type:'douyin'},{type:'wechat'}]).length, 1);
|
||||
assert.equal(await ctx.prepareDouyinPay('douyin'), false);
|
||||
});
|
||||
|
||||
test('H5 displays configured Douyin but blocks payment before order creation', async () => {
|
||||
const ctx = await payContext({ canOpenDypay: () => { throw new Error('Native SDK must not run'); } }, 'h5');
|
||||
assert.equal(ctx.douyinPayTypes('1,2,3'), '1,2,3,6');
|
||||
assert.equal(ctx.douyinPayTypes('1,6'), '1,6');
|
||||
assert.equal(ctx.filterDouyinPayWays([{type:'douyin'},{type:'wechat'}]).length, 2);
|
||||
assert.equal(ctx.filterDouyinPayWays([]).length, 0);
|
||||
assert.equal(await ctx.prepareDouyinPay('douyin'), false);
|
||||
assert.match(ctx.uni.messages.at(-1), /仅支持/);
|
||||
});
|
||||
test('request terminates on HTTP500, business500, bad JSON, auth failure and offline', async () => {
|
||||
for (const response of [{statusCode:500,data:{}}, {statusCode:200,data:{status:500}},
|
||||
{statusCode:200,data:'<html>'}, {statusCode:200,data:{bizcode:201,errcode:999}}, null]) {
|
||||
const uni = uniMock();
|
||||
uni.request = options => response ? options.success(response) : options.fail(new Error('offline'));
|
||||
const ctx = loadModule('utils/request.js', { uni, TOKEN_NAME:'token', USER_DATA:'user',
|
||||
getStorageFun: () => '', BASE_URL:'test-api', Authorization:'test-only', console:{log(){}}, setTimeout, clearTimeout });
|
||||
await assert.rejects(ctx.request({url:'/payment/queryResult'}));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"id": "tb-douyin-pay",
|
||||
"displayName": "TB 抖音支付",
|
||||
"version": "0.1.0",
|
||||
"description": "独立实现的抖音支付官方 SDK UTS 桥接",
|
||||
"engines": { "HBuilderX": ">=4.36.0" },
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"client": {
|
||||
"App": { "app-android": "y", "app-ios": "y", "app-harmony": "n" },
|
||||
"H5-mobile": { "Safari": "n", "Android Browser": "n" },
|
||||
"小程序": { "微信": "n" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<queries>
|
||||
<package android:name="com.ss.android.ugc.aweme" />
|
||||
<package android:name="com.ss.android.ugc.aweme.lite" />
|
||||
<package android:name="com.ss.android.ugc.live" />
|
||||
</queries>
|
||||
</manifest>
|
||||
@@ -0,0 +1,50 @@
|
||||
package uts.sdk.modules.tbDouyinPay
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import com.ss.android.dypay.api.DyPay
|
||||
import com.ss.android.dypay.api.IDyPayResultCallback
|
||||
import io.dcloud.uts.UTSAndroid
|
||||
import org.json.JSONObject
|
||||
|
||||
object TbDouyinPayNative {
|
||||
private val main = Handler(Looper.getMainLooper())
|
||||
|
||||
fun initialize(appId: String) { DyPay.setAppId(appId) }
|
||||
|
||||
fun available(): Boolean {
|
||||
val activity = UTSAndroid.getUniActivity() ?: return false
|
||||
return DyPay.isDypayAppUsable(activity)
|
||||
}
|
||||
|
||||
fun pay(payload: String, loading: Boolean, done: (String) -> Unit) {
|
||||
main.post {
|
||||
val activity = UTSAndroid.getUniActivity()
|
||||
if (activity == null || activity.isFinishing) {
|
||||
done("""{"resultCode":"2","errorMsg":"当前页面不可用"}""")
|
||||
return@post
|
||||
}
|
||||
try {
|
||||
if (!DyPay.isDypayAppUsable(activity)) {
|
||||
done("""{"resultCode":"100","errorMsg":"请安装或升级抖音客户端"}""")
|
||||
return@post
|
||||
}
|
||||
val json = JSONObject(payload)
|
||||
val data = HashMap<String, String>()
|
||||
for (key in listOf("appid", "partnerid", "prepayid", "package", "noncestr", "timestamp", "sign")) {
|
||||
data[key] = json.getString(key)
|
||||
}
|
||||
DyPay(activity).pay(data, object : IDyPayResultCallback {
|
||||
override fun onResult(result: Map<String, String>) {
|
||||
val response = JSONObject()
|
||||
.put("resultCode", result["resultCode"] ?: "3")
|
||||
.put("errorMsg", result["errorMsg"] ?: "")
|
||||
main.post { done(response.toString()) }
|
||||
}
|
||||
}, loading)
|
||||
} catch (_: Exception) {
|
||||
done("""{"resultCode":"2","errorMsg":"支付 SDK 调用异常,请查询订单"}""")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"minSdkVersion": 21,
|
||||
"dependencies": ["com.bytedance.caijing:dy-pay-sdk-tob:1.1.0.9"],
|
||||
"project": {
|
||||
"repositories": ["maven { url 'https://artifact.bytedance.com/repository/Volcengine/' }"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { InitOptions, PayOptions, PayCallback } from '../interface.uts'
|
||||
import { configure, invoke } from '../common.uts'
|
||||
|
||||
export function initDypay(options: InitOptions): boolean {
|
||||
if (!configure(options.appId)) return false
|
||||
TbDouyinPayNative.initialize(options.appId)
|
||||
return true
|
||||
}
|
||||
|
||||
export function canOpenDypay(): boolean {
|
||||
return TbDouyinPayNative.available()
|
||||
}
|
||||
|
||||
export function openDypay(options: PayOptions, callback: PayCallback): void {
|
||||
invoke(options, callback, (payload: string, loading: boolean, done: (raw: string) => void) => {
|
||||
TbDouyinPayNative.pay(payload, loading, done)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>DypaySDK.framework/DypaySDK</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>DypaySDK.framework</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>DypaySDK.framework/DypaySDK</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>DypaySDK.framework</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
+4
@@ -0,0 +1,4 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayDIRSFMDatabase.h"
|
||||
#import "DypayDIRSFMResultSet.h"
|
||||
#import "DypayDIRSFMDatabaseQueue.h"
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// DypayAPI.h
|
||||
// DypaySDK
|
||||
//
|
||||
// Created by xutianxi on 2021/12/10.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayErrorCode) {
|
||||
DypayErrorCodeSuccess = 0, // 成功
|
||||
DypayErrorCodeCancel = 1, // 用户取消
|
||||
DypayErrorCodeFail = 2, // 失败
|
||||
DypayErrorCodeProcessing = 3, // 支付结果处理中
|
||||
DypayErrorCodeVersionTooLow = 100, // 抖音版本过低,需要用户升级
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayLogLevel) {
|
||||
DypayLogLevelOff = 0,
|
||||
DypayLogLevelError = 1,
|
||||
DypayLogLevelWarn = 2,
|
||||
DypayLogLevelInfo = 3,
|
||||
DypayLogLevelDebug = 4,
|
||||
};
|
||||
|
||||
#define DYPAYSDK_TAG @"DypaySDK"
|
||||
|
||||
#define DYPAY_RECALL_API_MAX_TIME 3000 //毫秒级
|
||||
#define SHARED_SELF DypayAPI.sharedDypayAPI
|
||||
|
||||
@interface DypayAPI : NSObject
|
||||
|
||||
// 日志记录Block,可查看运行过程中的信息
|
||||
@property (nonatomic, copy) void(^logBlock)(DypayLogLevel level, NSTimeInterval timestamp, NSString *tag, NSString *message);
|
||||
|
||||
/**
|
||||
* 支付单例
|
||||
*
|
||||
* @return 返回单例对象
|
||||
*/
|
||||
+ (DypayAPI *)sharedDypayAPI;
|
||||
|
||||
/*
|
||||
* @param appId 从抖音商户平台申请的appId
|
||||
* @param scheme 从抖音回调当前 App 时使用的 scheme
|
||||
*/
|
||||
+ (void)registerWithAppID:(NSString *)appId
|
||||
callbackScheme:(NSString *)scheme;
|
||||
|
||||
/*
|
||||
* @param appId 从抖音商户平台申请的appId,优先使用universalLink,降级使用scheme
|
||||
* @param universalLink 从抖音回调当前 App 时使用的universalLink
|
||||
* @param scheme 从抖音回调当前 App 时使用的 scheme
|
||||
*/
|
||||
+ (void)registerWithAppID:(NSString *)appId
|
||||
universalLink:(NSString *)universalLink
|
||||
callbackScheme:(NSString *)scheme;
|
||||
|
||||
/*
|
||||
* 判断是否能打开 Dypay
|
||||
*/
|
||||
+ (bool)canOpenDypay;
|
||||
|
||||
/*
|
||||
* @brief 打开 Dypay, 打开成功后马上回调 completionBlock,
|
||||
* @param infoDict 拉起抖音支付必须的订单参数
|
||||
* @param currentTopViewController 拉起抖音支付时顶部的vc
|
||||
* @param callback 调用结果的回调
|
||||
*/
|
||||
+ (void)openDypayWithInfo:(NSDictionary *)infoDict
|
||||
fromViewController:(UIViewController *)currentTopViewController
|
||||
callback:(void(^)(BOOL isOpenedSuccessed, NSString *errMsg))completionBlock DEPRECATED_MSG_ATTRIBUTE("call openDypayWithInfo:fromViewController:resultCallback instead");
|
||||
|
||||
|
||||
/*
|
||||
* @brief 打开 Dypay,唤端之前:支付结果会通过该API的resultCallback参数回调,唤端之后:支付结果通过processDypayResultWithURL的callback回调
|
||||
* @param infoDict 拉起抖音支付必须的订单参数
|
||||
* @param currentTopViewController 拉起抖音支付时顶部的vc
|
||||
* @param resultCallback 支付结果的回调,resultCode枚举参照processDypayResultWithURL注释
|
||||
*/
|
||||
+ (void)openDypayWithInfo:(NSDictionary *)infoDict
|
||||
fromViewController:(UIViewController *)currentTopViewController
|
||||
resultCallback:(void(^)(NSDictionary *resultDict))resultCompletionBlock;
|
||||
|
||||
/*
|
||||
* 处理通过URL支付回调结果
|
||||
* resultDict 包含支付结果错误码信息,如果为nil也表示处理失败。
|
||||
字典中,key: "resultStatus"对应老的错误码定义,将逐步废弃;请使用新key: "resultCode"对应的错误码定义。
|
||||
老key: resultStatus,对应的错误码定义:
|
||||
-1 未知
|
||||
0 订单支付成功
|
||||
10 用户中途取消
|
||||
20 正在处理中
|
||||
30 版本过低
|
||||
40 失败
|
||||
50 超时
|
||||
新key: resultCode,对应的错误码定义
|
||||
DypayErrorCodeSuccess(0) 成功
|
||||
DypayErrorCodeCancel(1) 用户取消
|
||||
DypayErrorCodeFail(2) 失败
|
||||
DypayErrorCodeProcessing(3) 支付结果处理中
|
||||
DypayErrorCodeVersionTooLow(100) 抖音版本过低,需要用户升级
|
||||
*/
|
||||
+ (BOOL)processDypayResultWithURL:(NSURL *)url
|
||||
callback:(void(^)(NSDictionary * _Nullable resultDict))completionBlock;
|
||||
|
||||
/*
|
||||
* 处理通过Universal Link支付回调结果
|
||||
* resultDict 包含支付结果错误码信息,如果为nil也表示处理失败。
|
||||
字典中,key: "resultStatus"对应老的错误码定义,将逐步废弃;请使用新key: "resultCode"对应的错误码定义。
|
||||
老key: resultStatus,对应的错误码定义:
|
||||
-1 未知
|
||||
0 订单支付成功
|
||||
10 用户中途取消
|
||||
20 正在处理中
|
||||
30 版本过低
|
||||
40 失败
|
||||
50 超时
|
||||
新key: resultCode,对应的错误码定义
|
||||
DypayErrorCodeSuccess(0) 成功
|
||||
DypayErrorCodeCancel(1) 用户取消
|
||||
DypayErrorCodeFail(2) 失败
|
||||
DypayErrorCodeProcessing(3) 支付结果处理中
|
||||
DypayErrorCodeVersionTooLow(100) 抖音版本过低,需要用户升级
|
||||
*/
|
||||
+ (BOOL)processDypayResultWithUserActivity:(NSUserActivity *)userActivity
|
||||
callback:(void(^)(NSDictionary *resultDict))completionBlock;
|
||||
|
||||
/*! @brief 获取当前 DypaySDK API 的版本号
|
||||
*/
|
||||
+ (NSString *)getAPIVersion;
|
||||
|
||||
/*
|
||||
* 埋点
|
||||
*/
|
||||
+ (void)event:(NSString *_Nonnull)eventName params:(NSDictionary *_Nullable)params;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// 内部接口,字节外部App不应使用
|
||||
@interface DypayAPI (Internal)
|
||||
// 业务埋点上报Block,字节内部App使用时设置
|
||||
@property (nonatomic, copy) void(^trackEventBlock)(NSString *event, NSDictionary *params);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// DypayDIRSApplication.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISApplicationState) {
|
||||
DypayIRISApplicationStateUnknown = 0,
|
||||
DypayIRISApplicationStateActive,
|
||||
DypayIRISApplicationStateInactive,
|
||||
DypayIRISApplicationStateBackground
|
||||
};
|
||||
|
||||
|
||||
@interface DypayDIRSApplication : NSObject
|
||||
|
||||
@property (readonly, nonnull) NSString *launchID;
|
||||
@property (readonly, assign) NSTimeInterval launchTime;
|
||||
|
||||
@property (readonly) DypayIRISApplicationState applicationState;
|
||||
|
||||
+ (instancetype)sharedApplication;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// DypayDIRSBasicFeatureOptions.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/11/9.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSBasicFeatureOptions : DypayDIRSBasicModule
|
||||
|
||||
- (void)addFeatureOptions:(NSDictionary *)opts;
|
||||
|
||||
- (void)removeFeatureOptionsKeys:(NSArray *)keys;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// DypayDIRSBasicModule.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
#import "DypayIRISMacro.h"
|
||||
#import "DypayDIRSContext.h"
|
||||
#import "DypayDIRSModuleHive.h"
|
||||
#import "IRSLOG.h"
|
||||
#import "DypayDataIRIS.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class DypayDIRSContext;
|
||||
@interface DypayDIRSBasicModule : NSObject<DypayIRISModule>
|
||||
|
||||
@property (nonatomic, weak) DypayDIRSContext* context;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString* category;
|
||||
|
||||
@property BOOL isEnabled;
|
||||
@property DypayIRISState state;
|
||||
|
||||
- (void)onLaunch;
|
||||
|
||||
- (void)run;
|
||||
|
||||
- (void)stop;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSCompressionGzipPlugin.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/9.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSCompressionGzipPlugin : DypayDIRSBasicModule<DypayIRISModuleGlobal, DypayIRISDataCoder>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// DypayDIRSConcurrentCollection.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSConcurrentCollection<T> : NSObject
|
||||
|
||||
+ (instancetype)collectionWithRaw:(T)collection;
|
||||
|
||||
- (void)operate:(void (^)(T raw))operation;
|
||||
|
||||
- (nullable id)access:(nullable id (^)(T raw))operation;
|
||||
|
||||
- (T)rawValue;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// DypayDIRSConfig.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "DypayIRISDefines.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSComplianceConfiguration,DypayDIRSEventConfiguration,DypayDIRSObserver,DypayDIRSEventUploadFilterOptions;
|
||||
|
||||
@interface DypayDIRSConfig : NSObject
|
||||
|
||||
+ (instancetype _Nullable)configWithIdentifier:(NSString *_Nonnull)appId
|
||||
launchOptions:(nullable NSDictionary *)launchOptions;
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *appId;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *appName;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *appVersion;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *buildVersion;
|
||||
|
||||
//If you need to synchronize data between HostApp and ExtensionApp, you need to set the same groupId
|
||||
@property (nullable, nonatomic, copy) NSString *appGroupId;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *channel;
|
||||
|
||||
//be able to distinguish between different instances using the same appid
|
||||
@property (nullable, nonatomic, copy) NSString *subId;
|
||||
|
||||
@property (nonatomic, strong ) NSDictionary *launchOptions;
|
||||
|
||||
@property (nonatomic, assign) BOOL encryptionEnabled;
|
||||
|
||||
@property (nullable, nonatomic, strong) id<DypayIRISEndpoint> endpoint;
|
||||
|
||||
///The default log level is Error
|
||||
@property (nonatomic, assign) DypayIRISLOG_LEVEL logLevel;
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^configureUserLoggerBlock)(id<DypayIRISLog> _Nullable log);
|
||||
|
||||
@property (nullable, readonly) DypayDIRSComplianceConfiguration* compliance;
|
||||
|
||||
@property (nullable, readonly) DypayDIRSEventConfiguration* event;
|
||||
|
||||
@property (nullable, readonly) DypayDIRSObserver *observer;
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString*, NSString *> *_Nullable (^configureHTTPHeaderFieldsBlock)(NSUInteger service);
|
||||
|
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString*, id> *_Nullable (^configureCommonParametersBlock)(NSUInteger service);
|
||||
|
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString*, id> *_Nullable (^configureCustomHeaderBlock)(NSUInteger service);
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^onError)(BOOL fatal, NSError * _Nonnull error, id _Nullable userInfo);
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSComplianceConfiguration : NSObject
|
||||
|
||||
/**
|
||||
* @brief fields to avoid access
|
||||
*
|
||||
* @discussion Fields set in @c blockedFiels will not be accessed and uploaded.
|
||||
* For example, if you you do not want to collect @c vendor_id, set the following code block, then @c UIDevice.identifierForVendor will not be accessed, and the field @c vendor_id will not appear in any HTTPBODY
|
||||
*
|
||||
* @code
|
||||
* config.compliance.blockedFields = @[@"vendor_id"];
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) NSArray *blockedFields;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSEventConfiguration : NSObject
|
||||
|
||||
/*
|
||||
* Intercept or change events before they are stored
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) void (^configureEventInterceptorBlock)(id<DypayIRISEvent> _Nullable event, BOOL * _Nonnull stop);
|
||||
|
||||
/*
|
||||
* Filter events before packaging
|
||||
*
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) _Nullable id (^configurePreBatchFilterBlock)(id _Nullable context);
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) _Nullable id (^configureEventPacketBlock)(id<DypayIRISEvent> _Nullable event, BOOL * _Nonnull stop);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Event expiration time [Unit:seconds]
|
||||
* Data will be cleaned based on expiration time every time on startup
|
||||
* Setting it to 0 will not clean up the data.
|
||||
*
|
||||
* Default is 0
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger eventExpirationTime;
|
||||
|
||||
|
||||
/*
|
||||
* - DypayIRISEventPacketStrategyDefault
|
||||
* Packaging based on the upper limit of the number of events, The number of upper limit can be set through maxPacketEventCount, the default is 200
|
||||
* - DypayIRISEventPacketStrategyByteLimitation
|
||||
* Packing based on the upper limit of data length, The length can be set through maxPacketBytes, the default is 1024*1024
|
||||
*
|
||||
* Default is DypayIRISEventPacketStrategyDefault
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) DypayIRISEventPacketStrategy packetStrategy;
|
||||
|
||||
/*
|
||||
*
|
||||
* Default is 200
|
||||
* takes effect when setting config.event.packetStrategy = DypayIRISEventPacketStrategyDefault
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxPacketEventCount;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Default is 1m
|
||||
* takes effect when setting config.event.packetStrategy = DypayIRISEventPacketStrategyByteLimitation
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxPacketBytes;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Default is 500m, some(25%) earliest events will be deleted when the maximum limit is exceeded on startup
|
||||
|
||||
When an error occurs in the data file and the size of the database file cannot be successfully reduced
|
||||
in order to avoid affecting the stability of the application,
|
||||
the database file will be removed as a whole, which will cause events loss
|
||||
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxFileBytes;
|
||||
|
||||
/*
|
||||
* Maximum length after serialization
|
||||
* default 20*1024;
|
||||
*
|
||||
* @NOT take effect yet
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxPropertyBytes;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventUploadFilterOptions : NSObject
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray<NSString *> *regionKeys;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray<NSString *> *includeTypes;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray<NSString *> *excludeTypes;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSObserver : NSObject
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^onSessionLaunch)(NSString *sessionId, id _Nullable info);
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^onSessionTerminate)(NSString *sessionId, id _Nullable info);
|
||||
|
||||
@end
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// DypayDIRSContext.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSConfig,DypayDIRSLogger,DypayDIRSModuleHive;
|
||||
@interface DypayDIRSContext : NSObject
|
||||
|
||||
@property (nonatomic, readonly) DypayDIRSModuleHive* modular;
|
||||
|
||||
@property (readonly, nullable) DypayDIRSConfig *config;
|
||||
|
||||
@property (readonly, nonnull) NSString *name;
|
||||
|
||||
+ (instancetype)main;
|
||||
|
||||
+ (void)configure:(DypayDIRSConfig *)config;
|
||||
|
||||
- (instancetype)initWithConfig:(DypayDIRSConfig *)config;
|
||||
|
||||
- (BOOL)resume;
|
||||
|
||||
- (void)suspend;
|
||||
|
||||
- (nonnull NSString *)contextPath;
|
||||
|
||||
- (void)async:(dispatch_block_t)block;
|
||||
|
||||
- (nonnull NSDictionary *)contextInfo;
|
||||
|
||||
- (void)dispose;
|
||||
|
||||
- (BOOL)isMainContext;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSContext (Instance)
|
||||
|
||||
+ (NSArray<DypayDIRSContext *> *)ctx_all;
|
||||
|
||||
+ (nullable DypayDIRSContext *)ctx_get:(NSString *)name;
|
||||
|
||||
+ (void)ctx_add:(DypayDIRSContext *)context;
|
||||
|
||||
+ (void)ctx_remove:(DypayDIRSContext *)context;
|
||||
|
||||
@end
|
||||
|
||||
@interface DypayDIRSContext (Modules)
|
||||
|
||||
@property (nullable, nonatomic, readonly) DypayDIRSLogger *logger;
|
||||
|
||||
- (nullable NSDictionary *)modules;
|
||||
|
||||
+ (NSDictionary *)defaultModules;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// DypayDIRSEndpointConfiguration.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/24.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEndpointConfiguration : NSObject<DypayIRISEndpoint>
|
||||
|
||||
@property (nullable, nonatomic, copy) id _Nullable (^domainBlock)(NSUInteger service, id context);
|
||||
|
||||
@property (nullable, nonatomic, copy) id _Nullable (^endpointBlock)(NSUInteger service, id context);
|
||||
|
||||
+ (DypayDIRSEndpointConfiguration *)configurationUsingBlock:(nonnull id (^)(NSUInteger service, id context))block;
|
||||
|
||||
+ (DypayDIRSEndpointConfiguration *)configurationUsingDomainBlock:(nonnull id (^)(NSUInteger service, id context))block;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// DypayDIRSEnviroment.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/25.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEnviroment : DypayDIRSBasicModule<DypayIRISParameterHandler,DypayIRISModuleGlobal>
|
||||
|
||||
+ (NSInteger)sdkVersion;
|
||||
|
||||
+ (NSString *)sdkVersionString;
|
||||
|
||||
+ (NSString *)osName;
|
||||
|
||||
+ (NSString *)osVersion;
|
||||
|
||||
+ (NSString *)platform;
|
||||
|
||||
+ (NSString *)appVersion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// DypayDIRSErrorBuilder.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSErrorBuilder : NSObject
|
||||
|
||||
+ (instancetype)builder;
|
||||
|
||||
- (instancetype)withDomain:(NSErrorDomain)code;
|
||||
|
||||
- (instancetype)withCode:(NSUInteger)code;
|
||||
|
||||
- (instancetype)withDescription:(NSString *)description;
|
||||
|
||||
- (instancetype)withDescriptionFormat:(NSString *)format, ...;
|
||||
|
||||
- (instancetype)withFailureReason:(NSString *)reason;
|
||||
|
||||
- (instancetype)withUnderlyingError:(NSError *)error;
|
||||
|
||||
- (NSError *)build;
|
||||
|
||||
- (BOOL)buildError:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// DypayDIRSEvent.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISDefinesPrivate.h"
|
||||
|
||||
|
||||
|
||||
typedef NSString * DypayIRISEventType;
|
||||
|
||||
FOUNDATION_EXTERN DypayIRISEventType const _Nonnull DypayDIRSEventTypeV3; //event_v3
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSEventOptions;
|
||||
@interface DypayDIRSEvent : NSObject<DypayIRISEvent, NSCoding>
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * key;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * type;
|
||||
|
||||
@property (nonatomic) NSTimeInterval time;
|
||||
@property (nonatomic) NSTimeInterval storedTime;
|
||||
@property (nonatomic) NSTimeInterval batchedTime;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary * properties;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary * globalProperties;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary * commonParameters;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * logID;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSNumber* dbIndex;
|
||||
|
||||
@property (nonatomic, assign) int64_t index;
|
||||
|
||||
@property (nonatomic, copy) NSString* section;
|
||||
|
||||
@property (nullable, nonatomic) id schemaObject;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger schemaDataLength;
|
||||
|
||||
@property (nonatomic, strong) DypayDIRSEventOptions * options;
|
||||
|
||||
@property (nonatomic, assign) BOOL stained;
|
||||
|
||||
//return event_id if event stained
|
||||
- (int64_t)staining;
|
||||
|
||||
- (NSString *)sessionId;
|
||||
|
||||
- (void)addCommonParameters:(NSDictionary *)parameters;
|
||||
|
||||
|
||||
+ (nullable instancetype)eventWithType:(DypayIRISEventType _Nonnull)type
|
||||
properties:(NSDictionary * _Nullable)properties;
|
||||
|
||||
|
||||
+ (nullable instancetype)v3UsingKey:(NSString * _Nonnull)key
|
||||
properties:(NSDictionary * _Nullable)properties;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSEventOptions : NSObject
|
||||
|
||||
@property (nonatomic, assign) NSInteger category;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISPriority priority;
|
||||
|
||||
@property (nullable ,nonatomic, copy) NSString * regionKey;
|
||||
|
||||
@property (nonatomic, assign) NSInteger privacyLevel;
|
||||
|
||||
@property (nonatomic, assign) BOOL filtered;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventBatchOptions : NSObject
|
||||
|
||||
@property (nonatomic, assign) NSInteger priority;
|
||||
|
||||
@property (nullable, nonatomic) NSArray * eventIDs;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger count;
|
||||
|
||||
@property (nonatomic, strong) NSArray * allowRegionList;
|
||||
|
||||
@property (nonatomic, assign) NSInteger minDBIndex;
|
||||
|
||||
@property (nonatomic, assign) NSInteger maxDBIndex;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// DypayDIRSEventUploadDispatcher.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface DypayDIRSEventBatchDispatcher : DypayDIRSBasicModule
|
||||
|
||||
@property (nonatomic, readonly) id<DypayIRISServiceSchema> schema;
|
||||
|
||||
@property (readonly) id<DypayIRISEventUploadExecutor> defaultUploader;
|
||||
|
||||
@property (readonly) id<DypayIRISEventUploadExecutor> realtimeUploader;
|
||||
|
||||
- (nullable id<DypayIRISEventUploadExecutor>)createExecutor;
|
||||
|
||||
- (nullable NSArray<DypayIRISEventUploadExecutor> *)allExecutors;
|
||||
|
||||
- (nonnull dispatch_queue_t)intervalBatchQueue;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// DypayDIRSEventUploadExecutor.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventBatchExecutor : DypayDIRSBasicModule<DypayIRISEventUploadExecutor>
|
||||
|
||||
@property (nonatomic, assign) NSTimeInterval interval;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISServiceSchema> serializer;
|
||||
|
||||
@property (nullable, nonatomic) NSArray<id<DypayIRISDataCoder>> *compressors;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> encryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> decryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISEventStore> eventStore;
|
||||
|
||||
@property (nullable, nonatomic) id<DypayIRISThrottlter> throttlter;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISPriority priority;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISState execState;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary *options;
|
||||
|
||||
|
||||
/*
|
||||
* @opts
|
||||
* DypayIRISBatchOptionsEnforceKey - enforce batch YES|NO
|
||||
*
|
||||
*/
|
||||
//- (void)executeUpload:(DypayIRISBatchTrigger)trigger
|
||||
// options:(nullable NSDictionary *)opts
|
||||
// completion:(void (^ __nullable)(BOOL success, NSError* _Nullable error))completion;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSEventBlockPlugin.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/25.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventBlockPlugin : DypayDIRSBasicModule
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// DypayDIRSEventEntry.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventEntry : DypayDIRSBasicModule<DypayIRISModule, DypayIRISTracker>
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// DypayDIRSEventListener.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/14.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventListener : DypayDIRSBasicModule
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// DypayDIRSEventPacker.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventPacker : NSObject<DypayIRISEventPacker>
|
||||
|
||||
@property (nonatomic, assign) NSUInteger maxPackLength;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger maxEventCount;
|
||||
|
||||
@property (nonatomic, assign) NSInteger strategy;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// DypayDIRSEventRequestSchema.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayDIRSEventPacker.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventRequestSchema : DypayDIRSBasicModule<DypayIRISServiceSchema,DypayIRISModuleGlobal>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventRealtimeRequestSchema : DypayDIRSEventRequestSchema<DypayIRISServiceSchema, DypayIRISModuleGlobal>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSEventSerializer.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/14.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventSerializer : DypayDIRSBasicModule<DypayIRISEventSerializer>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// DypayDIRSEventSession.h
|
||||
//
|
||||
//
|
||||
// Created by ByteDance on 2023/8/4.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayDataIRIS.h"
|
||||
#import "DypayDIRSTracker+Session.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventSession : DypayDIRSBasicModule
|
||||
|
||||
@property (nonatomic, assign) DypayIRISLaunchType launchType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// DypayDIRSEventStore.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayDIRSEvent.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventStore : DypayDIRSBasicModule<DypayIRISEventStore>
|
||||
|
||||
@property (nonatomic, weak) id<DypayIRISEventSerializer> serializer;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// DypayDIRSExtension.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSDictionary (DypayDataIRIS)
|
||||
|
||||
- (nullable NSDictionary *)datairis_dictionaryForKey:(NSString *)key;
|
||||
|
||||
- (nullable NSString *)datairis_stringForKey:(NSString *)key;
|
||||
|
||||
- (nullable NSArray *)datairis_arrayForKey:(NSString *)key;
|
||||
|
||||
- (double)datairis_doubleForKey:(NSString *)key;
|
||||
|
||||
- (NSInteger)datairis_integerForKey:(NSString *)key;
|
||||
|
||||
- (BOOL)datairis_boolForKey:(NSString *)key;
|
||||
|
||||
- (long long)datairis_longlongValueForKey:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+1055
File diff suppressed because it is too large
Load Diff
+182
@@ -0,0 +1,182 @@
|
||||
//
|
||||
// DypayDIRSFMDatabaseQueue.h
|
||||
// fmdb
|
||||
//
|
||||
// Created by August Mueller on 6/22/11.
|
||||
// Copyright 2011 Flying Meat Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class DypayDIRSFMDatabase;
|
||||
|
||||
/** To perform queries and updates on multiple threads, you'll want to use `DypayDIRSFMDatabaseQueue`.
|
||||
|
||||
Using a single instance of `<DypayDIRSFMDatabase>` from multiple threads at once is a bad idea. It has always been OK to make a `<DypayDIRSFMDatabase>` object *per thread*. Just don't share a single instance across threads, and definitely not across multiple threads at the same time.
|
||||
|
||||
Instead, use `DypayDIRSFMDatabaseQueue`. Here's how to use it:
|
||||
|
||||
First, make your queue.
|
||||
|
||||
DypayDIRSFMDatabaseQueue *queue = [DypayDIRSFMDatabaseQueue databaseQueueWithPath:aPath];
|
||||
|
||||
Then use it like so:
|
||||
|
||||
[queue inDatabase:^(DypayDIRSFMDatabase *db) {
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
|
||||
|
||||
DypayDIRSResultSet *rs = [db executeQuery:@"select * from foo"];
|
||||
while ([rs next]) {
|
||||
//…
|
||||
}
|
||||
}];
|
||||
|
||||
An easy way to wrap things up in a transaction can be done like this:
|
||||
|
||||
[queue inTransaction:^(DypayDIRSFMDatabase *db, BOOL *rollback) {
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
|
||||
|
||||
if (whoopsSomethingWrongHappened) {
|
||||
*rollback = YES;
|
||||
return;
|
||||
}
|
||||
// etc…
|
||||
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:4]];
|
||||
}];
|
||||
|
||||
`DypayDIRSFMDatabaseQueue` will run the blocks on a serialized queue (hence the name of the class). So if you call `DypayDIRSFMDatabaseQueue`'s methods from multiple threads at the same time, they will be executed in the order they are received. This way queries and updates won't step on each other's toes, and every one is happy.
|
||||
|
||||
### See also
|
||||
|
||||
- `<DypayDIRSFMDatabase>`
|
||||
|
||||
@warning Do not instantiate a single `<DypayDIRSFMDatabase>` object and use it across multiple threads. Use `DypayDIRSFMDatabaseQueue` instead.
|
||||
|
||||
@warning The calls to `DypayDIRSFMDatabaseQueue`'s methods are blocking. So even though you are passing along blocks, they will **not** be run on another thread.
|
||||
|
||||
*/
|
||||
|
||||
@interface DypayDIRSFMDatabaseQueue : NSObject {
|
||||
NSString *_path;
|
||||
dispatch_queue_t _queue;
|
||||
DypayDIRSFMDatabase *_db;
|
||||
int _openFlags;
|
||||
}
|
||||
|
||||
/** Path of database */
|
||||
|
||||
@property (atomic, retain) NSString *path;
|
||||
|
||||
/** Open flags */
|
||||
|
||||
@property (atomic, readonly) int openFlags;
|
||||
|
||||
///----------------------------------------------------
|
||||
/// @name Initialization, opening, and closing of queue
|
||||
///----------------------------------------------------
|
||||
|
||||
/** Create queue using path.
|
||||
|
||||
@param aPath The file path of the database.
|
||||
|
||||
@return The `DypayDIRSFMDatabaseQueue` object. `nil` on error.
|
||||
*/
|
||||
|
||||
+ (instancetype)databaseQueueWithPath:(NSString*)aPath;
|
||||
|
||||
/** Create queue using path and specified flags.
|
||||
|
||||
@param aPath The file path of the database.
|
||||
@param openFlags Flags passed to the openWithFlags method of the database
|
||||
|
||||
@return The `DypayDIRSFMDatabaseQueue` object. `nil` on error.
|
||||
*/
|
||||
+ (instancetype)databaseQueueWithPath:(NSString*)aPath flags:(int)openFlags;
|
||||
|
||||
/** Create queue using path.
|
||||
|
||||
@param aPath The file path of the database.
|
||||
|
||||
@return The `DypayDIRSFMDatabaseQueue` object. `nil` on error.
|
||||
*/
|
||||
|
||||
- (instancetype)initWithPath:(NSString*)aPath;
|
||||
|
||||
/** Create queue using path and specified flags.
|
||||
|
||||
@param aPath The file path of the database.
|
||||
@param openFlags Flags passed to the openWithFlags method of the database
|
||||
|
||||
@return The `DypayDIRSFMDatabaseQueue` object. `nil` on error.
|
||||
*/
|
||||
|
||||
- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags;
|
||||
|
||||
/** Create queue using path and specified flags.
|
||||
|
||||
@param aPath The file path of the database.
|
||||
@param openFlags Flags passed to the openWithFlags method of the database
|
||||
@param vfsName The name of a custom virtual file system
|
||||
|
||||
@return The `DypayDIRSFMDatabaseQueue` object. `nil` on error.
|
||||
*/
|
||||
|
||||
- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags vfs:(NSString *)vfsName;
|
||||
|
||||
/** Returns the Class of 'DypayDIRSFMDatabase' subclass, that will be used to instantiate database object.
|
||||
|
||||
Subclasses can override this method to return specified Class of 'DypayDIRSFMDatabase' subclass.
|
||||
|
||||
@return The Class of 'DypayDIRSFMDatabase' subclass, that will be used to instantiate database object.
|
||||
*/
|
||||
|
||||
+ (Class)databaseClass;
|
||||
|
||||
/** Close database used by queue. */
|
||||
|
||||
- (void)close;
|
||||
|
||||
///-----------------------------------------------
|
||||
/// @name Dispatching database operations to queue
|
||||
///-----------------------------------------------
|
||||
|
||||
/** Synchronously perform database operations on queue.
|
||||
|
||||
@param block The code to be run on the queue of `DypayDIRSFMDatabaseQueue`
|
||||
*/
|
||||
|
||||
- (void)inDatabase:(void (^)(DypayDIRSFMDatabase *db))block;
|
||||
|
||||
/** Synchronously perform database operations on queue, using transactions.
|
||||
|
||||
@param block The code to be run on the queue of `DypayDIRSFMDatabaseQueue`
|
||||
*/
|
||||
|
||||
- (void)inTransaction:(void (^)(DypayDIRSFMDatabase *db, BOOL *rollback))block;
|
||||
|
||||
/** Synchronously perform database operations on queue, using deferred transactions.
|
||||
|
||||
@param block The code to be run on the queue of `DypayDIRSFMDatabaseQueue`
|
||||
*/
|
||||
|
||||
- (void)inDeferredTransaction:(void (^)(DypayDIRSFMDatabase *db, BOOL *rollback))block;
|
||||
|
||||
///-----------------------------------------------
|
||||
/// @name Dispatching database operations to queue
|
||||
///-----------------------------------------------
|
||||
|
||||
/** Synchronously perform database operations using save point.
|
||||
|
||||
@param block The code to be run on the queue of `DypayDIRSFMDatabaseQueue`
|
||||
*/
|
||||
|
||||
// NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock.
|
||||
// If you need to nest, use DypayDIRSFMDatabase's startSavePointWithName:error: instead.
|
||||
- (NSError*)inSavePoint:(void (^)(DypayDIRSFMDatabase *db, BOOL *rollback))block;
|
||||
|
||||
@end
|
||||
|
||||
+468
@@ -0,0 +1,468 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef __has_feature // Optional.
|
||||
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
||||
#endif
|
||||
|
||||
#ifndef NS_RETURNS_NOT_RETAINED
|
||||
#if __has_feature(attribute_ns_returns_not_retained)
|
||||
#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
|
||||
#else
|
||||
#define NS_RETURNS_NOT_RETAINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@class DypayDIRSFMDatabase;
|
||||
@class DypayDIRSStatement;
|
||||
|
||||
/** Represents the results of executing a query on an `<DypayDIRSFMDatabase>`.
|
||||
|
||||
### See also
|
||||
|
||||
- `<DypayDIRSFMDatabase>`
|
||||
*/
|
||||
|
||||
@interface DypayDIRSResultSet : NSObject {
|
||||
DypayDIRSFMDatabase *_parentDB;
|
||||
DypayDIRSStatement *_statement;
|
||||
|
||||
NSString *_query;
|
||||
NSMutableDictionary *_columnNameToIndexMap;
|
||||
}
|
||||
|
||||
///-----------------
|
||||
/// @name Properties
|
||||
///-----------------
|
||||
|
||||
/** Executed query */
|
||||
|
||||
@property (atomic, retain) NSString *query;
|
||||
|
||||
/** `NSMutableDictionary` mapping column names to numeric index */
|
||||
|
||||
@property (readonly) NSMutableDictionary *columnNameToIndexMap;
|
||||
|
||||
/** `DypayDIRSStatement` used by result set. */
|
||||
|
||||
@property (atomic, retain) DypayDIRSStatement *statement;
|
||||
|
||||
///------------------------------------
|
||||
/// @name Creating and closing database
|
||||
///------------------------------------
|
||||
|
||||
/** Create result set from `<DypayDIRSStatement>`
|
||||
|
||||
@param statement A `<DypayDIRSStatement>` to be performed
|
||||
|
||||
@param aDB A `<DypayDIRSFMDatabase>` to be used
|
||||
|
||||
@return A `DypayDIRSResultSet` on success; `nil` on failure
|
||||
*/
|
||||
|
||||
+ (instancetype)resultSetWithStatement:(DypayDIRSStatement *)statement usingParentDatabase:(DypayDIRSFMDatabase*)aDB;
|
||||
|
||||
/** Close result set */
|
||||
|
||||
- (void)close;
|
||||
|
||||
- (void)setParentDB:(DypayDIRSFMDatabase *)newDb;
|
||||
|
||||
///---------------------------------------
|
||||
/// @name Iterating through the result set
|
||||
///---------------------------------------
|
||||
|
||||
/** Retrieve next row for result set.
|
||||
|
||||
You must always invoke `next` or `nextWithError` before attempting to access the values returned in a query, even if you're only expecting one.
|
||||
|
||||
@return `YES` if row successfully retrieved; `NO` if end of result set reached
|
||||
|
||||
@see hasAnotherRow
|
||||
*/
|
||||
|
||||
- (BOOL)next;
|
||||
|
||||
/** Retrieve next row for result set.
|
||||
|
||||
You must always invoke `next` or `nextWithError` before attempting to access the values returned in a query, even if you're only expecting one.
|
||||
|
||||
@param outErr A 'NSError' object to receive any error object (if any).
|
||||
|
||||
@return 'YES' if row successfully retrieved; 'NO' if end of result set reached
|
||||
|
||||
@see hasAnotherRow
|
||||
*/
|
||||
|
||||
- (BOOL)nextWithError:(NSError **)outErr;
|
||||
|
||||
/** Did the last call to `<next>` succeed in retrieving another row?
|
||||
|
||||
@return `YES` if the last call to `<next>` succeeded in retrieving another record; `NO` if not.
|
||||
|
||||
@see next
|
||||
|
||||
@warning The `hasAnotherRow` method must follow a call to `<next>`. If the previous database interaction was something other than a call to `next`, then this method may return `NO`, whether there is another row of data or not.
|
||||
*/
|
||||
|
||||
- (BOOL)hasAnotherRow;
|
||||
|
||||
///---------------------------------------------
|
||||
/// @name Retrieving information from result set
|
||||
///---------------------------------------------
|
||||
|
||||
/** How many columns in result set
|
||||
|
||||
@return Integer value of the number of columns.
|
||||
*/
|
||||
|
||||
- (int)columnCount;
|
||||
|
||||
/** Column index for column name
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return Zero-based index for column.
|
||||
*/
|
||||
|
||||
- (int)columnIndexForName:(NSString*)columnName;
|
||||
|
||||
/** Column name for column index
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return columnName `NSString` value of the name of the column.
|
||||
*/
|
||||
|
||||
- (NSString*)columnNameForIndex:(int)columnIdx;
|
||||
|
||||
/** Result set integer value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `int` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (int)intForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set integer value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `int` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (int)intForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `long` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `long` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (long)longForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set long value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `long` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (long)longForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `long long int` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `long long int` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (long long int)longLongIntForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `long long int` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `long long int` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (long long int)longLongIntForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `unsigned long long int` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `unsigned long long int` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (unsigned long long int)unsignedLongLongIntForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `unsigned long long int` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `unsigned long long int` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (unsigned long long int)unsignedLongLongIntForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `BOOL` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `BOOL` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (BOOL)boolForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `BOOL` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `BOOL` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (BOOL)boolForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `double` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `double` value of the result set's column.
|
||||
|
||||
*/
|
||||
|
||||
- (double)doubleForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `double` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `double` value of the result set's column.
|
||||
|
||||
*/
|
||||
|
||||
- (double)doubleForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `NSString` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `NSString` value of the result set's column.
|
||||
|
||||
*/
|
||||
|
||||
- (NSString*)stringForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `NSString` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `NSString` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (NSString*)stringForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `NSDate` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `NSDate` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (NSDate*)dateForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `NSDate` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `NSDate` value of the result set's column.
|
||||
|
||||
*/
|
||||
|
||||
- (NSDate*)dateForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `NSData` value for column.
|
||||
|
||||
This is useful when storing binary data in table (such as image or the like).
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `NSData` value of the result set's column.
|
||||
|
||||
*/
|
||||
|
||||
- (NSData*)dataForColumn:(NSString*)columnName;
|
||||
|
||||
/** Result set `NSData` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `NSData` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (NSData*)dataForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set `(const unsigned char *)` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `(const unsigned char *)` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (const unsigned char *)UTF8StringForColumnName:(NSString*)columnName;
|
||||
|
||||
/** Result set `(const unsigned char *)` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `(const unsigned char *)` value of the result set's column.
|
||||
*/
|
||||
|
||||
- (const unsigned char *)UTF8StringForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set object for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
|
||||
|
||||
@see objectForKeyedSubscript:
|
||||
*/
|
||||
|
||||
- (id)objectForColumnName:(NSString*)columnName;
|
||||
|
||||
/** Result set object for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
|
||||
|
||||
@see objectAtIndexedSubscript:
|
||||
*/
|
||||
|
||||
- (id)objectForColumnIndex:(int)columnIdx;
|
||||
|
||||
/** Result set object for column.
|
||||
|
||||
This method allows the use of the "boxed" syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:
|
||||
|
||||
id result = rs[@"employee_name"];
|
||||
|
||||
This simplified syntax is equivalent to calling:
|
||||
|
||||
id result = [rs objectForKeyedSubscript:@"employee_name"];
|
||||
|
||||
which is, it turns out, equivalent to calling:
|
||||
|
||||
id result = [rs objectForColumnName:@"employee_name"];
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
|
||||
*/
|
||||
|
||||
- (id)objectForKeyedSubscript:(NSString *)columnName;
|
||||
|
||||
/** Result set object for column.
|
||||
|
||||
This method allows the use of the "boxed" syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:
|
||||
|
||||
id result = rs[0];
|
||||
|
||||
This simplified syntax is equivalent to calling:
|
||||
|
||||
id result = [rs objectForKeyedSubscript:0];
|
||||
|
||||
which is, it turns out, equivalent to calling:
|
||||
|
||||
id result = [rs objectForColumnName:0];
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
|
||||
*/
|
||||
|
||||
- (id)objectAtIndexedSubscript:(int)columnIdx;
|
||||
|
||||
/** Result set `NSData` value for column.
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `NSData` value of the result set's column.
|
||||
|
||||
@warning If you are going to use this data after you iterate over the next row, or after you close the
|
||||
result set, make sure to make a copy of the data first (or just use `<dataForColumn:>`/`<dataForColumnIndex:>`)
|
||||
If you don't, you're going to be in a world of hurt when you try and use the data.
|
||||
|
||||
*/
|
||||
|
||||
- (NSData*)dataNoCopyForColumn:(NSString*)columnName NS_RETURNS_NOT_RETAINED;
|
||||
|
||||
/** Result set `NSData` value for column.
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `NSData` value of the result set's column.
|
||||
|
||||
@warning If you are going to use this data after you iterate over the next row, or after you close the
|
||||
result set, make sure to make a copy of the data first (or just use `<dataForColumn:>`/`<dataForColumnIndex:>`)
|
||||
If you don't, you're going to be in a world of hurt when you try and use the data.
|
||||
|
||||
*/
|
||||
|
||||
- (NSData*)dataNoCopyForColumnIndex:(int)columnIdx NS_RETURNS_NOT_RETAINED;
|
||||
|
||||
/** Is the column `NULL`?
|
||||
|
||||
@param columnIdx Zero-based index for column.
|
||||
|
||||
@return `YES` if column is `NULL`; `NO` if not `NULL`.
|
||||
*/
|
||||
|
||||
- (BOOL)columnIndexIsNull:(int)columnIdx;
|
||||
|
||||
/** Is the column `NULL`?
|
||||
|
||||
@param columnName `NSString` value of the name of the column.
|
||||
|
||||
@return `YES` if column is `NULL`; `NO` if not `NULL`.
|
||||
*/
|
||||
|
||||
- (BOOL)columnIsNull:(NSString*)columnName;
|
||||
|
||||
|
||||
/** Returns a dictionary of the row results mapped to case sensitive keys of the column names.
|
||||
|
||||
@returns `NSDictionary` of the row results.
|
||||
|
||||
@warning The keys to the dictionary are case sensitive of the column names.
|
||||
*/
|
||||
|
||||
- (NSDictionary*)resultDictionary;
|
||||
|
||||
/** Returns a dictionary of the row results
|
||||
|
||||
@see resultDictionary
|
||||
|
||||
@warning **Deprecated**: Please use `<resultDictionary>` instead. Also, beware that `<resultDictionary>` is case sensitive!
|
||||
*/
|
||||
|
||||
- (NSDictionary*)resultDict __attribute__ ((deprecated));
|
||||
|
||||
///-----------------------------
|
||||
/// @name Key value coding magic
|
||||
///-----------------------------
|
||||
|
||||
/** Performs `setValue` to yield support for key value observing.
|
||||
|
||||
@param object The object for which the values will be set. This is the key-value-coding compliant object that you might, for example, observe.
|
||||
|
||||
*/
|
||||
|
||||
- (void)kvcMagic:(id)object;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// DypayDIRSGlobalTimer.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/12.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSGlobalTimer : NSObject
|
||||
|
||||
+ (instancetype)globalTimer;
|
||||
|
||||
- (void)addTimer:(id<DypayIRISTimer> _Nullable)timer;
|
||||
|
||||
- (void)removeTimer:(id<DypayIRISTimer> _Nullable)timer;
|
||||
|
||||
- (void)startTimer;
|
||||
|
||||
- (void)stopTimer;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// DypayDIRSIdentity.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSIdentity : DypayDIRSBasicModule<DypayIRISModule>
|
||||
|
||||
//for all service
|
||||
@property (readonly) BOOL isIdentifierAvailable;
|
||||
|
||||
@property (readonly, nullable) NSString *clientId;
|
||||
|
||||
- (void)setUserIdentifiers:(NSDictionary *)IDs;
|
||||
|
||||
- (void)setDeviceIdentifiers:(NSDictionary *)IDs;
|
||||
|
||||
- (NSDictionary *)userIdentifiers;
|
||||
|
||||
- (NSDictionary *)deviceIdentifiers;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// DypayDIRSLogger.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface DypayDIRSConsoleLogger : DypayDIRSBasicModule<DypayIRISModule, DypayIRISLogger>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSLogger : DypayDIRSBasicModule<DypayIRISModule>
|
||||
|
||||
- (void)addLogger:(id<DypayIRISLogger>)logger;
|
||||
|
||||
- (void)removeLogger:(id<DypayIRISLogger>)logger;
|
||||
|
||||
- (void)removeAllLoggers;
|
||||
|
||||
- (void)addLog:(id<DypayIRISLog> _Nonnull)log;
|
||||
|
||||
- (nonnull NSString *)stringUsingDefaultFormatter:(nonnull id<DypayIRISLog>)log;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// DypayDIRSMMapCache.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2024/3/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSMMapCache : NSObject
|
||||
|
||||
@property (nonatomic, assign, readonly) BOOL isMapping;
|
||||
|
||||
@property (nonatomic, assign, readonly, nullable) void *object;
|
||||
|
||||
- (instancetype)initWithPath:(NSString *)path;
|
||||
|
||||
- (BOOL)mmap:(size_t)size;
|
||||
|
||||
- (void)munmap;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// DypayDIRSModuleHive.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/12.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
#import "DypayDIRSConcurrentCollection.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSContext;
|
||||
@interface DypayDIRSModuleHive : NSObject {
|
||||
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) DypayDIRSContext* context;
|
||||
|
||||
- (instancetype)initWithContext:(nonnull DypayDIRSContext *)context;
|
||||
|
||||
- (void)resume;
|
||||
|
||||
- (void)suspend;
|
||||
|
||||
- (void)start;
|
||||
|
||||
- (nullable id<DypayIRISModule>)loadUsingId:(NSString *)moduleId;
|
||||
|
||||
- (nullable id<DypayIRISModule>)loadUsingClass:(Class<DypayIRISModule>)moduleClass;
|
||||
|
||||
- (nullable NSArray *)loadUsingProtocol:(Protocol *)protocol;
|
||||
|
||||
- (void)notify:(nonnull Protocol *)protocol
|
||||
selector:(SEL)sel
|
||||
arguments:(NSArray * _Nullable)arguments;
|
||||
|
||||
|
||||
- (BOOL)handleURL:(nonnull NSURL *)url;
|
||||
|
||||
- (void)raiseError:(nonnull NSError *)error
|
||||
isFatal:(BOOL)fatal
|
||||
withUserInfo:(nullable id)userInfo;
|
||||
|
||||
- (nullable NSDictionary *)exportCommonParameters:(nullable NSArray *)required;
|
||||
|
||||
- (nullable NSDictionary *)exportFeatureParameters;
|
||||
|
||||
- (nullable NSDictionary *)exportFeatureOptions;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// DypayDIRSNetworking.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSNetworkRequestOptions: NSObject<DypayIRISNetworkRequestOptions>
|
||||
|
||||
@property (nonatomic, assign) NSUInteger attempts;
|
||||
|
||||
@property (nonatomic, assign) NSTimeInterval timeout;
|
||||
|
||||
@property (nullable, nonatomic) NSArray<id<DypayIRISDataCoder>> *compressors;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> encryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> decryptor;
|
||||
|
||||
@property (nullable, nonatomic) NSDictionary *userInfo;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSNetworking : DypayDIRSBasicModule {
|
||||
}
|
||||
|
||||
@property (nonatomic) id<DypayIRISNetworkProvider> provider;
|
||||
|
||||
- (void)syncUsingSchema:(nonnull id<DypayIRISServiceSchema>)schema
|
||||
header:(nullable NSDictionary *)header
|
||||
body:(nullable id)body
|
||||
options:(nullable id<DypayIRISNetworkRequestOptions>)options
|
||||
completion:(void (^_Nullable)(BOOL success, id _Nullable data, id _Nullable response, NSError * _Nullable error, id _Nullable metrics))completionHandler;
|
||||
|
||||
- (void)asyncUsingSchema:(nonnull id<DypayIRISServiceSchema>)schema
|
||||
header:(nullable NSDictionary *)header
|
||||
body:(nullable id)body
|
||||
options:(nullable id<DypayIRISNetworkRequestOptions>)options
|
||||
completion:(void (^_Nullable)(BOOL success, id _Nullable data, id _Nullable response, NSError * _Nullable error, id _Nullable metrics))completionHandler;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSPreStorePlugin.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/10/23.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSPreStorePlugin : DypayDIRSBasicModule
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSRealtimeEventPlugin.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/11.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSRealtimeEventPlugin : DypayDIRSBasicModule
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSRemoteSettings.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/4.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSRemoteSettings : DypayDIRSBasicModule
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSRemoteSettingsSchema.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/4.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSRemoteSettingsSchema : DypayDIRSBasicModule<DypayIRISServiceSchema, DypayIRISModuleGlobal>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// DypayDIRSRequestParameters.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/4.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class DypayDIRSContext;
|
||||
@interface DypayDIRSRequestParameters : NSObject
|
||||
|
||||
+ (nullable NSDictionary *)commonParameters:(NSUInteger)service
|
||||
context:(nonnull DypayDIRSContext *)context
|
||||
fieldKeys:(nullable NSArray *)keys;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// DypayDIRSStore.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSStore : DypayDIRSBasicModule
|
||||
|
||||
- (id<DypayIRISStore>)cache;
|
||||
|
||||
- (_Nullable id<DypayIRISStore>)preferences;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// DypayDIRSTask.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/12.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSTask : NSObject
|
||||
|
||||
+ (void)asyncConcurrentTask:(dispatch_block_t)task;
|
||||
+ (void)asyncGlobalTask:(dispatch_block_t)task;
|
||||
+ (void)asyncMainTask:(dispatch_block_t)task
|
||||
forContext:(id)context;
|
||||
+ (dispatch_queue_t)defaultConcurrent;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSThrottlterPlugin.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/8/4.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSThrottlterPlugin : DypayDIRSBasicModule
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// DypayDIRSTracker+Session.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/9/20.
|
||||
//
|
||||
|
||||
#import "DypayDataIRIS.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, DypayIRISLaunchType) {
|
||||
DypayIRISLaunchTypeInitialState = 0,
|
||||
DypayIRISLaunchTypeUserClick,
|
||||
DypayIRISLaunchTypeRemotePush,
|
||||
DypayIRISLaunchTypeWidget,
|
||||
DypayIRISLaunchTypeSpotlight,
|
||||
DypayIRISLaunchTypeExternal,
|
||||
DypayIRISLaunchTypeBackground,
|
||||
DypayIRISLaunchTypeSiri,
|
||||
DypayIRISLaunchTypeUserLoginChanged = 99,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSTracker (Session)
|
||||
|
||||
@property (nonatomic, assign) DypayIRISLaunchType launchType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// DypayDIRSTracker.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/12.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSConfig,DypayDIRSEventUploadFilterOptions;
|
||||
@interface DypayDIRSTracker : NSObject
|
||||
|
||||
+ (instancetype _Nonnull)mainTracker;
|
||||
|
||||
+ (instancetype _Nonnull)initMainTrackerWithConfig:(DypayDIRSConfig * _Nonnull)config;
|
||||
|
||||
- (instancetype _Nonnull)initWithConfig:(DypayDIRSConfig * _Nonnull)config;
|
||||
|
||||
- (BOOL)start;
|
||||
|
||||
- (void)stop;
|
||||
|
||||
- (void)setDeviceIdentifiers:(nonnull NSDictionary *)IDs;
|
||||
|
||||
- (void)setUserIdentifiers:(nonnull NSDictionary *)IDs;
|
||||
|
||||
|
||||
- (nullable NSString *)clientId;
|
||||
|
||||
@end
|
||||
|
||||
@interface DypayDIRSTracker (Event)
|
||||
|
||||
//Default is YES;
|
||||
@property (nonatomic, assign) BOOL eventTrackEnabled;
|
||||
|
||||
//Default is YES;
|
||||
@property (nonatomic, assign) BOOL eventUploadEnabled;
|
||||
|
||||
- (void)trackEvent:(NSString * _Nonnull)key
|
||||
withProperties:(NSDictionary * _Nullable)properties;
|
||||
|
||||
- (void)trackJSON:(NSDictionary * _Nonnull)json
|
||||
withType:(NSString * _Nonnull)type;
|
||||
|
||||
- (void)addGlobalProperties:(nullable NSDictionary *)properties;
|
||||
|
||||
- (void)removeGlobalPropertiesForKeys:(nullable NSArray *)keys;
|
||||
|
||||
- (void)removeAllEvents;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSTracker (Enviroment)
|
||||
|
||||
- (void)setAppRegion:(nullable NSString *)appRegion;
|
||||
|
||||
- (void)setAppLanguage:(nullable NSString *)appLauguage;
|
||||
|
||||
- (void)setEventRegion:(nullable NSString *)region;
|
||||
|
||||
- (nullable NSString *)currentEventRegion;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSTracker (URL)
|
||||
|
||||
- (BOOL)handleURL:(nonnull NSURL *)url;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// DypayDIRSUtilities.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface DypayDIRSUtilities : NSObject
|
||||
|
||||
+ (nonnull NSString *)rootDirectory;
|
||||
+ (nullable NSString *)ensureDirectory:(nonnull NSString *)path;
|
||||
|
||||
//Runtime
|
||||
+ (NSString *)timeParser:(NSTimeInterval)time;
|
||||
+ (NSString *)dateParser:(NSTimeInterval)time;
|
||||
|
||||
+ (void)measureExecution:(void (^)(void))execution
|
||||
completion:(void (^ __nullable)(NSTimeInterval interval))completion;
|
||||
|
||||
|
||||
//equal
|
||||
|
||||
+ (BOOL)isObject:(id)obj isEqualTo:(id)target;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// DypayDIRSValue.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSValue : NSObject<DypayIRISValue>
|
||||
|
||||
- (instancetype)initWithValue:(nullable id)object
|
||||
withSource:(DypayIRISValueSource)source;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// DypayDataIRIS.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/7/12.
|
||||
//
|
||||
|
||||
#ifndef DypayDataIRIS_h
|
||||
#define DypayDataIRIS_h
|
||||
|
||||
#import "DypayIRISDefines.h"
|
||||
#import "DypayDIRSConfig.h"
|
||||
#import "DypayDIRSTracker.h"
|
||||
#import "DypayDIRSEndpointConfiguration.h"
|
||||
|
||||
|
||||
#endif /* DypayDataIRIS_h */
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// DypayDataIRISDefaultSchema.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/9/14.
|
||||
//
|
||||
|
||||
#ifndef DypayDataIRISDefaultSchema_h
|
||||
#define DypayDataIRISDefaultSchema_h
|
||||
|
||||
|
||||
#endif /* DypayDataIRISDefaultSchema_h */
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// DypayDataIRISEvent.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/9/14.
|
||||
//
|
||||
|
||||
#ifndef DypayDataIRISEvent_h
|
||||
#define DypayDataIRISEvent_h
|
||||
|
||||
|
||||
#endif /* DypayDataIRISEvent_h */
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// DypayDataIRISFMDB.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/9/14.
|
||||
//
|
||||
|
||||
#ifndef DypayDataIRISFMDB_h
|
||||
#define DypayDataIRISFMDB_h
|
||||
|
||||
|
||||
#endif /* DypayDataIRISFMDB_h */
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// DypayDataIRISRemoteSettings.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/9/14.
|
||||
//
|
||||
|
||||
#ifndef DypayDataIRISRemoteSettings_h
|
||||
#define DypayDataIRISRemoteSettings_h
|
||||
|
||||
|
||||
#endif /* DypayDataIRISRemoteSettings_h */
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// DypayDataIRISThrottlter.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/9/14.
|
||||
//
|
||||
|
||||
#ifndef DypayDataIRISThrottlter_h
|
||||
#define DypayDataIRISThrottlter_h
|
||||
|
||||
|
||||
#endif /* DypayDataIRISThrottlter_h */
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// IRSDefines.h
|
||||
//
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#ifndef IRSDefines_h
|
||||
#define IRSDefines_h
|
||||
|
||||
typedef NSString * DypayIRISParameterKey;
|
||||
typedef NSString * DypayIRISOptionsKey;
|
||||
typedef NSUInteger DypayIRISServiceType;
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISLOG_LEVEL) {
|
||||
DypayIRISLOG_LEVEL_OFF = 0,
|
||||
DypayIRISLOG_LEVEL_ERROR = 1,
|
||||
DypayIRISLOG_LEVEL_WARN = 2,
|
||||
DypayIRISLOG_LEVEL_INFO = 3,
|
||||
DypayIRISLOG_LEVEL_DEBUG = 4,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISValueSource) {
|
||||
DypayIRISValueSourceDefault = 1,
|
||||
DypayIRISValueSourceLocal,
|
||||
DypayIRISValueSourceRemote
|
||||
};
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISEventPacketStrategy) {
|
||||
DypayIRISEventPacketStrategyDefault = 0,
|
||||
DypayIRISEventPacketStrategyByteLimitation = 1,
|
||||
};
|
||||
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISServiceType DypayIRISServiceTypeRemoteSettings;
|
||||
FOUNDATION_EXPORT DypayIRISServiceType DypayIRISServiceTypeEvent;
|
||||
FOUNDATION_EXPORT DypayIRISServiceType DypayIRISServiceTypeEventRealtime;
|
||||
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISBatchFilterAllowRegionListKey;
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISBatchOptionsMaxConcurrentCountKey;
|
||||
|
||||
|
||||
@protocol DypayIRISLog <NSObject>
|
||||
|
||||
@property (nonatomic) DypayIRISLOG_LEVEL level;
|
||||
|
||||
@property (nonatomic) NSTimeInterval time;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * tag;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * message;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISValue <NSObject>
|
||||
|
||||
- (DypayIRISValueSource)source;
|
||||
|
||||
- (nullable id)rawValue;
|
||||
|
||||
- (nullable NSString *)stringValue;
|
||||
|
||||
- (NSInteger)integerValue;
|
||||
|
||||
- (double)doubleValue;
|
||||
|
||||
- (nullable NSDictionary *)dictioanryValue;
|
||||
|
||||
- (nullable NSArray *)arrayValue;
|
||||
|
||||
- (BOOL)boolValue;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISEvent <NSObject>
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * key;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * type;
|
||||
|
||||
@property (readonly, nonatomic) NSTimeInterval time;
|
||||
|
||||
@property (nonatomic, assign) int64_t index;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSNumber* dbIndex;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString* logID;
|
||||
|
||||
@property (nullable, nonatomic) NSDictionary * properties;
|
||||
|
||||
@property (readonly) NSInteger dataLength;
|
||||
|
||||
@property (nullable, readonly) NSString * sessionId;
|
||||
|
||||
@property (nullable, readonly) id objectValue;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISEndpoint <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
- (id _Nullable)domainForService:(NSUInteger)service
|
||||
context:(id _Nullable)context;
|
||||
|
||||
- (id _Nullable)endpointForService:(NSUInteger)service
|
||||
context:(id _Nullable)context;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IRSDefines_h */
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// DypayIRISDefinesPrivate.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/7/12.
|
||||
//
|
||||
|
||||
#ifndef DypayIRISDefinesPrivate_h
|
||||
#define DypayIRISDefinesPrivate_h
|
||||
|
||||
#import "DypayDataIRIS.h"
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
#import "DypayDIRSContext.h"
|
||||
#import "DypayDIRSLogger.h"
|
||||
#import "DypayDIRSStore.h"
|
||||
#import "DypayIRISMacro.h"
|
||||
#import "IRSLOG.h"
|
||||
#import "DypayDIRSEventBatchDispatcher.h"
|
||||
#import "DypayDIRSNetworking.h"
|
||||
#import "DypayDIRSIdentity.h"
|
||||
#import "DypayDIRSExtension.h"
|
||||
#import "DypayDIRSValue.h"
|
||||
#import "DypayDIRSEvent.h"
|
||||
#import "DypayDIRSTask.h"
|
||||
#import "DypayDIRSBasicFeatureOptions.h"
|
||||
#import "DypayDIRSRequestParameters.h"
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISSentryOptionsAppendCachedEventsKey;
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISSentryOptionsAggregatedKey;
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISSentryOptionsAggregationConfigurationKey;
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISSentryOptionsAggregationDimsKey;
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISEnviromentEventRegionKey;
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISBatchOptionsEnforceKey;
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISBatchOptionsEventStainedKey;
|
||||
|
||||
FOUNDATION_EXPORT DypayIRISOptionsKey _Nonnull DypayIRISBatchOptionsConcurrentModeKey;
|
||||
|
||||
|
||||
//append current cached events count
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSComplianceConfiguration (Private)
|
||||
|
||||
@property (nullable, nonatomic, weak) DypayDIRSConfig *base;
|
||||
|
||||
@end
|
||||
|
||||
@interface DypayDIRSEventConfiguration (Private)
|
||||
|
||||
@property (nullable, nonatomic, weak) DypayDIRSConfig *base;
|
||||
|
||||
@end
|
||||
|
||||
@interface DypayDIRSContext (Private)
|
||||
|
||||
@property (nullable, nonatomic, weak) DypayDIRSLogger *logger;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISTracker> tracker;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISEventListener> listener;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISSentry> sentry;
|
||||
|
||||
@property (nullable, nonatomic, weak) DypayDIRSIdentity *identity;
|
||||
@property (nullable, nonatomic, weak) DypayDIRSEventBatchDispatcher* dispatcher;
|
||||
@property (nullable, nonatomic, weak) DypayDIRSStore *store;
|
||||
@property (nullable, nonatomic, weak) DypayDIRSNetworking *networking;
|
||||
@property (nullable, nonatomic, weak) DypayDIRSBasicFeatureOptions *basicFeatureOptions;
|
||||
|
||||
@property (nullable, nonatomic, weak) id samplingModule;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSTracker (Private)
|
||||
|
||||
- (nonnull DypayDIRSContext *)context;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSConfig (Private)
|
||||
|
||||
- (BOOL)registerModule:(nullable Class<DypayIRISModule>)moduleClass;
|
||||
- (void)unregisterModule:(nullable Class)moduleClass;
|
||||
- (nonnull NSArray<Class<DypayIRISModule>> *)registeredModules;
|
||||
|
||||
- (void)disableModule:(nonnull NSString *)moduleId;
|
||||
- (nonnull NSArray<NSString *> *)disabledModuleIds;
|
||||
|
||||
- (nullable NSString *)uniqueKey;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* DypayIRISDefinesPrivate_h */
|
||||
+556
@@ -0,0 +1,556 @@
|
||||
//
|
||||
// IRSInterfaceDefines.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#ifndef IRSInterfaceDefines_h
|
||||
#define IRSInterfaceDefines_h
|
||||
|
||||
#import "DypayIRISDefines.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@class DypayDIRSContext,DypayDIRSValue;
|
||||
|
||||
#define DypayIRIS_MODULE_PRIORITY_HIGH 99
|
||||
|
||||
#define DypayIRIS_MODULE_PRIORITY_DEFAULT 50
|
||||
|
||||
#define DypayIRIS_MODULE_PRIORITY_LOW 0
|
||||
|
||||
#define DypayIRIS_MODULE_PRIORITY_CONFIG DypayIRIS_MODULE_PRIORITY_HIGH + 1
|
||||
|
||||
#define DypayIRIS_MODULE_PRIORITY_EVENT (DypayIRIS_MODULE_PRIORITY_DEFAULT + 1)
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISState) {
|
||||
DypayIRISStateDefault = 0,
|
||||
DypayIRISStateRunning,
|
||||
DypayIRISStateSuspending
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISPriority) {
|
||||
DypayIRISPriorityRealtime = (-99),
|
||||
DypayIRISPriorityDefault = 0,
|
||||
|
||||
};
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISBatchTrigger) {
|
||||
DypayIRISBatchTriggerTimer = 1 << 0, //1
|
||||
DypayIRISBatchTriggerEnterBackground = 1 << 1, //2
|
||||
DypayIRISBatchTriggerRealtime = 1 << 2, //4
|
||||
DypayIRISBatchTriggerLaunch = 1 << 3, //8
|
||||
DypayIRISBatchTriggerFlush = 1 << 4, //16
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISEventPackResult) {
|
||||
DypayIRISEventPackResultAvalible = 0,
|
||||
DypayIRISEventPackResultFull = 1,
|
||||
DypayIRISEventPackResultInvalid = 2
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@class DypayDIRSConfig;
|
||||
|
||||
@protocol DypayIRISModule <NSObject>
|
||||
|
||||
+ (nonnull NSString *)moduleId;
|
||||
|
||||
+ (nonnull NSString *)moduleVersion;
|
||||
|
||||
+ (BOOL)isPlugin;
|
||||
|
||||
+ (NSInteger)priority;
|
||||
|
||||
@property BOOL isEnabled;
|
||||
@property DypayIRISState state;
|
||||
@property (nullable, readonly) DypayDIRSContext *context;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString* category;
|
||||
|
||||
- (instancetype _Nonnull )initWithContext:(DypayDIRSContext * _Nonnull)context;
|
||||
|
||||
- (nullable dispatch_queue_t)executionQueue;
|
||||
|
||||
- (void)commonInit;
|
||||
|
||||
- (void)resume;
|
||||
|
||||
- (void)suspend;
|
||||
|
||||
@optional
|
||||
|
||||
+ (nonnull NSArray *)moduleDependencies;
|
||||
|
||||
- (void)waitUtilDone;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISModuleGlobal <DypayIRISModule>
|
||||
|
||||
@required
|
||||
+ (nonnull instancetype)sharedInstance;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISApplicationObserver <DypayIRISModule>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)onApplicationDidFinishLaunching;
|
||||
|
||||
- (void)onApplicationDidBecomeActive;
|
||||
|
||||
- (void)onApplicationWillEnterForeground;
|
||||
|
||||
- (void)onApplicationWillResignActive;
|
||||
|
||||
- (void)onApplicationDidEnterBackground;
|
||||
|
||||
- (void)onApplicationWillTerminate;
|
||||
|
||||
- (void)onApplicationDidReceiveMemoryWarning;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISContextObserver <DypayIRISModule>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)onFinishInitialization:(nonnull DypayDIRSContext *)context;
|
||||
|
||||
- (void)onFinishLaunching:(nonnull DypayDIRSContext *)context;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISIdentifierObserver <DypayIRISModule>
|
||||
|
||||
@optional
|
||||
- (void)onDeviceIdentifiersChanged:(nonnull NSDictionary *)change;
|
||||
|
||||
- (void)onUserIdentifiersChanged:(nonnull NSDictionary *)change;
|
||||
|
||||
- (void)onIdentifierAvailable;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISSessionObserver <NSObject>
|
||||
|
||||
@optional
|
||||
- (void)onSessionLaunch:(nonnull NSString *)sessionId;
|
||||
|
||||
- (void)onSessionTerminate:(nonnull NSString *)sessionId;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISEventSerializer <NSObject>
|
||||
|
||||
- (nullable NSData *)dataWithEvent:(nullable id)event options:(nullable id)opt error:(NSError * _Nullable * _Nullable)error;
|
||||
|
||||
- (nullable id)eventWithData:(nullable NSData *)data options:(nullable id)opt error:(NSError * _Nullable * _Nullable)error;
|
||||
|
||||
- (nullable id)eventWithDictionary:(nullable NSDictionary *)dict options:(nullable id)opt error:(NSError * _Nullable * _Nullable)error;
|
||||
|
||||
- (NSUInteger)encodingType;
|
||||
|
||||
+ (nullable NSArray *)allowedParameterFields;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISEventStore <DypayIRISModule>
|
||||
|
||||
- (void)addEvent:(id _Nonnull )event;
|
||||
|
||||
- (void)removeEvents:(id _Nullable )batchOpts;
|
||||
|
||||
- (void)queryEvents:(id _Nullable)batchOpts
|
||||
usingBlock:(nonnull void (^)(BOOL finish, id _Nullable event , BOOL * _Nonnull stop))block;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISEventSerializer> serializer;
|
||||
|
||||
@optional
|
||||
|
||||
- (BOOL)startWithPath:(nonnull NSString *)path;
|
||||
|
||||
- (void)reset;
|
||||
|
||||
- (nullable id)executeStatement:(nonnull NSString *)sql;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISTracker <DypayIRISModule>
|
||||
|
||||
@required
|
||||
|
||||
@property (nullable, readonly) id<DypayIRISEventStore> store;
|
||||
|
||||
- (void)setEnviromentVar:(nonnull id)val forKey:(nonnull NSString *)key;
|
||||
|
||||
- (nullable id)enviromentVarForKey:(nonnull NSString *)key;
|
||||
|
||||
- (void)trackEvent:(id<DypayIRISEvent> _Nonnull)event;
|
||||
|
||||
- (void)addGlobalProperties:(NSDictionary *_Nonnull)properties;
|
||||
|
||||
- (void)removeGlobalPropertieKeys:(NSArray *_Nonnull)keys;
|
||||
|
||||
- (void)removeAllEvents;
|
||||
|
||||
@optional
|
||||
|
||||
|
||||
- (void)addCommonParameters:(NSDictionary *_Nonnull)parameters;
|
||||
|
||||
- (void)configureUsingBlock:(nonnull dispatch_block_t)block;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISEventProcedureHandler <DypayIRISModule>
|
||||
|
||||
- (BOOL)handleProcedure:(id<DypayIRISEvent> _Nonnull)event
|
||||
withError:(NSError * _Nullable __autoreleasing *_Nullable)error;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISEventPreProcedureHandler <DypayIRISModule>
|
||||
|
||||
- (BOOL)prehandleProcedure:(id<DypayIRISEvent> _Nonnull)event
|
||||
withError:(NSError * _Nullable __autoreleasing *_Nullable)error;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISEventListener <DypayIRISModule>
|
||||
|
||||
- (void)notifyEventsAccepted:(nonnull NSArray *)events
|
||||
withOptions:(nullable id)opt;
|
||||
|
||||
- (void)notifyEventsStored:(nonnull NSArray *)events
|
||||
withOptions:(nullable id)opt;;
|
||||
|
||||
- (void)notifyEventsDropped:(nonnull NSArray *)events
|
||||
withOptions:(nullable id)opt
|
||||
withError:(NSError *_Nullable)error;
|
||||
|
||||
- (void)notifyEventsUploaded:(nonnull NSArray *)events
|
||||
withOptions:(nullable id)opt;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISEventObserver <DypayIRISModule>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)onEventAccepted:(id<DypayIRISEvent> _Nonnull)evt;
|
||||
|
||||
- (void)onEventStored:(id<DypayIRISEvent> _Nonnull)evt;
|
||||
|
||||
- (void)onEventDropped:(id<DypayIRISEvent> _Nonnull)evt withError:(NSError *_Nullable)error;
|
||||
|
||||
- (void)onEventUploaded:(id<DypayIRISEvent> _Nonnull)evt;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISEventPacker <DypayIRISModule>
|
||||
|
||||
@property (nonatomic, assign) NSUInteger maxPackLength;
|
||||
@property (nonatomic, assign) NSUInteger maxEventCount;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISEventPacketStrategy strategy;
|
||||
|
||||
- (DypayIRISEventPackResult)appendEvent:(nullable id<DypayIRISEvent>)event;
|
||||
|
||||
- (nonnull NSData *)serializedData;
|
||||
|
||||
- (nonnull id)objectValue;
|
||||
|
||||
- (nonnull NSArray *)eventIDs;
|
||||
|
||||
- (nonnull NSArray<id<DypayIRISEvent>> *)packetEvents;
|
||||
|
||||
@optional
|
||||
|
||||
- (void)appendCommonParameters:(nullable NSDictionary *)parameters;
|
||||
|
||||
- (void)appendFeatureParameters:(nullable NSDictionary *)features;
|
||||
|
||||
- (void)appendFeatureOptions:(nullable NSDictionary *)options;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISThrottlter <DypayIRISModule>
|
||||
|
||||
- (void)configure:(nullable id)strategy;
|
||||
|
||||
- (BOOL)allowed:(nullable id)options
|
||||
reason:(NSError * _Nullable __autoreleasing *_Nullable)reason;
|
||||
|
||||
- (void)setBasicInterval:(NSTimeInterval)interval;
|
||||
- (NSTimeInterval)adjustedInterval;
|
||||
|
||||
- (void)adjust:(nonnull id)result;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISURLHandler <DypayIRISModule>
|
||||
|
||||
- (BOOL)handleURL:(NSURL *_Nonnull)url;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISDataCoder <DypayIRISModule>
|
||||
|
||||
- (nonnull NSString *)algorithm;
|
||||
|
||||
@optional
|
||||
|
||||
- (nullable NSDictionary *)requiredHTTPHeaderFields;
|
||||
|
||||
- (nullable NSDictionary *)requiredParameters;
|
||||
|
||||
|
||||
- (nullable NSData *)encodedData:(NSData *_Nonnull)input
|
||||
options:(nullable id)options
|
||||
error:(NSError * _Nullable * _Nullable)error;
|
||||
|
||||
- (nullable NSData *)decodedData:(nonnull NSData *)input
|
||||
options:(nullable id)options
|
||||
error:(NSError * _Nullable * _Nullable)error;
|
||||
|
||||
- (uint64_t)hashUsingData:(nonnull id)input;
|
||||
|
||||
- (void)setOptions:(nullable NSDictionary *)options;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISTimer <NSObject>
|
||||
|
||||
@required
|
||||
|
||||
@property NSTimeInterval tickTime;
|
||||
|
||||
- (NSTimeInterval)timerInterval;
|
||||
|
||||
- (void)onTimerTick;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISLogger <NSObject>
|
||||
|
||||
- (void)addLog:(nonnull id<DypayIRISLog>)log;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISErrorHandler <DypayIRISModule>
|
||||
|
||||
@required
|
||||
- (void)onError:(NSError *_Nonnull)error;
|
||||
|
||||
@end
|
||||
|
||||
@protocol DypayIRISStore <NSObject>
|
||||
|
||||
- (nullable id)objectForKey:(NSString * _Nonnull)key;
|
||||
|
||||
- (BOOL)setObject:(id _Nonnull)object
|
||||
forKey:(NSString * _Nonnull)key;
|
||||
|
||||
- (BOOL)removeObjectForKey:(NSString * _Nonnull)key;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISNetworkRequestOptions <DypayIRISModule>
|
||||
|
||||
@property (nonatomic, assign) NSUInteger attempts;
|
||||
|
||||
@property (nonatomic, assign) NSTimeInterval timeout;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray* compressors;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> encryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> decryptor;
|
||||
|
||||
@property (nullable, nonatomic) NSDictionary *userInfo;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISNetworkProvider <DypayIRISModule>
|
||||
|
||||
- (void)request:(nonnull NSString *)HTTPUrl
|
||||
method:(nonnull NSString *)HTTPMethod
|
||||
headerFields:(nonnull NSDictionary<NSString *,NSString *> *)headerFields
|
||||
body:(nullable id)body
|
||||
options:(nullable id)options
|
||||
completion:(nonnull void (^)(id _Nullable data, id _Nullable response, NSError * _Nullable error))completion;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISServiceSchema <DypayIRISModule>
|
||||
|
||||
- (BOOL)resultWithResponse:(nullable id)object;
|
||||
|
||||
- (id _Nullable)responseObjectWithData:(nonnull NSData *)data;
|
||||
|
||||
/*
|
||||
* should start with '/'
|
||||
*/
|
||||
- (NSString *_Nonnull)HTTPPath;
|
||||
|
||||
/*
|
||||
* GET/POST/PUT...
|
||||
*/
|
||||
- (NSString * _Nonnull)HTTPMethod;
|
||||
|
||||
- (nullable id)HTTPBody:(nonnull DypayDIRSContext *)context
|
||||
options:(nullable id<DypayIRISNetworkRequestOptions>)options;
|
||||
|
||||
- (NSUInteger)serviceType;
|
||||
|
||||
@optional
|
||||
|
||||
- (NSDictionary * _Nullable)HTTPHeaderFields;
|
||||
|
||||
- (nullable NSString *)getLogID:(nonnull NSHTTPURLResponse *)response;
|
||||
|
||||
- (NSString * _Nullable)enchantURL:(NSString * _Nonnull)url;
|
||||
|
||||
- (nullable id)HTTPBodyPacker:(nonnull DypayDIRSContext *)context;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISEventUploadExecutor <DypayIRISModule>
|
||||
|
||||
@property (nonatomic, assign) NSTimeInterval interval;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISServiceSchema> serializer;
|
||||
|
||||
@property (nullable, nonatomic) NSArray<id<DypayIRISDataCoder>> *compressors;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> encryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> decryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISEventStore> eventStore;
|
||||
|
||||
@property (nullable, nonatomic) id<DypayIRISThrottlter> throttlter;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISPriority priority;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISState execState;
|
||||
|
||||
@property (nullable, nonatomic) NSDictionary *options;
|
||||
|
||||
- (void)executeUpload:(DypayIRISBatchTrigger)trigger;
|
||||
|
||||
- (void)executeUpload:(DypayIRISBatchTrigger)trigger
|
||||
options:(nullable NSDictionary *)options;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISEventRealtimeHandler <DypayIRISModule>
|
||||
|
||||
- (void)onRealtimeEventRecieved;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol DypayIRISParameterHandler <DypayIRISModule>
|
||||
|
||||
@optional
|
||||
|
||||
- (nullable NSArray *)supportedParameterKeys;
|
||||
|
||||
- (nullable id)parameterForKey:(nonnull NSString *)key;
|
||||
|
||||
- (NSDictionary * _Nullable)exportParameters:(nullable NSArray *)required;
|
||||
|
||||
- (NSDictionary * _Nullable)exportFeatureParameters;
|
||||
|
||||
- (NSDictionary * _Nullable)exportFeatureOptions;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISConfigurationHandler
|
||||
|
||||
@property (nullable, readonly) DypayDIRSValue *config;
|
||||
|
||||
@optional
|
||||
- (void)restore;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISConfigurationObserver
|
||||
|
||||
@optional
|
||||
- (void)onRemoteSettingsDidUpdate:(nonnull DypayDIRSValue *)config;
|
||||
|
||||
- (void)onRealtimeSettingsDidUpdate:(nonnull DypayDIRSValue *)config;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@protocol DypayIRISSentry <DypayIRISModule>
|
||||
|
||||
//default schema
|
||||
- (void)monitoring:(nonnull NSString *)key
|
||||
dimensions:(nullable NSDictionary *)dimensions
|
||||
options:(nullable NSDictionary *)options;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IRSInterfaceDefines_h */
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// DypayIRISMacro.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#ifndef DypayIRISMacro_h
|
||||
#define DypayIRISMacro_h
|
||||
|
||||
#include "metamacros.h"
|
||||
|
||||
|
||||
|
||||
#define DypayIRIS_CONCAT(A, B) A##B
|
||||
|
||||
#define DypayIRIS_EXPORT_MODULE(module_id, module_version) \
|
||||
+ (NSString *)moduleId { return module_id; } \
|
||||
+ (NSString *)moduleVersion { return module_version; }
|
||||
|
||||
#define DypayIRIS_EXPORT_PLUGIN(module_id, module_version) \
|
||||
+ (NSString *)moduleId { return module_id; } \
|
||||
+ (NSString *)moduleVersion { return module_version; } \
|
||||
+ (BOOL)isPlugin { return YES; }
|
||||
|
||||
#define DypayIRIS_EXPORT_PARAMETER(field, returnType) \
|
||||
- (returnType)DypayIRIS_CONCAT(__datairis_parameter__, field)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Define SharedInstance Implementation
|
||||
*
|
||||
* SHARED_INSTANCE_IMPL(sharedManager)
|
||||
* Equals
|
||||
* + (instancetype)sharedManager {...}
|
||||
*/
|
||||
#undef EXPORT_SHARED_INSTANCE
|
||||
#define EXPORT_SHARED_INSTANCE(sharedInstanceMethod) \
|
||||
+ (instancetype)sharedInstanceMethod \
|
||||
{ \
|
||||
static dispatch_once_t once; \
|
||||
static id __singleton__; \
|
||||
dispatch_once( &once, ^{ \
|
||||
__singleton__ = [[self alloc] init]; \
|
||||
if ([__singleton__ respondsToSelector:@selector(commonInit)]) { \
|
||||
[__singleton__ performSelector:@selector(commonInit)]; \
|
||||
}\
|
||||
}); \
|
||||
return __singleton__; \
|
||||
} \
|
||||
|
||||
/*
|
||||
* Usage paired @weakify(self) & @strongify(self)
|
||||
*/
|
||||
#ifndef weakify
|
||||
#if DEBUG
|
||||
#if __has_feature(objc_arc)
|
||||
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
|
||||
#else
|
||||
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
|
||||
#endif
|
||||
#else
|
||||
#if __has_feature(objc_arc)
|
||||
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
|
||||
#else
|
||||
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef strongify
|
||||
#if DEBUG
|
||||
#if __has_feature(objc_arc)
|
||||
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
|
||||
#else
|
||||
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
|
||||
#endif
|
||||
#else
|
||||
#if __has_feature(objc_arc)
|
||||
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
|
||||
#else
|
||||
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef DypayIRIS_keywordify
|
||||
|
||||
#if DEBUG
|
||||
#define DypayIRIS_keywordify autoreleasepool {}
|
||||
#else
|
||||
#define DypayIRIS_keywordify try {} @catch (...) {}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* @onExit {
|
||||
//code
|
||||
}
|
||||
*/
|
||||
#ifndef onExit
|
||||
#define onExit \
|
||||
DypayIRIS_keywordify \
|
||||
__strong datairis_cleanup_t metamacro_concat(macro_exitBlock_, __LINE__) __attribute__((cleanup(datairis_executeCleanupBlock), unused)) = ^
|
||||
|
||||
typedef void (^datairis_cleanup_t)(void);
|
||||
static inline void datairis_executeCleanupBlock (__strong datairis_cleanup_t *block) {
|
||||
(*block)();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* {
|
||||
* @lock_guard(lock)
|
||||
* //mutex excution
|
||||
* }
|
||||
*/
|
||||
#ifndef lock_guard
|
||||
#define lock_guard(l) \
|
||||
DypayIRIS_keywordify \
|
||||
[l lock]; \
|
||||
@onExit { \
|
||||
[l unlock]; \
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* DypayIRISMacro_h */
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#else
|
||||
#ifndef FOUNDATION_EXPORT
|
||||
#if defined(__cplusplus)
|
||||
#define FOUNDATION_EXPORT extern "C"
|
||||
#else
|
||||
#define FOUNDATION_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "DypayAPI.h"
|
||||
#import "DypayDIRSApplication.h"
|
||||
#import "DypayDIRSBasicFeatureOptions.h"
|
||||
#import "DypayDIRSCompressionGzipPlugin.h"
|
||||
#import "DypayDIRSContext.h"
|
||||
#import "DypayDIRSEnviroment.h"
|
||||
#import "DypayDIRSGlobalTimer.h"
|
||||
#import "DypayDIRSStore.h"
|
||||
#import "DypayDIRSValue.h"
|
||||
#import "DypayIRISDefinesPrivate.h"
|
||||
#import "DypayDIRSIdentity.h"
|
||||
#import "DypayDIRSLogger.h"
|
||||
#import "IRSLOG.h"
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayDIRSModuleHive.h"
|
||||
#import "DypayDIRSNetworking.h"
|
||||
#import "DypayDIRSRequestParameters.h"
|
||||
#import "DypayDataIRIS.h"
|
||||
#import "DypayDIRSConfig.h"
|
||||
#import "DypayDIRSEndpointConfiguration.h"
|
||||
#import "DypayDIRSTracker.h"
|
||||
#import "DypayDIRSConcurrentCollection.h"
|
||||
#import "DypayDIRSErrorBuilder.h"
|
||||
#import "DypayDIRSExtension.h"
|
||||
#import "DypayDIRSMMapCache.h"
|
||||
#import "DypayDIRSTask.h"
|
||||
#import "DypayDIRSUtilities.h"
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
#import "DypayIRISMacro.h"
|
||||
#import "metamacros.h"
|
||||
#import "DypayIRISDefines.h"
|
||||
#import "DypayDIRSEvent.h"
|
||||
#import "DypayDIRSEventBatchDispatcher.h"
|
||||
#import "DypayDIRSEventBatchExecutor.h"
|
||||
#import "DypayDIRSEventEntry.h"
|
||||
#import "DypayDIRSEventListener.h"
|
||||
#import "DypayDataIRISEvent.h"
|
||||
#import "DypayDIRSEventBlockPlugin.h"
|
||||
#import "DypayDIRSEventPacker.h"
|
||||
#import "DypayDIRSEventRequestSchema.h"
|
||||
#import "DypayDIRSEventSerializer.h"
|
||||
#import "DypayDataIRISDefaultSchema.h"
|
||||
#import "DIRSFMDB.h"
|
||||
#import "DypayDIRSEventStore.h"
|
||||
#import "DypayDIRSFMDatabase.h"
|
||||
#import "DypayDIRSFMDatabaseQueue.h"
|
||||
#import "DypayDIRSFMResultSet.h"
|
||||
#import "DypayDIRSPreStorePlugin.h"
|
||||
#import "DypayDataIRISFMDB.h"
|
||||
#import "DypayDIRSEventSession.h"
|
||||
#import "DypayDIRSTracker+Session.h"
|
||||
#import "DypayDIRSRealtimeEventPlugin.h"
|
||||
#import "DypayDIRSRemoteSettings.h"
|
||||
#import "DypayDataIRISRemoteSettings.h"
|
||||
#import "DypayDIRSRemoteSettingsSchema.h"
|
||||
#import "DypayDIRSThrottlterPlugin.h"
|
||||
#import "DypayDataIRISThrottlter.h"
|
||||
#import "DypayTrackerManager.h"
|
||||
|
||||
FOUNDATION_EXPORT double DypaySDKVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char DypaySDKVersionString[];
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// DypayTrackerManager.h
|
||||
// DypaySDK-CJPaySandBox
|
||||
//
|
||||
// Created by shanghuaijun on 2024/12/19.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class DypayDIRSTracker;
|
||||
@interface DypayTrackerManager : NSObject
|
||||
|
||||
@property (nonatomic, strong, readonly) DypayDIRSTracker *tracker;
|
||||
|
||||
+ (instancetype)defaultService;
|
||||
|
||||
+ (void)initConfig;
|
||||
|
||||
+ (void)event:(NSString *_Nonnull)eventName params:(NSDictionary *_Nullable)params;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// IRSLOG.h
|
||||
// Pods
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#ifndef IRSLOG_h
|
||||
#define IRSLOG_h
|
||||
|
||||
|
||||
#ifdef __OBJC__
|
||||
|
||||
extern void datairis_log_oc(int level, id ctx, NSString *tag, NSString *,...);
|
||||
#undef LOG_MACRO
|
||||
#define LOG_MACRO(flag,ctx,tag,fmt,...) \
|
||||
if (ctx && ctx.config && ctx.config.logLevel >= flag) { \
|
||||
datairis_log_oc(flag, ctx, tag, fmt, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DypayIRIS_MINIMUM_VERSION
|
||||
|
||||
#define LOG_DEBUG
|
||||
|
||||
#define LOG_INFO
|
||||
|
||||
#define LOG_WARN
|
||||
|
||||
#else
|
||||
|
||||
#undef LOG_DEBUG
|
||||
#define LOG_DEBUG(ctx, tag, fmt, ...) LOG_MACRO(4 ,ctx, tag, fmt, ##__VA_ARGS__)
|
||||
//#define LOG_DEBUG(ctx, tag, fmt, ...)
|
||||
|
||||
#undef LOG_INFO
|
||||
#define LOG_INFO(ctx, tag, fmt, ...) LOG_MACRO(3 ,ctx, tag, fmt, ##__VA_ARGS__)
|
||||
//#define LOG_INFO(ctx, tag, fmt, ...)
|
||||
|
||||
#undef LOG_WARN
|
||||
#define LOG_WARN(ctx, tag, fmt, ...) LOG_MACRO(2 ,ctx, tag, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#undef LOG_ERROR
|
||||
#define LOG_ERROR(ctx, tag, fmt, ...) LOG_MACRO(1 ,ctx, tag, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
#endif /* IRSLOG_h */
|
||||
+669
@@ -0,0 +1,669 @@
|
||||
/**
|
||||
* Macros for metaprogramming
|
||||
* ExtendedC
|
||||
*
|
||||
* Copyright (C) 2012 Justin Spahr-Summers
|
||||
* Released under the MIT license
|
||||
*/
|
||||
|
||||
#ifndef EXTC_METAMACROS_H
|
||||
#define EXTC_METAMACROS_H
|
||||
|
||||
|
||||
/**
|
||||
* Executes one or more expressions (which may have a void type, such as a call
|
||||
* to a function that returns no value) and always returns true.
|
||||
*/
|
||||
#define metamacro_exprify(...) \
|
||||
((__VA_ARGS__), true)
|
||||
|
||||
/**
|
||||
* Returns a string representation of VALUE after full macro expansion.
|
||||
*/
|
||||
#define metamacro_stringify(VALUE) \
|
||||
metamacro_stringify_(VALUE)
|
||||
|
||||
/**
|
||||
* Returns A and B concatenated after full macro expansion.
|
||||
*/
|
||||
#define metamacro_concat(A, B) \
|
||||
metamacro_concat_(A, B)
|
||||
|
||||
/**
|
||||
* Returns the Nth variadic argument (starting from zero). At least
|
||||
* N + 1 variadic arguments must be given. N must be between zero and twenty,
|
||||
* inclusive.
|
||||
*/
|
||||
#define metamacro_at(N, ...) \
|
||||
metamacro_concat(metamacro_at, N)(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Returns the number of arguments (up to twenty) provided to the macro. At
|
||||
* least one argument must be provided.
|
||||
*
|
||||
* Inspired by P99: http://p99.gforge.inria.fr
|
||||
*/
|
||||
#define metamacro_argcount(...) \
|
||||
metamacro_at(20, __VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
|
||||
|
||||
/**
|
||||
* Identical to #metamacro_foreach_cxt, except that no CONTEXT argument is
|
||||
* given. Only the index and current argument will thus be passed to MACRO.
|
||||
*/
|
||||
#define metamacro_foreach(MACRO, SEP, ...) \
|
||||
metamacro_foreach_cxt(metamacro_foreach_iter, SEP, MACRO, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* For each consecutive variadic argument (up to twenty), MACRO is passed the
|
||||
* zero-based index of the current argument, CONTEXT, and then the argument
|
||||
* itself. The results of adjoining invocations of MACRO are then separated by
|
||||
* SEP.
|
||||
*
|
||||
* Inspired by P99: http://p99.gforge.inria.fr
|
||||
*/
|
||||
#define metamacro_foreach_cxt(MACRO, SEP, CONTEXT, ...) \
|
||||
metamacro_concat(metamacro_foreach_cxt, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Identical to #metamacro_foreach_cxt. This can be used when the former would
|
||||
* fail due to recursive macro expansion.
|
||||
*/
|
||||
#define metamacro_foreach_cxt_recursive(MACRO, SEP, CONTEXT, ...) \
|
||||
metamacro_concat(metamacro_foreach_cxt_recursive, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* In consecutive order, appends each variadic argument (up to twenty) onto
|
||||
* BASE. The resulting concatenations are then separated by SEP.
|
||||
*
|
||||
* This is primarily useful to manipulate a list of macro invocations into instead
|
||||
* invoking a different, possibly related macro.
|
||||
*/
|
||||
#define metamacro_foreach_concat(BASE, SEP, ...) \
|
||||
metamacro_foreach_cxt(metamacro_foreach_concat_iter, SEP, BASE, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Iterates COUNT times, each time invoking MACRO with the current index
|
||||
* (starting at zero) and CONTEXT. The results of adjoining invocations of MACRO
|
||||
* are then separated by SEP.
|
||||
*
|
||||
* COUNT must be an integer between zero and twenty, inclusive.
|
||||
*/
|
||||
#define metamacro_for_cxt(COUNT, MACRO, SEP, CONTEXT) \
|
||||
metamacro_concat(metamacro_for_cxt, COUNT)(MACRO, SEP, CONTEXT)
|
||||
|
||||
/**
|
||||
* Returns the first argument given. At least one argument must be provided.
|
||||
*
|
||||
* This is useful when implementing a variadic macro, where you may have only
|
||||
* one variadic argument, but no way to retrieve it (for example, because \c ...
|
||||
* always needs to match at least one argument).
|
||||
*
|
||||
* @code
|
||||
|
||||
#define varmacro(...) \
|
||||
metamacro_head(__VA_ARGS__)
|
||||
|
||||
* @endcode
|
||||
*/
|
||||
#define metamacro_head(...) \
|
||||
metamacro_head_(__VA_ARGS__, 0)
|
||||
|
||||
/**
|
||||
* Returns every argument except the first. At least two arguments must be
|
||||
* provided.
|
||||
*/
|
||||
#define metamacro_tail(...) \
|
||||
metamacro_tail_(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Returns the first N (up to twenty) variadic arguments as a new argument list.
|
||||
* At least N variadic arguments must be provided.
|
||||
*/
|
||||
#define metamacro_take(N, ...) \
|
||||
metamacro_concat(metamacro_take, N)(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Removes the first N (up to twenty) variadic arguments from the given argument
|
||||
* list. At least N variadic arguments must be provided.
|
||||
*/
|
||||
#define metamacro_drop(N, ...) \
|
||||
metamacro_concat(metamacro_drop, N)(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Decrements VAL, which must be a number between zero and twenty, inclusive.
|
||||
*
|
||||
* This is primarily useful when dealing with indexes and counts in
|
||||
* metaprogramming.
|
||||
*/
|
||||
#define metamacro_dec(VAL) \
|
||||
metamacro_at(VAL, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
|
||||
|
||||
/**
|
||||
* Increments VAL, which must be a number between zero and twenty, inclusive.
|
||||
*
|
||||
* This is primarily useful when dealing with indexes and counts in
|
||||
* metaprogramming.
|
||||
*/
|
||||
#define metamacro_inc(VAL) \
|
||||
metamacro_at(VAL, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)
|
||||
|
||||
/**
|
||||
* If A is equal to B, the next argument list is expanded; otherwise, the
|
||||
* argument list after that is expanded. A and B must be numbers between zero
|
||||
* and twenty, inclusive. Additionally, B must be greater than or equal to A.
|
||||
*
|
||||
* @code
|
||||
|
||||
// expands to true
|
||||
metamacro_if_eq(0, 0)(true)(false)
|
||||
|
||||
// expands to false
|
||||
metamacro_if_eq(0, 1)(true)(false)
|
||||
|
||||
* @endcode
|
||||
*
|
||||
* This is primarily useful when dealing with indexes and counts in
|
||||
* metaprogramming.
|
||||
*/
|
||||
#define metamacro_if_eq(A, B) \
|
||||
metamacro_concat(metamacro_if_eq, A)(B)
|
||||
|
||||
/**
|
||||
* Identical to #metamacro_if_eq. This can be used when the former would fail
|
||||
* due to recursive macro expansion.
|
||||
*/
|
||||
#define metamacro_if_eq_recursive(A, B) \
|
||||
metamacro_concat(metamacro_if_eq_recursive, A)(B)
|
||||
|
||||
/**
|
||||
* Returns 1 if N is an even number, or 0 otherwise. N must be between zero and
|
||||
* twenty, inclusive.
|
||||
*
|
||||
* For the purposes of this test, zero is considered even.
|
||||
*/
|
||||
#define metamacro_is_even(N) \
|
||||
metamacro_at(N, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)
|
||||
|
||||
/**
|
||||
* Returns the logical NOT of B, which must be the number zero or one.
|
||||
*/
|
||||
#define metamacro_not(B) \
|
||||
metamacro_at(B, 1, 0)
|
||||
|
||||
// IMPLEMENTATION DETAILS FOLLOW!
|
||||
// Do not write code that depends on anything below this line.
|
||||
#define metamacro_stringify_(VALUE) # VALUE
|
||||
#define metamacro_concat_(A, B) A ## B
|
||||
#define metamacro_foreach_iter(INDEX, MACRO, ARG) MACRO(INDEX, ARG)
|
||||
#define metamacro_head_(FIRST, ...) FIRST
|
||||
#define metamacro_tail_(FIRST, ...) __VA_ARGS__
|
||||
#define metamacro_consume_(...)
|
||||
#define metamacro_expand_(...) __VA_ARGS__
|
||||
|
||||
// implemented from scratch so that metamacro_concat() doesn't end up nesting
|
||||
#define metamacro_foreach_concat_iter(INDEX, BASE, ARG) metamacro_foreach_concat_iter_(BASE, ARG)
|
||||
#define metamacro_foreach_concat_iter_(BASE, ARG) BASE ## ARG
|
||||
|
||||
// metamacro_at expansions
|
||||
#define metamacro_at0(...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at1(_0, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at2(_0, _1, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at3(_0, _1, _2, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at4(_0, _1, _2, _3, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at5(_0, _1, _2, _3, _4, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at6(_0, _1, _2, _3, _4, _5, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at7(_0, _1, _2, _3, _4, _5, _6, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at8(_0, _1, _2, _3, _4, _5, _6, _7, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at9(_0, _1, _2, _3, _4, _5, _6, _7, _8, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at11(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at12(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at13(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at14(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at15(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at17(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at18(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at19(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, ...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_at20(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, ...) metamacro_head(__VA_ARGS__)
|
||||
|
||||
// metamacro_foreach_cxt expansions
|
||||
#define metamacro_foreach_cxt0(MACRO, SEP, CONTEXT)
|
||||
#define metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0)
|
||||
|
||||
#define metamacro_foreach_cxt2(MACRO, SEP, CONTEXT, _0, _1) \
|
||||
metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) \
|
||||
SEP \
|
||||
MACRO(1, CONTEXT, _1)
|
||||
|
||||
#define metamacro_foreach_cxt3(MACRO, SEP, CONTEXT, _0, _1, _2) \
|
||||
metamacro_foreach_cxt2(MACRO, SEP, CONTEXT, _0, _1) \
|
||||
SEP \
|
||||
MACRO(2, CONTEXT, _2)
|
||||
|
||||
#define metamacro_foreach_cxt4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
|
||||
metamacro_foreach_cxt3(MACRO, SEP, CONTEXT, _0, _1, _2) \
|
||||
SEP \
|
||||
MACRO(3, CONTEXT, _3)
|
||||
|
||||
#define metamacro_foreach_cxt5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
|
||||
metamacro_foreach_cxt4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
|
||||
SEP \
|
||||
MACRO(4, CONTEXT, _4)
|
||||
|
||||
#define metamacro_foreach_cxt6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
|
||||
metamacro_foreach_cxt5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
|
||||
SEP \
|
||||
MACRO(5, CONTEXT, _5)
|
||||
|
||||
#define metamacro_foreach_cxt7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
|
||||
metamacro_foreach_cxt6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
|
||||
SEP \
|
||||
MACRO(6, CONTEXT, _6)
|
||||
|
||||
#define metamacro_foreach_cxt8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
|
||||
metamacro_foreach_cxt7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
|
||||
SEP \
|
||||
MACRO(7, CONTEXT, _7)
|
||||
|
||||
#define metamacro_foreach_cxt9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
|
||||
metamacro_foreach_cxt8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
|
||||
SEP \
|
||||
MACRO(8, CONTEXT, _8)
|
||||
|
||||
#define metamacro_foreach_cxt10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
|
||||
metamacro_foreach_cxt9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
|
||||
SEP \
|
||||
MACRO(9, CONTEXT, _9)
|
||||
|
||||
#define metamacro_foreach_cxt11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
|
||||
metamacro_foreach_cxt10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
|
||||
SEP \
|
||||
MACRO(10, CONTEXT, _10)
|
||||
|
||||
#define metamacro_foreach_cxt12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
|
||||
metamacro_foreach_cxt11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
|
||||
SEP \
|
||||
MACRO(11, CONTEXT, _11)
|
||||
|
||||
#define metamacro_foreach_cxt13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
|
||||
metamacro_foreach_cxt12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
|
||||
SEP \
|
||||
MACRO(12, CONTEXT, _12)
|
||||
|
||||
#define metamacro_foreach_cxt14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
|
||||
metamacro_foreach_cxt13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
|
||||
SEP \
|
||||
MACRO(13, CONTEXT, _13)
|
||||
|
||||
#define metamacro_foreach_cxt15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
|
||||
metamacro_foreach_cxt14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
|
||||
SEP \
|
||||
MACRO(14, CONTEXT, _14)
|
||||
|
||||
#define metamacro_foreach_cxt16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
|
||||
metamacro_foreach_cxt15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
|
||||
SEP \
|
||||
MACRO(15, CONTEXT, _15)
|
||||
|
||||
#define metamacro_foreach_cxt17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
|
||||
metamacro_foreach_cxt16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
|
||||
SEP \
|
||||
MACRO(16, CONTEXT, _16)
|
||||
|
||||
#define metamacro_foreach_cxt18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
|
||||
metamacro_foreach_cxt17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
|
||||
SEP \
|
||||
MACRO(17, CONTEXT, _17)
|
||||
|
||||
#define metamacro_foreach_cxt19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
|
||||
metamacro_foreach_cxt18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
|
||||
SEP \
|
||||
MACRO(18, CONTEXT, _18)
|
||||
|
||||
#define metamacro_foreach_cxt20(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19) \
|
||||
metamacro_foreach_cxt19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
|
||||
SEP \
|
||||
MACRO(19, CONTEXT, _19)
|
||||
|
||||
// metamacro_foreach_cxt_recursive expansions
|
||||
#define metamacro_foreach_cxt_recursive0(MACRO, SEP, CONTEXT)
|
||||
#define metamacro_foreach_cxt_recursive1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive2(MACRO, SEP, CONTEXT, _0, _1) \
|
||||
metamacro_foreach_cxt_recursive1(MACRO, SEP, CONTEXT, _0) \
|
||||
SEP \
|
||||
MACRO(1, CONTEXT, _1)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive3(MACRO, SEP, CONTEXT, _0, _1, _2) \
|
||||
metamacro_foreach_cxt_recursive2(MACRO, SEP, CONTEXT, _0, _1) \
|
||||
SEP \
|
||||
MACRO(2, CONTEXT, _2)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
|
||||
metamacro_foreach_cxt_recursive3(MACRO, SEP, CONTEXT, _0, _1, _2) \
|
||||
SEP \
|
||||
MACRO(3, CONTEXT, _3)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
|
||||
metamacro_foreach_cxt_recursive4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
|
||||
SEP \
|
||||
MACRO(4, CONTEXT, _4)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
|
||||
metamacro_foreach_cxt_recursive5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
|
||||
SEP \
|
||||
MACRO(5, CONTEXT, _5)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
|
||||
metamacro_foreach_cxt_recursive6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
|
||||
SEP \
|
||||
MACRO(6, CONTEXT, _6)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
|
||||
metamacro_foreach_cxt_recursive7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
|
||||
SEP \
|
||||
MACRO(7, CONTEXT, _7)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
|
||||
metamacro_foreach_cxt_recursive8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
|
||||
SEP \
|
||||
MACRO(8, CONTEXT, _8)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
|
||||
metamacro_foreach_cxt_recursive9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
|
||||
SEP \
|
||||
MACRO(9, CONTEXT, _9)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
|
||||
metamacro_foreach_cxt_recursive10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
|
||||
SEP \
|
||||
MACRO(10, CONTEXT, _10)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
|
||||
metamacro_foreach_cxt_recursive11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
|
||||
SEP \
|
||||
MACRO(11, CONTEXT, _11)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
|
||||
metamacro_foreach_cxt_recursive12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
|
||||
SEP \
|
||||
MACRO(12, CONTEXT, _12)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
|
||||
metamacro_foreach_cxt_recursive13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
|
||||
SEP \
|
||||
MACRO(13, CONTEXT, _13)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
|
||||
metamacro_foreach_cxt_recursive14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
|
||||
SEP \
|
||||
MACRO(14, CONTEXT, _14)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
|
||||
metamacro_foreach_cxt_recursive15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
|
||||
SEP \
|
||||
MACRO(15, CONTEXT, _15)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
|
||||
metamacro_foreach_cxt_recursive16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
|
||||
SEP \
|
||||
MACRO(16, CONTEXT, _16)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
|
||||
metamacro_foreach_cxt_recursive17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
|
||||
SEP \
|
||||
MACRO(17, CONTEXT, _17)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
|
||||
metamacro_foreach_cxt_recursive18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
|
||||
SEP \
|
||||
MACRO(18, CONTEXT, _18)
|
||||
|
||||
#define metamacro_foreach_cxt_recursive20(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19) \
|
||||
metamacro_foreach_cxt_recursive19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
|
||||
SEP \
|
||||
MACRO(19, CONTEXT, _19)
|
||||
|
||||
// metamacro_for_cxt expansions
|
||||
#define metamacro_for_cxt0(MACRO, SEP, CONTEXT)
|
||||
#define metamacro_for_cxt1(MACRO, SEP, CONTEXT) MACRO(0, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt2(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt1(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(1, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt3(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt2(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(2, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt4(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt3(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(3, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt5(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt4(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(4, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt6(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt5(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(5, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt7(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt6(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(6, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt8(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt7(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(7, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt9(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt8(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(8, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt10(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt9(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(9, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt11(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt10(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(10, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt12(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt11(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(11, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt13(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt12(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(12, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt14(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt13(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(13, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt15(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt14(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(14, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt16(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt15(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(15, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt17(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt16(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(16, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt18(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt17(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(17, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt19(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt18(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(18, CONTEXT)
|
||||
|
||||
#define metamacro_for_cxt20(MACRO, SEP, CONTEXT) \
|
||||
metamacro_for_cxt19(MACRO, SEP, CONTEXT) \
|
||||
SEP \
|
||||
MACRO(19, CONTEXT)
|
||||
|
||||
// metamacro_if_eq expansions
|
||||
#define metamacro_if_eq0(VALUE) \
|
||||
metamacro_concat(metamacro_if_eq0_, VALUE)
|
||||
|
||||
#define metamacro_if_eq0_0(...) __VA_ARGS__ metamacro_consume_
|
||||
#define metamacro_if_eq0_1(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_2(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_3(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_4(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_5(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_6(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_7(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_8(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_9(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_10(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_11(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_12(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_13(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_14(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_15(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_16(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_17(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_18(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_19(...) metamacro_expand_
|
||||
#define metamacro_if_eq0_20(...) metamacro_expand_
|
||||
|
||||
#define metamacro_if_eq1(VALUE) metamacro_if_eq0(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq2(VALUE) metamacro_if_eq1(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq3(VALUE) metamacro_if_eq2(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq4(VALUE) metamacro_if_eq3(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq5(VALUE) metamacro_if_eq4(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq6(VALUE) metamacro_if_eq5(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq7(VALUE) metamacro_if_eq6(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq8(VALUE) metamacro_if_eq7(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq9(VALUE) metamacro_if_eq8(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq10(VALUE) metamacro_if_eq9(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq11(VALUE) metamacro_if_eq10(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq12(VALUE) metamacro_if_eq11(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq13(VALUE) metamacro_if_eq12(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq14(VALUE) metamacro_if_eq13(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq15(VALUE) metamacro_if_eq14(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq16(VALUE) metamacro_if_eq15(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq17(VALUE) metamacro_if_eq16(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq18(VALUE) metamacro_if_eq17(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq19(VALUE) metamacro_if_eq18(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq20(VALUE) metamacro_if_eq19(metamacro_dec(VALUE))
|
||||
|
||||
// metamacro_if_eq_recursive expansions
|
||||
#define metamacro_if_eq_recursive0(VALUE) \
|
||||
metamacro_concat(metamacro_if_eq_recursive0_, VALUE)
|
||||
|
||||
#define metamacro_if_eq_recursive0_0(...) __VA_ARGS__ metamacro_consume_
|
||||
#define metamacro_if_eq_recursive0_1(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_2(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_3(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_4(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_5(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_6(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_7(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_8(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_9(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_10(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_11(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_12(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_13(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_14(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_15(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_16(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_17(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_18(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_19(...) metamacro_expand_
|
||||
#define metamacro_if_eq_recursive0_20(...) metamacro_expand_
|
||||
|
||||
#define metamacro_if_eq_recursive1(VALUE) metamacro_if_eq_recursive0(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive2(VALUE) metamacro_if_eq_recursive1(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive3(VALUE) metamacro_if_eq_recursive2(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive4(VALUE) metamacro_if_eq_recursive3(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive5(VALUE) metamacro_if_eq_recursive4(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive6(VALUE) metamacro_if_eq_recursive5(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive7(VALUE) metamacro_if_eq_recursive6(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive8(VALUE) metamacro_if_eq_recursive7(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive9(VALUE) metamacro_if_eq_recursive8(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive10(VALUE) metamacro_if_eq_recursive9(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive11(VALUE) metamacro_if_eq_recursive10(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive12(VALUE) metamacro_if_eq_recursive11(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive13(VALUE) metamacro_if_eq_recursive12(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive14(VALUE) metamacro_if_eq_recursive13(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive15(VALUE) metamacro_if_eq_recursive14(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive16(VALUE) metamacro_if_eq_recursive15(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive17(VALUE) metamacro_if_eq_recursive16(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive18(VALUE) metamacro_if_eq_recursive17(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive19(VALUE) metamacro_if_eq_recursive18(metamacro_dec(VALUE))
|
||||
#define metamacro_if_eq_recursive20(VALUE) metamacro_if_eq_recursive19(metamacro_dec(VALUE))
|
||||
|
||||
// metamacro_take expansions
|
||||
#define metamacro_take0(...)
|
||||
#define metamacro_take1(...) metamacro_head(__VA_ARGS__)
|
||||
#define metamacro_take2(...) metamacro_head(__VA_ARGS__), metamacro_take1(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take3(...) metamacro_head(__VA_ARGS__), metamacro_take2(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take4(...) metamacro_head(__VA_ARGS__), metamacro_take3(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take5(...) metamacro_head(__VA_ARGS__), metamacro_take4(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take6(...) metamacro_head(__VA_ARGS__), metamacro_take5(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take7(...) metamacro_head(__VA_ARGS__), metamacro_take6(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take8(...) metamacro_head(__VA_ARGS__), metamacro_take7(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take9(...) metamacro_head(__VA_ARGS__), metamacro_take8(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take10(...) metamacro_head(__VA_ARGS__), metamacro_take9(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take11(...) metamacro_head(__VA_ARGS__), metamacro_take10(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take12(...) metamacro_head(__VA_ARGS__), metamacro_take11(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take13(...) metamacro_head(__VA_ARGS__), metamacro_take12(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take14(...) metamacro_head(__VA_ARGS__), metamacro_take13(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take15(...) metamacro_head(__VA_ARGS__), metamacro_take14(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take16(...) metamacro_head(__VA_ARGS__), metamacro_take15(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take17(...) metamacro_head(__VA_ARGS__), metamacro_take16(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take18(...) metamacro_head(__VA_ARGS__), metamacro_take17(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take19(...) metamacro_head(__VA_ARGS__), metamacro_take18(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_take20(...) metamacro_head(__VA_ARGS__), metamacro_take19(metamacro_tail(__VA_ARGS__))
|
||||
|
||||
// metamacro_drop expansions
|
||||
#define metamacro_drop0(...) __VA_ARGS__
|
||||
#define metamacro_drop1(...) metamacro_tail(__VA_ARGS__)
|
||||
#define metamacro_drop2(...) metamacro_drop1(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop3(...) metamacro_drop2(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop4(...) metamacro_drop3(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop5(...) metamacro_drop4(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop6(...) metamacro_drop5(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop7(...) metamacro_drop6(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop8(...) metamacro_drop7(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop9(...) metamacro_drop8(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop10(...) metamacro_drop9(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop11(...) metamacro_drop10(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop12(...) metamacro_drop11(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop13(...) metamacro_drop12(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop14(...) metamacro_drop13(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop15(...) metamacro_drop14(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop16(...) metamacro_drop15(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop17(...) metamacro_drop16(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop18(...) metamacro_drop17(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop19(...) metamacro_drop18(metamacro_tail(__VA_ARGS__))
|
||||
#define metamacro_drop20(...) metamacro_drop19(metamacro_tail(__VA_ARGS__))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
framework module DypaySDK {
|
||||
umbrella header "DypaySDK-umbrella.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
BIN
Binary file not shown.
+4
@@ -0,0 +1,4 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayDIRSFMDatabase.h"
|
||||
#import "DypayDIRSFMResultSet.h"
|
||||
#import "DypayDIRSFMDatabaseQueue.h"
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// DypayAPI.h
|
||||
// DypaySDK
|
||||
//
|
||||
// Created by xutianxi on 2021/12/10.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayErrorCode) {
|
||||
DypayErrorCodeSuccess = 0, // 成功
|
||||
DypayErrorCodeCancel = 1, // 用户取消
|
||||
DypayErrorCodeFail = 2, // 失败
|
||||
DypayErrorCodeProcessing = 3, // 支付结果处理中
|
||||
DypayErrorCodeVersionTooLow = 100, // 抖音版本过低,需要用户升级
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayLogLevel) {
|
||||
DypayLogLevelOff = 0,
|
||||
DypayLogLevelError = 1,
|
||||
DypayLogLevelWarn = 2,
|
||||
DypayLogLevelInfo = 3,
|
||||
DypayLogLevelDebug = 4,
|
||||
};
|
||||
|
||||
#define DYPAYSDK_TAG @"DypaySDK"
|
||||
|
||||
#define DYPAY_RECALL_API_MAX_TIME 3000 //毫秒级
|
||||
#define SHARED_SELF DypayAPI.sharedDypayAPI
|
||||
|
||||
@interface DypayAPI : NSObject
|
||||
|
||||
// 日志记录Block,可查看运行过程中的信息
|
||||
@property (nonatomic, copy) void(^logBlock)(DypayLogLevel level, NSTimeInterval timestamp, NSString *tag, NSString *message);
|
||||
|
||||
/**
|
||||
* 支付单例
|
||||
*
|
||||
* @return 返回单例对象
|
||||
*/
|
||||
+ (DypayAPI *)sharedDypayAPI;
|
||||
|
||||
/*
|
||||
* @param appId 从抖音商户平台申请的appId
|
||||
* @param scheme 从抖音回调当前 App 时使用的 scheme
|
||||
*/
|
||||
+ (void)registerWithAppID:(NSString *)appId
|
||||
callbackScheme:(NSString *)scheme;
|
||||
|
||||
/*
|
||||
* @param appId 从抖音商户平台申请的appId,优先使用universalLink,降级使用scheme
|
||||
* @param universalLink 从抖音回调当前 App 时使用的universalLink
|
||||
* @param scheme 从抖音回调当前 App 时使用的 scheme
|
||||
*/
|
||||
+ (void)registerWithAppID:(NSString *)appId
|
||||
universalLink:(NSString *)universalLink
|
||||
callbackScheme:(NSString *)scheme;
|
||||
|
||||
/*
|
||||
* 判断是否能打开 Dypay
|
||||
*/
|
||||
+ (bool)canOpenDypay;
|
||||
|
||||
/*
|
||||
* @brief 打开 Dypay, 打开成功后马上回调 completionBlock,
|
||||
* @param infoDict 拉起抖音支付必须的订单参数
|
||||
* @param currentTopViewController 拉起抖音支付时顶部的vc
|
||||
* @param callback 调用结果的回调
|
||||
*/
|
||||
+ (void)openDypayWithInfo:(NSDictionary *)infoDict
|
||||
fromViewController:(UIViewController *)currentTopViewController
|
||||
callback:(void(^)(BOOL isOpenedSuccessed, NSString *errMsg))completionBlock DEPRECATED_MSG_ATTRIBUTE("call openDypayWithInfo:fromViewController:resultCallback instead");
|
||||
|
||||
|
||||
/*
|
||||
* @brief 打开 Dypay,唤端之前:支付结果会通过该API的resultCallback参数回调,唤端之后:支付结果通过processDypayResultWithURL的callback回调
|
||||
* @param infoDict 拉起抖音支付必须的订单参数
|
||||
* @param currentTopViewController 拉起抖音支付时顶部的vc
|
||||
* @param resultCallback 支付结果的回调,resultCode枚举参照processDypayResultWithURL注释
|
||||
*/
|
||||
+ (void)openDypayWithInfo:(NSDictionary *)infoDict
|
||||
fromViewController:(UIViewController *)currentTopViewController
|
||||
resultCallback:(void(^)(NSDictionary *resultDict))resultCompletionBlock;
|
||||
|
||||
/*
|
||||
* 处理通过URL支付回调结果
|
||||
* resultDict 包含支付结果错误码信息,如果为nil也表示处理失败。
|
||||
字典中,key: "resultStatus"对应老的错误码定义,将逐步废弃;请使用新key: "resultCode"对应的错误码定义。
|
||||
老key: resultStatus,对应的错误码定义:
|
||||
-1 未知
|
||||
0 订单支付成功
|
||||
10 用户中途取消
|
||||
20 正在处理中
|
||||
30 版本过低
|
||||
40 失败
|
||||
50 超时
|
||||
新key: resultCode,对应的错误码定义
|
||||
DypayErrorCodeSuccess(0) 成功
|
||||
DypayErrorCodeCancel(1) 用户取消
|
||||
DypayErrorCodeFail(2) 失败
|
||||
DypayErrorCodeProcessing(3) 支付结果处理中
|
||||
DypayErrorCodeVersionTooLow(100) 抖音版本过低,需要用户升级
|
||||
*/
|
||||
+ (BOOL)processDypayResultWithURL:(NSURL *)url
|
||||
callback:(void(^)(NSDictionary * _Nullable resultDict))completionBlock;
|
||||
|
||||
/*
|
||||
* 处理通过Universal Link支付回调结果
|
||||
* resultDict 包含支付结果错误码信息,如果为nil也表示处理失败。
|
||||
字典中,key: "resultStatus"对应老的错误码定义,将逐步废弃;请使用新key: "resultCode"对应的错误码定义。
|
||||
老key: resultStatus,对应的错误码定义:
|
||||
-1 未知
|
||||
0 订单支付成功
|
||||
10 用户中途取消
|
||||
20 正在处理中
|
||||
30 版本过低
|
||||
40 失败
|
||||
50 超时
|
||||
新key: resultCode,对应的错误码定义
|
||||
DypayErrorCodeSuccess(0) 成功
|
||||
DypayErrorCodeCancel(1) 用户取消
|
||||
DypayErrorCodeFail(2) 失败
|
||||
DypayErrorCodeProcessing(3) 支付结果处理中
|
||||
DypayErrorCodeVersionTooLow(100) 抖音版本过低,需要用户升级
|
||||
*/
|
||||
+ (BOOL)processDypayResultWithUserActivity:(NSUserActivity *)userActivity
|
||||
callback:(void(^)(NSDictionary *resultDict))completionBlock;
|
||||
|
||||
/*! @brief 获取当前 DypaySDK API 的版本号
|
||||
*/
|
||||
+ (NSString *)getAPIVersion;
|
||||
|
||||
/*
|
||||
* 埋点
|
||||
*/
|
||||
+ (void)event:(NSString *_Nonnull)eventName params:(NSDictionary *_Nullable)params;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// 内部接口,字节外部App不应使用
|
||||
@interface DypayAPI (Internal)
|
||||
// 业务埋点上报Block,字节内部App使用时设置
|
||||
@property (nonatomic, copy) void(^trackEventBlock)(NSString *event, NSDictionary *params);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// DypayDIRSApplication.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, DypayIRISApplicationState) {
|
||||
DypayIRISApplicationStateUnknown = 0,
|
||||
DypayIRISApplicationStateActive,
|
||||
DypayIRISApplicationStateInactive,
|
||||
DypayIRISApplicationStateBackground
|
||||
};
|
||||
|
||||
|
||||
@interface DypayDIRSApplication : NSObject
|
||||
|
||||
@property (readonly, nonnull) NSString *launchID;
|
||||
@property (readonly, assign) NSTimeInterval launchTime;
|
||||
|
||||
@property (readonly) DypayIRISApplicationState applicationState;
|
||||
|
||||
+ (instancetype)sharedApplication;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// DypayDIRSBasicFeatureOptions.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/11/9.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSBasicFeatureOptions : DypayDIRSBasicModule
|
||||
|
||||
- (void)addFeatureOptions:(NSDictionary *)opts;
|
||||
|
||||
- (void)removeFeatureOptionsKeys:(NSArray *)keys;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// DypayDIRSBasicModule.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
#import "DypayIRISMacro.h"
|
||||
#import "DypayDIRSContext.h"
|
||||
#import "DypayDIRSModuleHive.h"
|
||||
#import "IRSLOG.h"
|
||||
#import "DypayDataIRIS.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class DypayDIRSContext;
|
||||
@interface DypayDIRSBasicModule : NSObject<DypayIRISModule>
|
||||
|
||||
@property (nonatomic, weak) DypayDIRSContext* context;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString* category;
|
||||
|
||||
@property BOOL isEnabled;
|
||||
@property DypayIRISState state;
|
||||
|
||||
- (void)onLaunch;
|
||||
|
||||
- (void)run;
|
||||
|
||||
- (void)stop;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSCompressionGzipPlugin.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/9.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSCompressionGzipPlugin : DypayDIRSBasicModule<DypayIRISModuleGlobal, DypayIRISDataCoder>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// DypayDIRSConcurrentCollection.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSConcurrentCollection<T> : NSObject
|
||||
|
||||
+ (instancetype)collectionWithRaw:(T)collection;
|
||||
|
||||
- (void)operate:(void (^)(T raw))operation;
|
||||
|
||||
- (nullable id)access:(nullable id (^)(T raw))operation;
|
||||
|
||||
- (T)rawValue;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// DypayDIRSConfig.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "DypayIRISDefines.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSComplianceConfiguration,DypayDIRSEventConfiguration,DypayDIRSObserver,DypayDIRSEventUploadFilterOptions;
|
||||
|
||||
@interface DypayDIRSConfig : NSObject
|
||||
|
||||
+ (instancetype _Nullable)configWithIdentifier:(NSString *_Nonnull)appId
|
||||
launchOptions:(nullable NSDictionary *)launchOptions;
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *appId;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *appName;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *appVersion;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *buildVersion;
|
||||
|
||||
//If you need to synchronize data between HostApp and ExtensionApp, you need to set the same groupId
|
||||
@property (nullable, nonatomic, copy) NSString *appGroupId;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString *channel;
|
||||
|
||||
//be able to distinguish between different instances using the same appid
|
||||
@property (nullable, nonatomic, copy) NSString *subId;
|
||||
|
||||
@property (nonatomic, strong ) NSDictionary *launchOptions;
|
||||
|
||||
@property (nonatomic, assign) BOOL encryptionEnabled;
|
||||
|
||||
@property (nullable, nonatomic, strong) id<DypayIRISEndpoint> endpoint;
|
||||
|
||||
///The default log level is Error
|
||||
@property (nonatomic, assign) DypayIRISLOG_LEVEL logLevel;
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^configureUserLoggerBlock)(id<DypayIRISLog> _Nullable log);
|
||||
|
||||
@property (nullable, readonly) DypayDIRSComplianceConfiguration* compliance;
|
||||
|
||||
@property (nullable, readonly) DypayDIRSEventConfiguration* event;
|
||||
|
||||
@property (nullable, readonly) DypayDIRSObserver *observer;
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString*, NSString *> *_Nullable (^configureHTTPHeaderFieldsBlock)(NSUInteger service);
|
||||
|
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString*, id> *_Nullable (^configureCommonParametersBlock)(NSUInteger service);
|
||||
|
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString*, id> *_Nullable (^configureCustomHeaderBlock)(NSUInteger service);
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^onError)(BOOL fatal, NSError * _Nonnull error, id _Nullable userInfo);
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSComplianceConfiguration : NSObject
|
||||
|
||||
/**
|
||||
* @brief fields to avoid access
|
||||
*
|
||||
* @discussion Fields set in @c blockedFiels will not be accessed and uploaded.
|
||||
* For example, if you you do not want to collect @c vendor_id, set the following code block, then @c UIDevice.identifierForVendor will not be accessed, and the field @c vendor_id will not appear in any HTTPBODY
|
||||
*
|
||||
* @code
|
||||
* config.compliance.blockedFields = @[@"vendor_id"];
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) NSArray *blockedFields;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSEventConfiguration : NSObject
|
||||
|
||||
/*
|
||||
* Intercept or change events before they are stored
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) void (^configureEventInterceptorBlock)(id<DypayIRISEvent> _Nullable event, BOOL * _Nonnull stop);
|
||||
|
||||
/*
|
||||
* Filter events before packaging
|
||||
*
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) _Nullable id (^configurePreBatchFilterBlock)(id _Nullable context);
|
||||
|
||||
|
||||
@property (nullable, nonatomic, copy) _Nullable id (^configureEventPacketBlock)(id<DypayIRISEvent> _Nullable event, BOOL * _Nonnull stop);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Event expiration time [Unit:seconds]
|
||||
* Data will be cleaned based on expiration time every time on startup
|
||||
* Setting it to 0 will not clean up the data.
|
||||
*
|
||||
* Default is 0
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger eventExpirationTime;
|
||||
|
||||
|
||||
/*
|
||||
* - DypayIRISEventPacketStrategyDefault
|
||||
* Packaging based on the upper limit of the number of events, The number of upper limit can be set through maxPacketEventCount, the default is 200
|
||||
* - DypayIRISEventPacketStrategyByteLimitation
|
||||
* Packing based on the upper limit of data length, The length can be set through maxPacketBytes, the default is 1024*1024
|
||||
*
|
||||
* Default is DypayIRISEventPacketStrategyDefault
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) DypayIRISEventPacketStrategy packetStrategy;
|
||||
|
||||
/*
|
||||
*
|
||||
* Default is 200
|
||||
* takes effect when setting config.event.packetStrategy = DypayIRISEventPacketStrategyDefault
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxPacketEventCount;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Default is 1m
|
||||
* takes effect when setting config.event.packetStrategy = DypayIRISEventPacketStrategyByteLimitation
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxPacketBytes;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Default is 500m, some(25%) earliest events will be deleted when the maximum limit is exceeded on startup
|
||||
|
||||
When an error occurs in the data file and the size of the database file cannot be successfully reduced
|
||||
in order to avoid affecting the stability of the application,
|
||||
the database file will be removed as a whole, which will cause events loss
|
||||
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxFileBytes;
|
||||
|
||||
/*
|
||||
* Maximum length after serialization
|
||||
* default 20*1024;
|
||||
*
|
||||
* @NOT take effect yet
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger maxPropertyBytes;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventUploadFilterOptions : NSObject
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray<NSString *> *regionKeys;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray<NSString *> *includeTypes;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSArray<NSString *> *excludeTypes;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSObserver : NSObject
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^onSessionLaunch)(NSString *sessionId, id _Nullable info);
|
||||
|
||||
@property (nullable, nonatomic, copy) void (^onSessionTerminate)(NSString *sessionId, id _Nullable info);
|
||||
|
||||
@end
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// DypayDIRSContext.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSConfig,DypayDIRSLogger,DypayDIRSModuleHive;
|
||||
@interface DypayDIRSContext : NSObject
|
||||
|
||||
@property (nonatomic, readonly) DypayDIRSModuleHive* modular;
|
||||
|
||||
@property (readonly, nullable) DypayDIRSConfig *config;
|
||||
|
||||
@property (readonly, nonnull) NSString *name;
|
||||
|
||||
+ (instancetype)main;
|
||||
|
||||
+ (void)configure:(DypayDIRSConfig *)config;
|
||||
|
||||
- (instancetype)initWithConfig:(DypayDIRSConfig *)config;
|
||||
|
||||
- (BOOL)resume;
|
||||
|
||||
- (void)suspend;
|
||||
|
||||
- (nonnull NSString *)contextPath;
|
||||
|
||||
- (void)async:(dispatch_block_t)block;
|
||||
|
||||
- (nonnull NSDictionary *)contextInfo;
|
||||
|
||||
- (void)dispose;
|
||||
|
||||
- (BOOL)isMainContext;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSContext (Instance)
|
||||
|
||||
+ (NSArray<DypayDIRSContext *> *)ctx_all;
|
||||
|
||||
+ (nullable DypayDIRSContext *)ctx_get:(NSString *)name;
|
||||
|
||||
+ (void)ctx_add:(DypayDIRSContext *)context;
|
||||
|
||||
+ (void)ctx_remove:(DypayDIRSContext *)context;
|
||||
|
||||
@end
|
||||
|
||||
@interface DypayDIRSContext (Modules)
|
||||
|
||||
@property (nullable, nonatomic, readonly) DypayDIRSLogger *logger;
|
||||
|
||||
- (nullable NSDictionary *)modules;
|
||||
|
||||
+ (NSDictionary *)defaultModules;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// DypayDIRSEndpointConfiguration.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/24.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEndpointConfiguration : NSObject<DypayIRISEndpoint>
|
||||
|
||||
@property (nullable, nonatomic, copy) id _Nullable (^domainBlock)(NSUInteger service, id context);
|
||||
|
||||
@property (nullable, nonatomic, copy) id _Nullable (^endpointBlock)(NSUInteger service, id context);
|
||||
|
||||
+ (DypayDIRSEndpointConfiguration *)configurationUsingBlock:(nonnull id (^)(NSUInteger service, id context))block;
|
||||
|
||||
+ (DypayDIRSEndpointConfiguration *)configurationUsingDomainBlock:(nonnull id (^)(NSUInteger service, id context))block;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// DypayDIRSEnviroment.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/25.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEnviroment : DypayDIRSBasicModule<DypayIRISParameterHandler,DypayIRISModuleGlobal>
|
||||
|
||||
+ (NSInteger)sdkVersion;
|
||||
|
||||
+ (NSString *)sdkVersionString;
|
||||
|
||||
+ (NSString *)osName;
|
||||
|
||||
+ (NSString *)osVersion;
|
||||
|
||||
+ (NSString *)platform;
|
||||
|
||||
+ (NSString *)appVersion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// DypayDIRSErrorBuilder.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSErrorBuilder : NSObject
|
||||
|
||||
+ (instancetype)builder;
|
||||
|
||||
- (instancetype)withDomain:(NSErrorDomain)code;
|
||||
|
||||
- (instancetype)withCode:(NSUInteger)code;
|
||||
|
||||
- (instancetype)withDescription:(NSString *)description;
|
||||
|
||||
- (instancetype)withDescriptionFormat:(NSString *)format, ...;
|
||||
|
||||
- (instancetype)withFailureReason:(NSString *)reason;
|
||||
|
||||
- (instancetype)withUnderlyingError:(NSError *)error;
|
||||
|
||||
- (NSError *)build;
|
||||
|
||||
- (BOOL)buildError:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// DypayDIRSEvent.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DypayIRISDefinesPrivate.h"
|
||||
|
||||
|
||||
|
||||
typedef NSString * DypayIRISEventType;
|
||||
|
||||
FOUNDATION_EXTERN DypayIRISEventType const _Nonnull DypayDIRSEventTypeV3; //event_v3
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class DypayDIRSEventOptions;
|
||||
@interface DypayDIRSEvent : NSObject<DypayIRISEvent, NSCoding>
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * key;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * type;
|
||||
|
||||
@property (nonatomic) NSTimeInterval time;
|
||||
@property (nonatomic) NSTimeInterval storedTime;
|
||||
@property (nonatomic) NSTimeInterval batchedTime;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary * properties;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary * globalProperties;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary * commonParameters;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSString * logID;
|
||||
|
||||
@property (nullable, nonatomic, copy) NSNumber* dbIndex;
|
||||
|
||||
@property (nonatomic, assign) int64_t index;
|
||||
|
||||
@property (nonatomic, copy) NSString* section;
|
||||
|
||||
@property (nullable, nonatomic) id schemaObject;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger schemaDataLength;
|
||||
|
||||
@property (nonatomic, strong) DypayDIRSEventOptions * options;
|
||||
|
||||
@property (nonatomic, assign) BOOL stained;
|
||||
|
||||
//return event_id if event stained
|
||||
- (int64_t)staining;
|
||||
|
||||
- (NSString *)sessionId;
|
||||
|
||||
- (void)addCommonParameters:(NSDictionary *)parameters;
|
||||
|
||||
|
||||
+ (nullable instancetype)eventWithType:(DypayIRISEventType _Nonnull)type
|
||||
properties:(NSDictionary * _Nullable)properties;
|
||||
|
||||
|
||||
+ (nullable instancetype)v3UsingKey:(NSString * _Nonnull)key
|
||||
properties:(NSDictionary * _Nullable)properties;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface DypayDIRSEventOptions : NSObject
|
||||
|
||||
@property (nonatomic, assign) NSInteger category;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISPriority priority;
|
||||
|
||||
@property (nullable ,nonatomic, copy) NSString * regionKey;
|
||||
|
||||
@property (nonatomic, assign) NSInteger privacyLevel;
|
||||
|
||||
@property (nonatomic, assign) BOOL filtered;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventBatchOptions : NSObject
|
||||
|
||||
@property (nonatomic, assign) NSInteger priority;
|
||||
|
||||
@property (nullable, nonatomic) NSArray * eventIDs;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger count;
|
||||
|
||||
@property (nonatomic, strong) NSArray * allowRegionList;
|
||||
|
||||
@property (nonatomic, assign) NSInteger minDBIndex;
|
||||
|
||||
@property (nonatomic, assign) NSInteger maxDBIndex;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// DypayDIRSEventUploadDispatcher.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface DypayDIRSEventBatchDispatcher : DypayDIRSBasicModule
|
||||
|
||||
@property (nonatomic, readonly) id<DypayIRISServiceSchema> schema;
|
||||
|
||||
@property (readonly) id<DypayIRISEventUploadExecutor> defaultUploader;
|
||||
|
||||
@property (readonly) id<DypayIRISEventUploadExecutor> realtimeUploader;
|
||||
|
||||
- (nullable id<DypayIRISEventUploadExecutor>)createExecutor;
|
||||
|
||||
- (nullable NSArray<DypayIRISEventUploadExecutor> *)allExecutors;
|
||||
|
||||
- (nonnull dispatch_queue_t)intervalBatchQueue;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// DypayDIRSEventUploadExecutor.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayIRISInterfaceDefines.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventBatchExecutor : DypayDIRSBasicModule<DypayIRISEventUploadExecutor>
|
||||
|
||||
@property (nonatomic, assign) NSTimeInterval interval;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISServiceSchema> serializer;
|
||||
|
||||
@property (nullable, nonatomic) NSArray<id<DypayIRISDataCoder>> *compressors;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> encryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISDataCoder> decryptor;
|
||||
|
||||
@property (nullable, nonatomic, weak) id<DypayIRISEventStore> eventStore;
|
||||
|
||||
@property (nullable, nonatomic) id<DypayIRISThrottlter> throttlter;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISPriority priority;
|
||||
|
||||
@property (nonatomic, assign) DypayIRISState execState;
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary *options;
|
||||
|
||||
|
||||
/*
|
||||
* @opts
|
||||
* DypayIRISBatchOptionsEnforceKey - enforce batch YES|NO
|
||||
*
|
||||
*/
|
||||
//- (void)executeUpload:(DypayIRISBatchTrigger)trigger
|
||||
// options:(nullable NSDictionary *)opts
|
||||
// completion:(void (^ __nullable)(BOOL success, NSError* _Nullable error))completion;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSEventBlockPlugin.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/25.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventBlockPlugin : DypayDIRSBasicModule
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// DypayDIRSEventEntry.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/13.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventEntry : DypayDIRSBasicModule<DypayIRISModule, DypayIRISTracker>
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// DypayDIRSEventListener.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/8/14.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventListener : DypayDIRSBasicModule
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// DypayDIRSEventPacker.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventPacker : NSObject<DypayIRISEventPacker>
|
||||
|
||||
@property (nonatomic, assign) NSUInteger maxPackLength;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger maxEventCount;
|
||||
|
||||
@property (nonatomic, assign) NSInteger strategy;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// DypayDIRSEventRequestSchema.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/18.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
#import "DypayDIRSEventPacker.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventRequestSchema : DypayDIRSBasicModule<DypayIRISServiceSchema,DypayIRISModuleGlobal>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface DypayDIRSEventRealtimeRequestSchema : DypayDIRSEventRequestSchema<DypayIRISServiceSchema, DypayIRISModuleGlobal>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DypayDIRSEventSerializer.h
|
||||
// DypayDataIRIS
|
||||
//
|
||||
// Created by ByteDance on 2023/7/14.
|
||||
//
|
||||
|
||||
#import "DypayDIRSBasicModule.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DypayDIRSEventSerializer : DypayDIRSBasicModule<DypayIRISEventSerializer>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user