revojs 0.0.76 → 0.0.77
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/app/index.d.ts +6 -5
- package/dist/index.js +120 -120
- package/dist/signals/index.d.ts +0 -1
- package/package.json +1 -6
- package/dist/presets/bun.d.ts +0 -1
- package/dist/presets/bun.js +0 -63
- package/dist/presets/deno.d.ts +0 -1
- package/dist/presets/deno.js +0 -4
- package/dist/presets/node.d.ts +0 -1
- package/dist/presets/node.js +0 -4
package/dist/app/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Middleware } from "../runtime";
|
|
2
|
-
export type
|
|
3
|
-
[P in keyof T]?:
|
|
4
|
-
}
|
|
2
|
+
export type Mergeable<T> = {
|
|
3
|
+
[P in keyof T]?: Mergeable<T[P]>;
|
|
4
|
+
};
|
|
5
5
|
export type Environment = typeof CLIENT | typeof SERVER;
|
|
6
6
|
export type Virtual = (environment: Environment) => void | string;
|
|
7
7
|
export type ClientEntry = "index.html" | (string & {});
|
|
8
|
-
export type ServerEntry = "revojs/
|
|
8
|
+
export type ServerEntry = "@revojs/bun/runtime" | "revojs/cloudflare/runtime" | (string & {});
|
|
9
9
|
export type Module = {
|
|
10
10
|
setup: (app: App) => void | Promise<void>;
|
|
11
11
|
};
|
|
@@ -28,6 +28,7 @@ export type App = {
|
|
|
28
28
|
config: Config;
|
|
29
29
|
virtuals: Record<string, Virtual>;
|
|
30
30
|
};
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function mergeObjects<TBase, TInput>(base: TBase, input: TInput): TBase & TInput;
|
|
32
|
+
export declare function createApp(config?: Mergeable<Config>): App;
|
|
32
33
|
export declare const SERVER = "ssr";
|
|
33
34
|
export declare const CLIENT = "client";
|
package/dist/index.js
CHANGED
|
@@ -1,112 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
var StopEvent = class extends Event {
|
|
3
|
-
constructor() {
|
|
4
|
-
super("stop");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
var Scope = class extends EventTarget {
|
|
8
|
-
parentScope;
|
|
9
|
-
context;
|
|
10
|
-
constructor(parentScope) {
|
|
11
|
-
super();
|
|
12
|
-
this.parentScope = parentScope;
|
|
13
|
-
this.parentScope?.onStop(() => this.stop());
|
|
14
|
-
this.context = /* @__PURE__ */ new Map();
|
|
15
|
-
}
|
|
16
|
-
getContext(input) {
|
|
17
|
-
let scope = this;
|
|
18
|
-
while (scope) {
|
|
19
|
-
if (scope.context.has(input)) return scope.context.get(input);
|
|
20
|
-
scope = scope.parentScope;
|
|
21
|
-
}
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
setContext(input, value) {
|
|
25
|
-
this.context.set(input, value);
|
|
26
|
-
}
|
|
27
|
-
onStop(input) {
|
|
28
|
-
this.addEventListener("stop", input, { once: true });
|
|
29
|
-
}
|
|
30
|
-
stop() {
|
|
31
|
-
return this.dispatchEvent(new StopEvent());
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var Compute = class extends Scope {
|
|
35
|
-
invoke;
|
|
36
|
-
constructor(parentScope, invoke) {
|
|
37
|
-
super(parentScope);
|
|
38
|
-
this.invoke = invoke;
|
|
39
|
-
}
|
|
40
|
-
run() {
|
|
41
|
-
this.stop();
|
|
42
|
-
return this.invoke(this);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var Handler = class Handler {
|
|
46
|
-
get(target, key) {
|
|
47
|
-
const compute = activeCompute;
|
|
48
|
-
if (compute) {
|
|
49
|
-
const computes = targets.get(target) ?? /* @__PURE__ */ new Map();
|
|
50
|
-
const set = computes.get(key) ?? /* @__PURE__ */ new Set();
|
|
51
|
-
computes.set(key, set.add(compute));
|
|
52
|
-
targets.set(target, computes);
|
|
53
|
-
compute.parentScope?.onStop(() => {
|
|
54
|
-
set.delete(compute);
|
|
55
|
-
if (set.size === 0) {
|
|
56
|
-
computes.delete(key);
|
|
57
|
-
if (computes.size === 0) targets.delete(target);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const value = Reflect.get(target, key);
|
|
62
|
-
if (value) {
|
|
63
|
-
if (typeof value === "function" && !value.prototype) return value.bind(target);
|
|
64
|
-
if (typeof value === "object") {
|
|
65
|
-
const tag = Object.prototype.toString.call(value);
|
|
66
|
-
if (tag === "[object Object]" || tag === "[object Array]" || tag === "[object Map]" || tag === "[object Set]" || tag === "[object WeakMap]" || tag === "[object WeakSet]") return new Proxy(value, new Handler());
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return value;
|
|
70
|
-
}
|
|
71
|
-
set(target, key, value) {
|
|
72
|
-
const result = Reflect.set(target, key, value);
|
|
73
|
-
for (const compute of targets.get(target)?.get(key) ?? []) compute.run();
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
function createState(value) {
|
|
78
|
-
return new Proxy({ value }, new Handler());
|
|
79
|
-
}
|
|
80
|
-
function createCompute(scope, invoke) {
|
|
81
|
-
let previous = activeCompute;
|
|
82
|
-
activeCompute = new Compute(scope, invoke);
|
|
83
|
-
const result = invoke(activeCompute);
|
|
84
|
-
if (result instanceof Promise) return result.finally(() => activeCompute = previous);
|
|
85
|
-
activeCompute = previous;
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
function createMemo(scope, invoke) {
|
|
89
|
-
let state;
|
|
90
|
-
const compute = createCompute(scope, (scope$1) => {
|
|
91
|
-
const value = invoke(scope$1);
|
|
92
|
-
if (typeof state === "object") state.value = value;
|
|
93
|
-
return value;
|
|
94
|
-
});
|
|
95
|
-
state = createState(compute);
|
|
96
|
-
return state;
|
|
97
|
-
}
|
|
98
|
-
function fromValue(value) {
|
|
99
|
-
if (value instanceof Function) return fromValue(value());
|
|
100
|
-
return value;
|
|
101
|
-
}
|
|
102
|
-
function untrack(invoke) {
|
|
103
|
-
let previous = activeCompute;
|
|
104
|
-
activeCompute = void 0;
|
|
105
|
-
const result = invoke();
|
|
106
|
-
if (result instanceof Promise) return result.finally(() => activeCompute = previous);
|
|
107
|
-
activeCompute = previous;
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
1
|
+
//#region src/app/index.ts
|
|
110
2
|
function mergeObjects(base, input) {
|
|
111
3
|
const object = structuredClone(input);
|
|
112
4
|
for (const key in base) {
|
|
@@ -118,20 +10,12 @@ function mergeObjects(base, input) {
|
|
|
118
10
|
}
|
|
119
11
|
return object;
|
|
120
12
|
}
|
|
121
|
-
function defineContext(key) {
|
|
122
|
-
return key;
|
|
123
|
-
}
|
|
124
|
-
let activeCompute;
|
|
125
|
-
const targets = /* @__PURE__ */ new WeakMap();
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/app/index.ts
|
|
129
13
|
function createApp(config) {
|
|
130
14
|
return {
|
|
131
15
|
config: mergeObjects(config, {
|
|
132
16
|
modules: [],
|
|
133
|
-
client: { entry: "
|
|
134
|
-
server: { entry: "revojs/
|
|
17
|
+
client: { entry: "index.html" },
|
|
18
|
+
server: { entry: "@revojs/bun/runtime" },
|
|
135
19
|
dev: { middleware: [] }
|
|
136
20
|
}),
|
|
137
21
|
virtuals: {}
|
|
@@ -382,6 +266,122 @@ var Radix = class Radix {
|
|
|
382
266
|
};
|
|
383
267
|
};
|
|
384
268
|
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/signals/index.ts
|
|
271
|
+
var StopEvent = class extends Event {
|
|
272
|
+
constructor() {
|
|
273
|
+
super("stop");
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
var Scope = class extends EventTarget {
|
|
277
|
+
parentScope;
|
|
278
|
+
context;
|
|
279
|
+
constructor(parentScope) {
|
|
280
|
+
super();
|
|
281
|
+
this.parentScope = parentScope;
|
|
282
|
+
this.parentScope?.onStop(() => this.stop());
|
|
283
|
+
this.context = /* @__PURE__ */ new Map();
|
|
284
|
+
}
|
|
285
|
+
getContext(input) {
|
|
286
|
+
let scope = this;
|
|
287
|
+
while (scope) {
|
|
288
|
+
if (scope.context.has(input)) return scope.context.get(input);
|
|
289
|
+
scope = scope.parentScope;
|
|
290
|
+
}
|
|
291
|
+
return {};
|
|
292
|
+
}
|
|
293
|
+
setContext(input, value) {
|
|
294
|
+
this.context.set(input, value);
|
|
295
|
+
}
|
|
296
|
+
onStop(input) {
|
|
297
|
+
this.addEventListener("stop", input, { once: true });
|
|
298
|
+
}
|
|
299
|
+
stop() {
|
|
300
|
+
return this.dispatchEvent(new StopEvent());
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
var Compute = class extends Scope {
|
|
304
|
+
invoke;
|
|
305
|
+
constructor(parentScope, invoke) {
|
|
306
|
+
super(parentScope);
|
|
307
|
+
this.invoke = invoke;
|
|
308
|
+
}
|
|
309
|
+
run() {
|
|
310
|
+
this.stop();
|
|
311
|
+
return this.invoke(this);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
var Handler = class Handler {
|
|
315
|
+
get(target, key) {
|
|
316
|
+
const compute = activeCompute;
|
|
317
|
+
if (compute) {
|
|
318
|
+
const computes = targets.get(target) ?? /* @__PURE__ */ new Map();
|
|
319
|
+
const set = computes.get(key) ?? /* @__PURE__ */ new Set();
|
|
320
|
+
computes.set(key, set.add(compute));
|
|
321
|
+
targets.set(target, computes);
|
|
322
|
+
compute.parentScope?.onStop(() => {
|
|
323
|
+
set.delete(compute);
|
|
324
|
+
if (set.size === 0) {
|
|
325
|
+
computes.delete(key);
|
|
326
|
+
if (computes.size === 0) targets.delete(target);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
const value = Reflect.get(target, key);
|
|
331
|
+
if (value) {
|
|
332
|
+
if (typeof value === "function" && !value.prototype) return value.bind(target);
|
|
333
|
+
if (typeof value === "object") {
|
|
334
|
+
const tag = Object.prototype.toString.call(value);
|
|
335
|
+
if (tag === "[object Object]" || tag === "[object Array]" || tag === "[object Map]" || tag === "[object Set]" || tag === "[object WeakMap]" || tag === "[object WeakSet]") return new Proxy(value, new Handler());
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
set(target, key, value) {
|
|
341
|
+
const result = Reflect.set(target, key, value);
|
|
342
|
+
for (const compute of targets.get(target)?.get(key) ?? []) compute.run();
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
function createState(value) {
|
|
347
|
+
return new Proxy({ value }, new Handler());
|
|
348
|
+
}
|
|
349
|
+
function createCompute(scope, invoke) {
|
|
350
|
+
let previous = activeCompute;
|
|
351
|
+
activeCompute = new Compute(scope, invoke);
|
|
352
|
+
const result = invoke(activeCompute);
|
|
353
|
+
if (result instanceof Promise) return result.finally(() => activeCompute = previous);
|
|
354
|
+
activeCompute = previous;
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
function createMemo(scope, invoke) {
|
|
358
|
+
let state;
|
|
359
|
+
const compute = createCompute(scope, (scope$1) => {
|
|
360
|
+
const value = invoke(scope$1);
|
|
361
|
+
if (typeof state === "object") state.value = value;
|
|
362
|
+
return value;
|
|
363
|
+
});
|
|
364
|
+
state = createState(compute);
|
|
365
|
+
return state;
|
|
366
|
+
}
|
|
367
|
+
function fromValue(value) {
|
|
368
|
+
if (value instanceof Function) return fromValue(value());
|
|
369
|
+
return value;
|
|
370
|
+
}
|
|
371
|
+
function untrack(invoke) {
|
|
372
|
+
let previous = activeCompute;
|
|
373
|
+
activeCompute = void 0;
|
|
374
|
+
const result = invoke();
|
|
375
|
+
if (result instanceof Promise) return result.finally(() => activeCompute = previous);
|
|
376
|
+
activeCompute = previous;
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
function defineContext(key) {
|
|
380
|
+
return key;
|
|
381
|
+
}
|
|
382
|
+
let activeCompute;
|
|
383
|
+
const targets = /* @__PURE__ */ new WeakMap();
|
|
384
|
+
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/runtime/index.ts
|
|
387
387
|
function isRoute(value) {
|
|
@@ -592,7 +592,7 @@ function hydrate(scope, parentNode, slot, index, previous) {
|
|
|
592
592
|
if (previous$1 && hydration !== previous$1) if (Array.isArray(hydration)) if (Array.isArray(previous$1)) {
|
|
593
593
|
const range = toRange(previous$1);
|
|
594
594
|
range.deleteContents();
|
|
595
|
-
|
|
595
|
+
range.insertNode(toFragment(hydration));
|
|
596
596
|
} else if (parentNode.contains(previous$1)) parentNode.replaceChild(toFragment(hydration), previous$1);
|
|
597
597
|
else parentNode.replaceChild(toFragment(hydration), parentNode.childNodes.item(index));
|
|
598
598
|
else if (Array.isArray(previous$1)) {
|
package/dist/signals/index.d.ts
CHANGED
|
@@ -33,7 +33,6 @@ export declare function createCompute<T>(scope: Scope, invoke: (scope: Scope) =>
|
|
|
33
33
|
export declare function createMemo<T>(scope: Scope, invoke: (scope: Scope) => T): State<T>;
|
|
34
34
|
export declare function fromValue<T>(value: Value<T>): T;
|
|
35
35
|
export declare function untrack<T>(invoke: () => T): T;
|
|
36
|
-
export declare function mergeObjects<TBase, TInput>(base: TBase, input: TInput): TBase & TInput;
|
|
37
36
|
export declare function defineContext<T>(key: string): Descriptor<T>;
|
|
38
37
|
export declare let activeCompute: Compute | undefined;
|
|
39
38
|
export declare const targets: WeakMap<object, Map<string | symbol, Set<Compute<void>>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "revojs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "coverbase/revojs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
11
|
},
|
|
12
|
-
"./presets/*": {
|
|
13
|
-
"types": "./dist/presets/*.d.ts",
|
|
14
|
-
"import": "./dist/presets/*.js"
|
|
15
|
-
},
|
|
16
12
|
"./jsx-runtime": {
|
|
17
13
|
"types": "./dist/jsx/index.d.ts",
|
|
18
14
|
"import": "./dist/jsx/index.js"
|
|
@@ -38,7 +34,6 @@
|
|
|
38
34
|
"devDependencies": {
|
|
39
35
|
"@revojs/rolldown": "*",
|
|
40
36
|
"@revojs/tsconfig": "*",
|
|
41
|
-
"@types/bun": "^1.2.17",
|
|
42
37
|
"rolldown": "^1.0.0-beta.19"
|
|
43
38
|
}
|
|
44
39
|
}
|
package/dist/presets/bun.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/presets/bun.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { serve } from "bun";
|
|
2
|
-
import { runtime } from "#virtual/runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/signals/index.ts
|
|
5
|
-
var StopEvent = class extends Event {
|
|
6
|
-
constructor() {
|
|
7
|
-
super("stop");
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var Scope = class extends EventTarget {
|
|
11
|
-
parentScope;
|
|
12
|
-
context;
|
|
13
|
-
constructor(parentScope) {
|
|
14
|
-
super();
|
|
15
|
-
this.parentScope = parentScope;
|
|
16
|
-
this.parentScope?.onStop(() => this.stop());
|
|
17
|
-
this.context = /* @__PURE__ */ new Map();
|
|
18
|
-
}
|
|
19
|
-
getContext(input) {
|
|
20
|
-
let scope = this;
|
|
21
|
-
while (scope) {
|
|
22
|
-
if (scope.context.has(input)) return scope.context.get(input);
|
|
23
|
-
scope = scope.parentScope;
|
|
24
|
-
}
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
setContext(input, value) {
|
|
28
|
-
this.context.set(input, value);
|
|
29
|
-
}
|
|
30
|
-
onStop(input) {
|
|
31
|
-
this.addEventListener("stop", input, { once: true });
|
|
32
|
-
}
|
|
33
|
-
stop() {
|
|
34
|
-
return this.dispatchEvent(new StopEvent());
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function defineContext(key) {
|
|
38
|
-
return key;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/html/index.ts
|
|
43
|
-
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/runtime/index.ts
|
|
47
|
-
const RUNTIME_CONTEXT = defineContext("RUNTIME_CONTEXT");
|
|
48
|
-
const ROUTE_CONTEXT = defineContext("ROUTE_CONTEXT");
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/presets/bun.ts
|
|
52
|
-
serve({ fetch: async (request) => {
|
|
53
|
-
const scope = new Scope();
|
|
54
|
-
scope.setContext(RUNTIME_CONTEXT, {
|
|
55
|
-
tasks: new Array(),
|
|
56
|
-
request,
|
|
57
|
-
response: { headers: new Headers() },
|
|
58
|
-
variables: process.env
|
|
59
|
-
});
|
|
60
|
-
return await runtime.fetch(scope).finally(() => scope.stop());
|
|
61
|
-
} });
|
|
62
|
-
|
|
63
|
-
//#endregion
|
package/dist/presets/deno.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/presets/deno.js
DELETED
package/dist/presets/node.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/presets/node.js
DELETED