@arcote.tech/arc-adapter-db-sqlite-wasm 0.4.9 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +451 -1
- package/dist/worker.js +27 -27
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../../../node_modules/mutative/dist/mutative.esm.mjs
|
|
1
|
+
// ../../../../node_modules/.bun/mutative@1.3.0/node_modules/mutative/dist/mutative.esm.mjs
|
|
2
2
|
var Operation = {
|
|
3
3
|
Remove: "remove",
|
|
4
4
|
Replace: "replace",
|
|
@@ -2826,6 +2826,147 @@ class ArcEvent extends ArcContextElement {
|
|
|
2826
2826
|
return ArcEvent.sharedDatabaseStoreSchema();
|
|
2827
2827
|
}
|
|
2828
2828
|
}
|
|
2829
|
+
function buildElementContext(queryElements, mutationElements, adapters) {
|
|
2830
|
+
const queryMap = new Map;
|
|
2831
|
+
const mutateMap = new Map;
|
|
2832
|
+
const queryProps = {};
|
|
2833
|
+
for (const element of queryElements) {
|
|
2834
|
+
if (element.queryContext) {
|
|
2835
|
+
const ctx = element.queryContext(adapters);
|
|
2836
|
+
queryProps[element.name] = ctx;
|
|
2837
|
+
queryMap.set(element, ctx);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
const mutateProps = {};
|
|
2841
|
+
for (const element of mutationElements) {
|
|
2842
|
+
if (element.mutateContext) {
|
|
2843
|
+
const ctx = element.mutateContext(adapters);
|
|
2844
|
+
mutateProps[element.name] = ctx;
|
|
2845
|
+
mutateMap.set(element, ctx);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
const queryFn = (element) => {
|
|
2849
|
+
const cached = queryMap.get(element);
|
|
2850
|
+
if (cached)
|
|
2851
|
+
return cached;
|
|
2852
|
+
if (element.queryContext) {
|
|
2853
|
+
const ctx = element.queryContext(adapters);
|
|
2854
|
+
queryMap.set(element, ctx);
|
|
2855
|
+
return ctx;
|
|
2856
|
+
}
|
|
2857
|
+
throw new Error(`Element "${element.name}" has no queryContext`);
|
|
2858
|
+
};
|
|
2859
|
+
Object.assign(queryFn, queryProps);
|
|
2860
|
+
const mutateFn = (element) => {
|
|
2861
|
+
const cached = mutateMap.get(element);
|
|
2862
|
+
if (cached)
|
|
2863
|
+
return cached;
|
|
2864
|
+
if (element.mutateContext) {
|
|
2865
|
+
const ctx = element.mutateContext(adapters);
|
|
2866
|
+
mutateMap.set(element, ctx);
|
|
2867
|
+
return ctx;
|
|
2868
|
+
}
|
|
2869
|
+
throw new Error(`Element "${element.name}" has no mutateContext`);
|
|
2870
|
+
};
|
|
2871
|
+
Object.assign(mutateFn, mutateProps);
|
|
2872
|
+
return {
|
|
2873
|
+
query: queryFn,
|
|
2874
|
+
mutate: mutateFn
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
class ArcFunction {
|
|
2879
|
+
data;
|
|
2880
|
+
constructor(data) {
|
|
2881
|
+
this.data = data;
|
|
2882
|
+
}
|
|
2883
|
+
withParams(schema) {
|
|
2884
|
+
return new ArcFunction({
|
|
2885
|
+
...this.data,
|
|
2886
|
+
params: schema instanceof ArcObject ? schema : new ArcObject(schema)
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
withResult(schema) {
|
|
2890
|
+
return new ArcFunction({
|
|
2891
|
+
...this.data,
|
|
2892
|
+
result: schema instanceof ArcObject ? schema : new ArcObject(schema)
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
query(elements) {
|
|
2896
|
+
return new ArcFunction({
|
|
2897
|
+
...this.data,
|
|
2898
|
+
queryElements: elements
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
mutate(elements) {
|
|
2902
|
+
return new ArcFunction({
|
|
2903
|
+
...this.data,
|
|
2904
|
+
mutationElements: elements
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
protectedBy(token, check) {
|
|
2908
|
+
const existingProtections = this.data.protections || [];
|
|
2909
|
+
return new ArcFunction({
|
|
2910
|
+
...this.data,
|
|
2911
|
+
protections: [...existingProtections, { token, check }]
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
description(desc) {
|
|
2915
|
+
return new ArcFunction({
|
|
2916
|
+
...this.data,
|
|
2917
|
+
description: desc
|
|
2918
|
+
});
|
|
2919
|
+
}
|
|
2920
|
+
handle(handler) {
|
|
2921
|
+
return new ArcFunction({
|
|
2922
|
+
...this.data,
|
|
2923
|
+
handler
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
get isPublic() {
|
|
2927
|
+
return !this.hasProtections;
|
|
2928
|
+
}
|
|
2929
|
+
get hasProtections() {
|
|
2930
|
+
return (this.data.protections?.length ?? 0) > 0;
|
|
2931
|
+
}
|
|
2932
|
+
get protections() {
|
|
2933
|
+
return this.data.protections || [];
|
|
2934
|
+
}
|
|
2935
|
+
get handler() {
|
|
2936
|
+
return this.data.handler;
|
|
2937
|
+
}
|
|
2938
|
+
get params() {
|
|
2939
|
+
return this.data.params;
|
|
2940
|
+
}
|
|
2941
|
+
get result() {
|
|
2942
|
+
return this.data.result;
|
|
2943
|
+
}
|
|
2944
|
+
async verifyProtections(tokens) {
|
|
2945
|
+
if (!this.data.protections || this.data.protections.length === 0) {
|
|
2946
|
+
return true;
|
|
2947
|
+
}
|
|
2948
|
+
for (const protection of this.data.protections) {
|
|
2949
|
+
const tokenInstance = tokens.find((t) => t.getTokenDefinition() === protection.token);
|
|
2950
|
+
if (!tokenInstance) {
|
|
2951
|
+
return false;
|
|
2952
|
+
}
|
|
2953
|
+
const result = await protection.check(tokenInstance);
|
|
2954
|
+
if (result === false) {
|
|
2955
|
+
return false;
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
return true;
|
|
2959
|
+
}
|
|
2960
|
+
buildContext(adapters) {
|
|
2961
|
+
return buildElementContext(this.data.queryElements || [], this.data.mutationElements || [], adapters);
|
|
2962
|
+
}
|
|
2963
|
+
toJsonSchema() {
|
|
2964
|
+
return {
|
|
2965
|
+
params: this.data.params?.toJsonSchema?.() ?? null,
|
|
2966
|
+
result: this.data.result?.toJsonSchema?.() ?? null
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2829
2970
|
class AggregateBase {
|
|
2830
2971
|
value;
|
|
2831
2972
|
_id;
|
|
@@ -2863,6 +3004,315 @@ class AggregateBase {
|
|
|
2863
3004
|
return result;
|
|
2864
3005
|
}
|
|
2865
3006
|
}
|
|
3007
|
+
class ArcCommand extends ArcContextElement {
|
|
3008
|
+
data;
|
|
3009
|
+
#fn;
|
|
3010
|
+
constructor(data, fn) {
|
|
3011
|
+
super(data.name);
|
|
3012
|
+
this.data = data;
|
|
3013
|
+
this.#fn = fn ?? new ArcFunction({
|
|
3014
|
+
params: data.params,
|
|
3015
|
+
result: null,
|
|
3016
|
+
queryElements: data.queryElements,
|
|
3017
|
+
mutationElements: data.mutationElements,
|
|
3018
|
+
protections: data.protections || [],
|
|
3019
|
+
handler: data.handler ?? null,
|
|
3020
|
+
description: data.description
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
description(description) {
|
|
3024
|
+
const newFn = this.#fn.description(description);
|
|
3025
|
+
return new ArcCommand({ ...this.data, description }, newFn);
|
|
3026
|
+
}
|
|
3027
|
+
get isPublic() {
|
|
3028
|
+
return this.#fn.isPublic;
|
|
3029
|
+
}
|
|
3030
|
+
query(elements) {
|
|
3031
|
+
const newFn = this.#fn.query(elements);
|
|
3032
|
+
return new ArcCommand({ ...this.data, queryElements: elements }, newFn);
|
|
3033
|
+
}
|
|
3034
|
+
mutate(elements) {
|
|
3035
|
+
const newFn = this.#fn.mutate(elements);
|
|
3036
|
+
return new ArcCommand({ ...this.data, mutationElements: elements }, newFn);
|
|
3037
|
+
}
|
|
3038
|
+
withParams(schema) {
|
|
3039
|
+
const newFn = this.#fn.withParams(schema);
|
|
3040
|
+
return new ArcCommand({
|
|
3041
|
+
...this.data,
|
|
3042
|
+
params: schema instanceof ArcObject ? schema : new ArcObject(schema)
|
|
3043
|
+
}, newFn);
|
|
3044
|
+
}
|
|
3045
|
+
withResult(...schemas) {
|
|
3046
|
+
return new ArcCommand({ ...this.data, results: schemas }, this.#fn);
|
|
3047
|
+
}
|
|
3048
|
+
handle(handler) {
|
|
3049
|
+
const newFn = new ArcFunction({
|
|
3050
|
+
...this.#fn.data,
|
|
3051
|
+
handler
|
|
3052
|
+
});
|
|
3053
|
+
return new ArcCommand({ ...this.data, handler }, newFn);
|
|
3054
|
+
}
|
|
3055
|
+
protectBy(token, check) {
|
|
3056
|
+
const newFn = this.#fn.protectedBy(token, check);
|
|
3057
|
+
const existingProtections = this.data.protections || [];
|
|
3058
|
+
return new ArcCommand({
|
|
3059
|
+
...this.data,
|
|
3060
|
+
protections: [...existingProtections, { token, check }]
|
|
3061
|
+
}, newFn);
|
|
3062
|
+
}
|
|
3063
|
+
get hasProtections() {
|
|
3064
|
+
return this.#fn.hasProtections;
|
|
3065
|
+
}
|
|
3066
|
+
get protections() {
|
|
3067
|
+
return this.#fn.protections;
|
|
3068
|
+
}
|
|
3069
|
+
async verifyProtections(tokens) {
|
|
3070
|
+
return this.#fn.verifyProtections(tokens);
|
|
3071
|
+
}
|
|
3072
|
+
async init(environment, adapters) {
|
|
3073
|
+
if (environment === "server" && this.data.handler && adapters.commandWire?.registerCommandHandler) {
|
|
3074
|
+
adapters.commandWire.registerCommandHandler(this.data.name, async (params) => {
|
|
3075
|
+
const executeFunc = this.mutateContext(adapters);
|
|
3076
|
+
return await executeFunc(params);
|
|
3077
|
+
});
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
mutateContext(adapters) {
|
|
3081
|
+
const executeFunc = async (params) => {
|
|
3082
|
+
if (this.data.handler) {
|
|
3083
|
+
return await this.executeLocally(params, adapters);
|
|
3084
|
+
}
|
|
3085
|
+
if (!adapters.commandWire) {
|
|
3086
|
+
throw new Error(`Command "${this.data.name}" has no handler and no commandWire adapter available for remote execution`);
|
|
3087
|
+
}
|
|
3088
|
+
return await adapters.commandWire.executeCommand(this.data.name, params);
|
|
3089
|
+
};
|
|
3090
|
+
return Object.assign(executeFunc, { params: this.data.params });
|
|
3091
|
+
}
|
|
3092
|
+
async executeLocally(params, adapters) {
|
|
3093
|
+
if (!this.data.handler) {
|
|
3094
|
+
throw new Error(`Command "${this.data.name}" has no handler`);
|
|
3095
|
+
}
|
|
3096
|
+
const context2 = this.buildCommandContext(adapters);
|
|
3097
|
+
return await this.data.handler(context2, params);
|
|
3098
|
+
}
|
|
3099
|
+
buildCommandContext(adapters) {
|
|
3100
|
+
const context2 = this.#fn.buildContext(adapters);
|
|
3101
|
+
if (this.#fn.hasProtections && adapters.authAdapter) {
|
|
3102
|
+
const decoded = adapters.authAdapter.getDecoded();
|
|
3103
|
+
if (decoded) {
|
|
3104
|
+
context2.$auth = {
|
|
3105
|
+
params: decoded.params,
|
|
3106
|
+
tokenName: decoded.tokenName
|
|
3107
|
+
};
|
|
3108
|
+
} else {
|
|
3109
|
+
throw new Error(`Command "${this.data.name}" requires authentication but no valid token found`);
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
return context2;
|
|
3113
|
+
}
|
|
3114
|
+
toJsonSchema() {
|
|
3115
|
+
const parametersSchema = this.data.params ? this.data.params.toJsonSchema?.() ?? {
|
|
3116
|
+
type: "object",
|
|
3117
|
+
properties: {}
|
|
3118
|
+
} : { type: "object", properties: {} };
|
|
3119
|
+
return {
|
|
3120
|
+
type: "function",
|
|
3121
|
+
name: this.data.name,
|
|
3122
|
+
description: this.data.description ?? undefined,
|
|
3123
|
+
parameters: parametersSchema,
|
|
3124
|
+
strict: true
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
class ArcListener extends ArcContextElement {
|
|
3129
|
+
data;
|
|
3130
|
+
#fn;
|
|
3131
|
+
unsubscribers = [];
|
|
3132
|
+
constructor(data, fn) {
|
|
3133
|
+
super(data.name);
|
|
3134
|
+
this.data = data;
|
|
3135
|
+
this.#fn = fn ?? new ArcFunction({
|
|
3136
|
+
params: null,
|
|
3137
|
+
result: null,
|
|
3138
|
+
queryElements: data.queryElements,
|
|
3139
|
+
mutationElements: data.mutationElements,
|
|
3140
|
+
protections: [],
|
|
3141
|
+
handler: null,
|
|
3142
|
+
description: data.description
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3145
|
+
description(description) {
|
|
3146
|
+
const newFn = this.#fn.description(description);
|
|
3147
|
+
return new ArcListener({ ...this.data, description }, newFn);
|
|
3148
|
+
}
|
|
3149
|
+
listenTo(events) {
|
|
3150
|
+
return new ArcListener({ ...this.data, eventElements: events }, this.#fn);
|
|
3151
|
+
}
|
|
3152
|
+
query(elements) {
|
|
3153
|
+
const newFn = this.#fn.query(elements);
|
|
3154
|
+
return new ArcListener({ ...this.data, queryElements: elements }, newFn);
|
|
3155
|
+
}
|
|
3156
|
+
mutate(elements) {
|
|
3157
|
+
const newFn = this.#fn.mutate(elements);
|
|
3158
|
+
return new ArcListener({ ...this.data, mutationElements: elements }, newFn);
|
|
3159
|
+
}
|
|
3160
|
+
async() {
|
|
3161
|
+
return new ArcListener({ ...this.data, isAsync: true }, this.#fn);
|
|
3162
|
+
}
|
|
3163
|
+
handle(handler) {
|
|
3164
|
+
return new ArcListener({ ...this.data, handler }, this.#fn);
|
|
3165
|
+
}
|
|
3166
|
+
get eventElements() {
|
|
3167
|
+
return this.data.eventElements || [];
|
|
3168
|
+
}
|
|
3169
|
+
get isAsync() {
|
|
3170
|
+
return this.data.isAsync;
|
|
3171
|
+
}
|
|
3172
|
+
async init(environment, adapters) {
|
|
3173
|
+
if (environment !== "server") {
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
if (!this.data.handler) {
|
|
3177
|
+
console.warn(`Listener "${this.data.name}" has no handler`);
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
if (!adapters.eventPublisher) {
|
|
3181
|
+
console.warn(`Listener "${this.data.name}" cannot subscribe: no eventPublisher adapter`);
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
for (const eventElement of this.data.eventElements) {
|
|
3185
|
+
const unsubscribe = adapters.eventPublisher.subscribe(eventElement.name, async (event2) => {
|
|
3186
|
+
await this.handleEvent(event2, adapters);
|
|
3187
|
+
});
|
|
3188
|
+
this.unsubscribers.push(unsubscribe);
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
async handleEvent(event2, adapters) {
|
|
3192
|
+
if (!this.data.handler)
|
|
3193
|
+
return;
|
|
3194
|
+
const context2 = this.#fn.buildContext(adapters);
|
|
3195
|
+
if (adapters.authAdapter) {
|
|
3196
|
+
const decoded = adapters.authAdapter.getDecoded();
|
|
3197
|
+
if (decoded) {
|
|
3198
|
+
context2.$auth = {
|
|
3199
|
+
params: decoded.params,
|
|
3200
|
+
tokenName: decoded.tokenName
|
|
3201
|
+
};
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
if (this.data.isAsync) {
|
|
3205
|
+
Promise.resolve(this.data.handler(context2, event2)).catch((error) => {
|
|
3206
|
+
console.error(`Async listener "${this.data.name}" error:`, error);
|
|
3207
|
+
});
|
|
3208
|
+
} else {
|
|
3209
|
+
await this.data.handler(context2, event2);
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
destroy() {
|
|
3213
|
+
for (const unsubscribe of this.unsubscribers) {
|
|
3214
|
+
unsubscribe();
|
|
3215
|
+
}
|
|
3216
|
+
this.unsubscribers = [];
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
class ArcRoute extends ArcContextElement {
|
|
3220
|
+
data;
|
|
3221
|
+
#fn;
|
|
3222
|
+
constructor(data, fn) {
|
|
3223
|
+
super(data.name);
|
|
3224
|
+
this.data = data;
|
|
3225
|
+
this.#fn = fn ?? new ArcFunction({
|
|
3226
|
+
params: null,
|
|
3227
|
+
result: null,
|
|
3228
|
+
queryElements: data.queryElements,
|
|
3229
|
+
mutationElements: data.mutationElements,
|
|
3230
|
+
protections: data.protections || [],
|
|
3231
|
+
handler: null,
|
|
3232
|
+
description: data.description
|
|
3233
|
+
});
|
|
3234
|
+
}
|
|
3235
|
+
description(description) {
|
|
3236
|
+
const newFn = this.#fn.description(description);
|
|
3237
|
+
return new ArcRoute({ ...this.data, description }, newFn);
|
|
3238
|
+
}
|
|
3239
|
+
path(path) {
|
|
3240
|
+
return new ArcRoute({ ...this.data, path }, this.#fn);
|
|
3241
|
+
}
|
|
3242
|
+
public() {
|
|
3243
|
+
return new ArcRoute({ ...this.data, isPublic: true }, this.#fn);
|
|
3244
|
+
}
|
|
3245
|
+
query(elements) {
|
|
3246
|
+
const newFn = this.#fn.query(elements);
|
|
3247
|
+
return new ArcRoute({ ...this.data, queryElements: elements }, newFn);
|
|
3248
|
+
}
|
|
3249
|
+
mutate(elements) {
|
|
3250
|
+
const newFn = this.#fn.mutate(elements);
|
|
3251
|
+
return new ArcRoute({ ...this.data, mutationElements: elements }, newFn);
|
|
3252
|
+
}
|
|
3253
|
+
protectBy(token, check) {
|
|
3254
|
+
const newFn = this.#fn.protectedBy(token, check);
|
|
3255
|
+
const existingProtections = this.data.protections || [];
|
|
3256
|
+
return new ArcRoute({
|
|
3257
|
+
...this.data,
|
|
3258
|
+
protections: [...existingProtections, { token, check }]
|
|
3259
|
+
}, newFn);
|
|
3260
|
+
}
|
|
3261
|
+
handle(handlers) {
|
|
3262
|
+
return new ArcRoute({ ...this.data, handlers }, this.#fn);
|
|
3263
|
+
}
|
|
3264
|
+
get routePath() {
|
|
3265
|
+
return this.data.path || `/${this.data.name}`;
|
|
3266
|
+
}
|
|
3267
|
+
get fullPath() {
|
|
3268
|
+
return `/route${this.routePath}`;
|
|
3269
|
+
}
|
|
3270
|
+
get isPublic() {
|
|
3271
|
+
return this.data.isPublic;
|
|
3272
|
+
}
|
|
3273
|
+
get hasProtections() {
|
|
3274
|
+
return this.#fn.hasProtections;
|
|
3275
|
+
}
|
|
3276
|
+
get protections() {
|
|
3277
|
+
return this.data.protections || [];
|
|
3278
|
+
}
|
|
3279
|
+
getHandler(method) {
|
|
3280
|
+
return this.data.handlers?.[method];
|
|
3281
|
+
}
|
|
3282
|
+
matchesPath(pathname) {
|
|
3283
|
+
const routePath = this.fullPath;
|
|
3284
|
+
const routeParts = routePath.split("/").filter(Boolean);
|
|
3285
|
+
const pathParts = pathname.split("/").filter(Boolean);
|
|
3286
|
+
if (routeParts.length !== pathParts.length) {
|
|
3287
|
+
return { matches: false, params: {} };
|
|
3288
|
+
}
|
|
3289
|
+
const params = {};
|
|
3290
|
+
for (let i = 0;i < routeParts.length; i++) {
|
|
3291
|
+
const routePart = routeParts[i];
|
|
3292
|
+
const pathPart = pathParts[i];
|
|
3293
|
+
if (routePart.startsWith(":")) {
|
|
3294
|
+
const paramName = routePart.slice(1);
|
|
3295
|
+
params[paramName] = pathPart;
|
|
3296
|
+
} else if (routePart !== pathPart) {
|
|
3297
|
+
return { matches: false, params: {} };
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
return { matches: true, params };
|
|
3301
|
+
}
|
|
3302
|
+
async verifyProtections(tokens) {
|
|
3303
|
+
if (this.data.isPublic) {
|
|
3304
|
+
return true;
|
|
3305
|
+
}
|
|
3306
|
+
return this.#fn.verifyProtections(tokens);
|
|
3307
|
+
}
|
|
3308
|
+
buildContext(adapters, authParams) {
|
|
3309
|
+
const context2 = this.#fn.buildContext(adapters);
|
|
3310
|
+
if (authParams) {
|
|
3311
|
+
context2.$auth = authParams;
|
|
3312
|
+
}
|
|
3313
|
+
return context2;
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
2866
3316
|
class DataStorage {
|
|
2867
3317
|
async commitChanges(changes) {
|
|
2868
3318
|
await Promise.all(changes.map(({ store, changes: changes2 }) => this.getStore(store).applyChanges(changes2)));
|
package/dist/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../../../node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-bundler-friendly.mjs
|
|
1
|
+
// ../../../../node_modules/.bun/@sqlite.org+sqlite-wasm@3.46.0-build2/node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-bundler-friendly.mjs
|
|
2
2
|
var sqlite3InitModule = (() => {
|
|
3
3
|
var _scriptDir = import.meta.url;
|
|
4
4
|
return function(config) {
|
|
@@ -5893,22 +5893,22 @@ var sqlite3InitModule = (() => {
|
|
|
5893
5893
|
SBF.__makeDebugFlags = function(deriveFrom = null) {
|
|
5894
5894
|
if (deriveFrom && deriveFrom.__flags)
|
|
5895
5895
|
deriveFrom = deriveFrom.__flags;
|
|
5896
|
-
const f = function
|
|
5896
|
+
const f = function f2(flags) {
|
|
5897
5897
|
if (arguments.length === 0) {
|
|
5898
|
-
return
|
|
5898
|
+
return f2.__flags;
|
|
5899
5899
|
}
|
|
5900
5900
|
if (flags < 0) {
|
|
5901
|
-
delete
|
|
5902
|
-
delete
|
|
5903
|
-
delete
|
|
5904
|
-
delete
|
|
5901
|
+
delete f2.__flags.getter;
|
|
5902
|
+
delete f2.__flags.setter;
|
|
5903
|
+
delete f2.__flags.alloc;
|
|
5904
|
+
delete f2.__flags.dealloc;
|
|
5905
5905
|
} else {
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5906
|
+
f2.__flags.getter = (1 & flags) !== 0;
|
|
5907
|
+
f2.__flags.setter = (2 & flags) !== 0;
|
|
5908
|
+
f2.__flags.alloc = (4 & flags) !== 0;
|
|
5909
|
+
f2.__flags.dealloc = (8 & flags) !== 0;
|
|
5910
5910
|
}
|
|
5911
|
-
return
|
|
5911
|
+
return f2._flags;
|
|
5912
5912
|
};
|
|
5913
5913
|
Object.defineProperty(f, "__flags", {
|
|
5914
5914
|
iterable: false,
|
|
@@ -6306,7 +6306,7 @@ var sqlite3InitModule = (() => {
|
|
|
6306
6306
|
}
|
|
6307
6307
|
Object.defineProperty(ctor.prototype, key, prop);
|
|
6308
6308
|
};
|
|
6309
|
-
const StructBinder = function
|
|
6309
|
+
const StructBinder = function StructBinder2(structName, structInfo) {
|
|
6310
6310
|
if (arguments.length === 1) {
|
|
6311
6311
|
structInfo = structName;
|
|
6312
6312
|
structName = structInfo.name;
|
|
@@ -6340,17 +6340,17 @@ var sqlite3InitModule = (() => {
|
|
|
6340
6340
|
else if (structInfo.sizeof < lastMember.offset + lastMember.sizeof) {
|
|
6341
6341
|
toss("Invalid struct config:", structName, "max member offset (" + lastMember.offset + ") ", "extends past end of struct (sizeof=" + structInfo.sizeof + ").");
|
|
6342
6342
|
}
|
|
6343
|
-
const debugFlags = rop(SBF.__makeDebugFlags(
|
|
6344
|
-
const StructCtor = function
|
|
6345
|
-
if (!(this instanceof
|
|
6343
|
+
const debugFlags = rop(SBF.__makeDebugFlags(StructBinder2.debugFlags));
|
|
6344
|
+
const StructCtor = function StructCtor2(externalMemory) {
|
|
6345
|
+
if (!(this instanceof StructCtor2)) {
|
|
6346
6346
|
toss("The", structName, "constructor may only be called via 'new'.");
|
|
6347
6347
|
} else if (arguments.length) {
|
|
6348
6348
|
if (externalMemory !== (externalMemory | 0) || externalMemory <= 0) {
|
|
6349
6349
|
toss("Invalid pointer value for", structName, "constructor.");
|
|
6350
6350
|
}
|
|
6351
|
-
__allocStruct(
|
|
6351
|
+
__allocStruct(StructCtor2, this, externalMemory);
|
|
6352
6352
|
} else {
|
|
6353
|
-
__allocStruct(
|
|
6353
|
+
__allocStruct(StructCtor2, this);
|
|
6354
6354
|
}
|
|
6355
6355
|
};
|
|
6356
6356
|
Object.defineProperties(StructCtor, {
|
|
@@ -8328,7 +8328,7 @@ var sqlite3InitModule = (() => {
|
|
|
8328
8328
|
return arg.returnVal();
|
|
8329
8329
|
},
|
|
8330
8330
|
createFunction: function f(name, xFunc, opt) {
|
|
8331
|
-
const isFunc = (
|
|
8331
|
+
const isFunc = (f2) => f2 instanceof Function;
|
|
8332
8332
|
switch (arguments.length) {
|
|
8333
8333
|
case 1:
|
|
8334
8334
|
opt = name;
|
|
@@ -8520,8 +8520,8 @@ var sqlite3InitModule = (() => {
|
|
|
8520
8520
|
f._ = {
|
|
8521
8521
|
string: function(stmt2, ndx2, val2, asBlob) {
|
|
8522
8522
|
const [pStr, n] = wasm.allocCString(val2, true);
|
|
8523
|
-
const
|
|
8524
|
-
return
|
|
8523
|
+
const f2 = asBlob ? capi.sqlite3_bind_blob : capi.sqlite3_bind_text;
|
|
8524
|
+
return f2(stmt2.pointer, ndx2, pStr, n, capi.SQLITE_WASM_DEALLOC);
|
|
8525
8525
|
}
|
|
8526
8526
|
};
|
|
8527
8527
|
}
|
|
@@ -9841,7 +9841,7 @@ Total of`, n, "op(s) for", t, "ms (incl. " + w + " ms of waiting on the async si
|
|
|
9841
9841
|
};
|
|
9842
9842
|
opfsUtil.randomFilename = randomFilename;
|
|
9843
9843
|
opfsUtil.treeList = async function() {
|
|
9844
|
-
const doDir = async function
|
|
9844
|
+
const doDir = async function callee2(dirHandle, tgt) {
|
|
9845
9845
|
tgt.name = dirHandle.name;
|
|
9846
9846
|
tgt.dirs = [];
|
|
9847
9847
|
tgt.files = [];
|
|
@@ -9849,7 +9849,7 @@ Total of`, n, "op(s) for", t, "ms (incl. " + w + " ms of waiting on the async si
|
|
|
9849
9849
|
if (handle.kind === "directory") {
|
|
9850
9850
|
const subDir = Object.create(null);
|
|
9851
9851
|
tgt.dirs.push(subDir);
|
|
9852
|
-
await
|
|
9852
|
+
await callee2(handle, subDir);
|
|
9853
9853
|
} else {
|
|
9854
9854
|
tgt.files.push(handle.name);
|
|
9855
9855
|
}
|
|
@@ -9888,12 +9888,12 @@ Total of`, n, "op(s) for", t, "ms (incl. " + w + " ms of waiting on the async si
|
|
|
9888
9888
|
opt = { callback: opt };
|
|
9889
9889
|
}
|
|
9890
9890
|
opt = Object.assign(defaultOpt, opt || {});
|
|
9891
|
-
const doDir = async function
|
|
9891
|
+
const doDir = async function callee2(dirHandle, depth) {
|
|
9892
9892
|
for await (const handle of dirHandle.values()) {
|
|
9893
9893
|
if (opt.callback(handle, dirHandle, depth) === false)
|
|
9894
9894
|
return false;
|
|
9895
9895
|
else if (opt.recursive && handle.kind === "directory") {
|
|
9896
|
-
if (await
|
|
9896
|
+
if (await callee2(handle, depth + 1) === false)
|
|
9897
9897
|
break;
|
|
9898
9898
|
}
|
|
9899
9899
|
}
|
|
@@ -10913,7 +10913,7 @@ var toExportForESM = function() {
|
|
|
10913
10913
|
sqlite3InitModule = toExportForESM;
|
|
10914
10914
|
var sqlite3_bundler_friendly_default = sqlite3InitModule;
|
|
10915
10915
|
|
|
10916
|
-
// ../../../../node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1-promiser.mjs
|
|
10916
|
+
// ../../../../node_modules/.bun/@sqlite.org+sqlite-wasm@3.46.0-build2/node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1-promiser.mjs
|
|
10917
10917
|
globalThis.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig) {
|
|
10918
10918
|
if (arguments.length === 1 && typeof arguments[0] === "function") {
|
|
10919
10919
|
const f = config;
|
|
@@ -11067,7 +11067,7 @@ sqlite3Worker1Promiser.v2 = function(config) {
|
|
|
11067
11067
|
});
|
|
11068
11068
|
var sqlite3_worker1_promiser_default = sqlite3Worker1Promiser.v2;
|
|
11069
11069
|
|
|
11070
|
-
// ../../../../node_modules/@sqlite.org/sqlite-wasm/index.mjs
|
|
11070
|
+
// ../../../../node_modules/.bun/@sqlite.org+sqlite-wasm@3.46.0-build2/node_modules/@sqlite.org/sqlite-wasm/index.mjs
|
|
11071
11071
|
var sqlite3Worker1Promiser2 = self.sqlite3Worker1Promiser;
|
|
11072
11072
|
var sqlite_wasm_default = sqlite3_bundler_friendly_default;
|
|
11073
11073
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-adapter-db-sqlite-wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dev": "bun build ./src/index.ts ./src/worker.ts --outdir ./dist --target browser --format esm --watch"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@arcote.tech/arc": "^0.
|
|
26
|
+
"@arcote.tech/arc": "^0.5.1",
|
|
27
27
|
"@sqlite.org/sqlite-wasm": "^3.46.0-build1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|