@native-dom/runtime 0.0.3 → 0.0.4
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/README.md +1 -1
- package/dist/attributes.d.ts +21 -18
- package/dist/attributes.d.ts.map +1 -1
- package/dist/attributes.js +115 -137
- package/dist/attributes.js.map +1 -1
- package/dist/css.d.ts +137 -133
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +495 -555
- package/dist/css.js.map +1 -1
- package/dist/custom-elements.d.ts +22 -18
- package/dist/custom-elements.d.ts.map +1 -1
- package/dist/custom-elements.js +58 -58
- package/dist/custom-elements.js.map +1 -1
- package/dist/errors.d.ts +5 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -6
- package/dist/errors.js.map +1 -1
- package/dist/event-init.d.ts +81 -77
- package/dist/event-init.d.ts.map +1 -1
- package/dist/events.d.ts +164 -161
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +417 -462
- package/dist/events.js.map +1 -1
- package/dist/geometry.d.ts +44 -41
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +68 -72
- package/dist/geometry.js.map +1 -1
- package/dist/history.d.ts +17 -13
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +67 -62
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +795 -798
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3020 -3597
- package/dist/index.js.map +1 -1
- package/dist/observers.d.ts +46 -42
- package/dist/observers.d.ts.map +1 -1
- package/dist/observers.js +59 -57
- package/dist/observers.js.map +1 -1
- package/dist/platform.d.ts +71 -67
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +204 -212
- package/dist/platform.js.map +1 -1
- package/dist/stats.d.ts +18 -31
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +75 -87
- package/dist/stats.js.map +1 -1
- package/package.json +6 -7
- package/dist/event-init.js +0 -2
- package/dist/event-init.js.map +0 -1
package/dist/stats.js
CHANGED
|
@@ -1,105 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
//#region src/stats.ts
|
|
2
|
+
const runtimeStats = createRuntimeStats(false);
|
|
3
|
+
const nativeDocumentProxyCache = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function resetRuntimeStats(enabled = true) {
|
|
5
|
+
runtimeStats.enabled = enabled;
|
|
6
|
+
runtimeStats.nativeCalls = emptyCounterMap();
|
|
7
|
+
runtimeStats.operations = emptyCounterMap();
|
|
8
|
+
runtimeStats.wrappers = {
|
|
9
|
+
created: 0,
|
|
10
|
+
cacheHits: 0,
|
|
11
|
+
documentHits: 0,
|
|
12
|
+
byKind: emptyCounterMap()
|
|
13
|
+
};
|
|
14
|
+
return getRuntimeStats();
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
function setRuntimeStatsEnabled(enabled) {
|
|
17
|
+
runtimeStats.enabled = enabled;
|
|
18
|
+
return getRuntimeStats();
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
function getRuntimeStats() {
|
|
21
|
+
return {
|
|
22
|
+
enabled: runtimeStats.enabled,
|
|
23
|
+
nativeCalls: snapshotCounterMap(runtimeStats.nativeCalls),
|
|
24
|
+
operations: snapshotCounterMap(runtimeStats.operations),
|
|
25
|
+
wrappers: {
|
|
26
|
+
created: runtimeStats.wrappers.created,
|
|
27
|
+
cacheHits: runtimeStats.wrappers.cacheHits,
|
|
28
|
+
documentHits: runtimeStats.wrappers.documentHits,
|
|
29
|
+
byKind: snapshotCounterMap(runtimeStats.wrappers.byKind)
|
|
30
|
+
}
|
|
31
|
+
};
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
incrementCounter(runtimeStats.nativeCalls, name);
|
|
33
|
+
function recordNativeCall(name) {
|
|
34
|
+
if (!runtimeStats.enabled) return;
|
|
35
|
+
incrementCounter(runtimeStats.nativeCalls, name);
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
incrementCounter(runtimeStats.operations, name);
|
|
37
|
+
function recordOperation(name) {
|
|
38
|
+
if (!runtimeStats.enabled) return;
|
|
39
|
+
incrementCounter(runtimeStats.operations, name);
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
runtimeStats.wrappers.created++;
|
|
49
|
-
incrementCounter(runtimeStats.wrappers.byKind, kind);
|
|
41
|
+
function recordWrapperCreated(kind) {
|
|
42
|
+
if (!runtimeStats.enabled) return;
|
|
43
|
+
runtimeStats.wrappers.created++;
|
|
44
|
+
incrementCounter(runtimeStats.wrappers.byKind, kind);
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
function prepareNativeDocument(native) {
|
|
47
|
+
return runtimeStats.enabled ? instrumentNativeDocument(native) : native;
|
|
53
48
|
}
|
|
54
49
|
function createRuntimeStats(enabled) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
return {
|
|
51
|
+
enabled,
|
|
52
|
+
nativeCalls: emptyCounterMap(),
|
|
53
|
+
operations: emptyCounterMap(),
|
|
54
|
+
wrappers: {
|
|
55
|
+
created: 0,
|
|
56
|
+
cacheHits: 0,
|
|
57
|
+
documentHits: 0,
|
|
58
|
+
byKind: emptyCounterMap()
|
|
59
|
+
}
|
|
60
|
+
};
|
|
66
61
|
}
|
|
67
62
|
function emptyCounterMap() {
|
|
68
|
-
|
|
63
|
+
return Object.create(null);
|
|
69
64
|
}
|
|
70
65
|
function snapshotCounterMap(counts) {
|
|
71
|
-
|
|
66
|
+
return Object.fromEntries(Object.entries(counts).sort(([left], [right]) => left.localeCompare(right)));
|
|
72
67
|
}
|
|
73
68
|
function incrementCounter(counts, name) {
|
|
74
|
-
|
|
69
|
+
counts[name] = (counts[name] ?? 0) + 1;
|
|
75
70
|
}
|
|
76
71
|
function instrumentNativeDocument(native) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const wrapped = (...args) => {
|
|
95
|
-
recordNativeCall(String(property));
|
|
96
|
-
return Reflect.apply(value, target, args);
|
|
97
|
-
};
|
|
98
|
-
functionCache.set(property, wrapped);
|
|
99
|
-
return wrapped;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
nativeDocumentProxyCache.set(native, proxy);
|
|
103
|
-
return proxy;
|
|
72
|
+
if (!runtimeStats.enabled || typeof native !== "object" || native === null) return native;
|
|
73
|
+
const cached = nativeDocumentProxyCache.get(native);
|
|
74
|
+
if (cached) return cached;
|
|
75
|
+
const functionCache = /* @__PURE__ */ new Map();
|
|
76
|
+
const proxy = new Proxy(native, { get(target, property, receiver) {
|
|
77
|
+
const value = Reflect.get(target, property, receiver);
|
|
78
|
+
if (typeof value !== "function") return value;
|
|
79
|
+
if (functionCache.has(property)) return functionCache.get(property);
|
|
80
|
+
const wrapped = (...args) => {
|
|
81
|
+
recordNativeCall(String(property));
|
|
82
|
+
return Reflect.apply(value, target, args);
|
|
83
|
+
};
|
|
84
|
+
functionCache.set(property, wrapped);
|
|
85
|
+
return wrapped;
|
|
86
|
+
} });
|
|
87
|
+
nativeDocumentProxyCache.set(native, proxy);
|
|
88
|
+
return proxy;
|
|
104
89
|
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { getRuntimeStats, prepareNativeDocument, recordNativeCall, recordOperation, recordWrapperCreated, resetRuntimeStats, runtimeStats, setRuntimeStatsEnabled };
|
|
92
|
+
|
|
105
93
|
//# sourceMappingURL=stats.js.map
|
package/dist/stats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.js","
|
|
1
|
+
{"version":3,"file":"stats.js","names":[],"sources":["../src/stats.ts"],"sourcesContent":["import type { NativeDocument as NativeDocumentBinding } from \"@native-dom/native-core\";\n\nexport interface RuntimeStatsSnapshot {\n enabled: boolean;\n nativeCalls: Record<string, number>;\n operations: Record<string, number>;\n wrappers: {\n created: number;\n cacheHits: number;\n documentHits: number;\n byKind: Record<string, number>;\n };\n}\n\ninterface MutableRuntimeStats {\n enabled: boolean;\n nativeCalls: Record<string, number>;\n operations: Record<string, number>;\n wrappers: {\n created: number;\n cacheHits: number;\n documentHits: number;\n byKind: Record<string, number>;\n };\n}\n\nexport const runtimeStats: MutableRuntimeStats = createRuntimeStats(false);\n\nconst nativeDocumentProxyCache = new WeakMap<object, NativeDocumentBinding>();\n\nexport function resetRuntimeStats(enabled = true): RuntimeStatsSnapshot {\n runtimeStats.enabled = enabled;\n runtimeStats.nativeCalls = emptyCounterMap();\n runtimeStats.operations = emptyCounterMap();\n runtimeStats.wrappers = {\n created: 0,\n cacheHits: 0,\n documentHits: 0,\n byKind: emptyCounterMap()\n };\n return getRuntimeStats();\n}\n\nexport function setRuntimeStatsEnabled(enabled: boolean): RuntimeStatsSnapshot {\n runtimeStats.enabled = enabled;\n return getRuntimeStats();\n}\n\nexport function getRuntimeStats(): RuntimeStatsSnapshot {\n return {\n enabled: runtimeStats.enabled,\n nativeCalls: snapshotCounterMap(runtimeStats.nativeCalls),\n operations: snapshotCounterMap(runtimeStats.operations),\n wrappers: {\n created: runtimeStats.wrappers.created,\n cacheHits: runtimeStats.wrappers.cacheHits,\n documentHits: runtimeStats.wrappers.documentHits,\n byKind: snapshotCounterMap(runtimeStats.wrappers.byKind)\n }\n };\n}\n\nexport function recordNativeCall(name: string): void {\n if (!runtimeStats.enabled) {\n return;\n }\n incrementCounter(runtimeStats.nativeCalls, name);\n}\n\nexport function recordOperation(name: string): void {\n if (!runtimeStats.enabled) {\n return;\n }\n incrementCounter(runtimeStats.operations, name);\n}\n\nexport function recordWrapperCreated(kind: string): void {\n if (!runtimeStats.enabled) {\n return;\n }\n runtimeStats.wrappers.created++;\n incrementCounter(runtimeStats.wrappers.byKind, kind);\n}\n\nexport function prepareNativeDocument(native: NativeDocumentBinding): NativeDocumentBinding {\n return runtimeStats.enabled ? instrumentNativeDocument(native) : native;\n}\n\nfunction createRuntimeStats(enabled: boolean): MutableRuntimeStats {\n return {\n enabled,\n nativeCalls: emptyCounterMap(),\n operations: emptyCounterMap(),\n wrappers: {\n created: 0,\n cacheHits: 0,\n documentHits: 0,\n byKind: emptyCounterMap()\n }\n };\n}\n\nfunction emptyCounterMap(): Record<string, number> {\n return Object.create(null) as Record<string, number>;\n}\n\nfunction snapshotCounterMap(counts: Record<string, number>): Record<string, number> {\n return Object.fromEntries(\n Object.entries(counts).sort(([left], [right]) => left.localeCompare(right))\n );\n}\n\nfunction incrementCounter(counts: Record<string, number>, name: string): void {\n counts[name] = (counts[name] ?? 0) + 1;\n}\n\nfunction instrumentNativeDocument(native: NativeDocumentBinding): NativeDocumentBinding {\n if (!runtimeStats.enabled || typeof native !== \"object\" || native === null) {\n return native;\n }\n const cached = nativeDocumentProxyCache.get(native as object);\n if (cached) {\n return cached;\n }\n\n const functionCache = new Map<PropertyKey, unknown>();\n const proxy = new Proxy(native as object, {\n get(target, property, receiver) {\n const value = Reflect.get(target, property, receiver);\n if (typeof value !== \"function\") {\n return value;\n }\n if (functionCache.has(property)) {\n return functionCache.get(property);\n }\n const wrapped = (...args: unknown[]) => {\n recordNativeCall(String(property));\n return Reflect.apply(value, target, args);\n };\n functionCache.set(property, wrapped);\n return wrapped;\n }\n }) as NativeDocumentBinding;\n nativeDocumentProxyCache.set(native as object, proxy);\n return proxy;\n}\n"],"mappings":";AA0BA,MAAa,eAAoC,mBAAmB,MAAM;AAE1E,MAAM,2CAA2B,IAAI,SAAwC;AAE7E,SAAgB,kBAAkB,UAAU,MAA4B;AACtE,cAAa,UAAU;AACvB,cAAa,cAAc,iBAAiB;AAC5C,cAAa,aAAa,iBAAiB;AAC3C,cAAa,WAAW;EACtB,SAAS;EACT,WAAW;EACX,cAAc;EACd,QAAQ,iBAAiB;EAC1B;AACD,QAAO,iBAAiB;;AAG1B,SAAgB,uBAAuB,SAAwC;AAC7E,cAAa,UAAU;AACvB,QAAO,iBAAiB;;AAG1B,SAAgB,kBAAwC;AACtD,QAAO;EACL,SAAS,aAAa;EACtB,aAAa,mBAAmB,aAAa,YAAY;EACzD,YAAY,mBAAmB,aAAa,WAAW;EACvD,UAAU;GACR,SAAS,aAAa,SAAS;GAC/B,WAAW,aAAa,SAAS;GACjC,cAAc,aAAa,SAAS;GACpC,QAAQ,mBAAmB,aAAa,SAAS,OAAO;GACzD;EACF;;AAGH,SAAgB,iBAAiB,MAAoB;AACnD,KAAI,CAAC,aAAa,QAChB;AAEF,kBAAiB,aAAa,aAAa,KAAK;;AAGlD,SAAgB,gBAAgB,MAAoB;AAClD,KAAI,CAAC,aAAa,QAChB;AAEF,kBAAiB,aAAa,YAAY,KAAK;;AAGjD,SAAgB,qBAAqB,MAAoB;AACvD,KAAI,CAAC,aAAa,QAChB;AAEF,cAAa,SAAS;AACtB,kBAAiB,aAAa,SAAS,QAAQ,KAAK;;AAGtD,SAAgB,sBAAsB,QAAsD;AAC1F,QAAO,aAAa,UAAU,yBAAyB,OAAO,GAAG;;AAGnE,SAAS,mBAAmB,SAAuC;AACjE,QAAO;EACL;EACA,aAAa,iBAAiB;EAC9B,YAAY,iBAAiB;EAC7B,UAAU;GACR,SAAS;GACT,WAAW;GACX,cAAc;GACd,QAAQ,iBAAiB;GAC1B;EACF;;AAGH,SAAS,kBAA0C;AACjD,QAAO,OAAO,OAAO,KAAK;;AAG5B,SAAS,mBAAmB,QAAwD;AAClF,QAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,cAAc,MAAM,CAAC,CAC5E;;AAGH,SAAS,iBAAiB,QAAgC,MAAoB;AAC5E,QAAO,SAAS,OAAO,SAAS,KAAK;;AAGvC,SAAS,yBAAyB,QAAsD;AACtF,KAAI,CAAC,aAAa,WAAW,OAAO,WAAW,YAAY,WAAW,KACpE,QAAO;CAET,MAAM,SAAS,yBAAyB,IAAI,OAAiB;AAC7D,KAAI,OACF,QAAO;CAGT,MAAM,gCAAgB,IAAI,KAA2B;CACrD,MAAM,QAAQ,IAAI,MAAM,QAAkB,EACxC,IAAI,QAAQ,UAAU,UAAU;EAC9B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,SAAS;AACrD,MAAI,OAAO,UAAU,WACnB,QAAO;AAET,MAAI,cAAc,IAAI,SAAS,CAC7B,QAAO,cAAc,IAAI,SAAS;EAEpC,MAAM,WAAW,GAAG,SAAoB;AACtC,oBAAiB,OAAO,SAAS,CAAC;AAClC,UAAO,QAAQ,MAAM,OAAO,QAAQ,KAAK;;AAE3C,gBAAc,IAAI,UAAU,QAAQ;AACpC,SAAO;IAEV,CAAC;AACF,0BAAyB,IAAI,QAAkB,MAAM;AACrD,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-dom/runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "DOM runtime facade backed by native-dom's Rust core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,15 +37,14 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@native-dom/native-core": "^0.0.
|
|
40
|
+
"@native-dom/native-core": "^0.0.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"
|
|
44
|
-
"vitest": "4.1.5"
|
|
43
|
+
"vitest": "4.1.6"
|
|
45
44
|
},
|
|
46
45
|
"scripts": {
|
|
47
|
-
"build": "
|
|
48
|
-
"test": "
|
|
49
|
-
"typecheck": "
|
|
46
|
+
"build": "vp pack src/index.ts",
|
|
47
|
+
"test": "vp test run",
|
|
48
|
+
"typecheck": "vp check --no-fmt --no-lint --no-error-on-unmatched-pattern"
|
|
50
49
|
}
|
|
51
50
|
}
|
package/dist/event-init.js
DELETED
package/dist/event-init.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-init.js","sourceRoot":"","sources":["../src/event-init.ts"],"names":[],"mappings":""}
|