@zenithbuild/runtime 0.7.4 → 0.7.7
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 -0
- package/RUNTIME_CONTRACT.md +8 -0
- package/dist/diagnostics-production.d.ts +11 -0
- package/dist/diagnostics-production.js +279 -0
- package/dist/events.js +2 -2
- package/dist/expressions.d.ts +0 -1
- package/dist/expressions.js +128 -150
- package/dist/hydrate.js +32 -67
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/markup.js +7 -7
- package/dist/payload.d.ts +9 -10
- package/dist/payload.js +128 -219
- package/dist/presence.d.ts +67 -0
- package/dist/presence.js +297 -0
- package/dist/render.js +99 -117
- package/dist/runtime-template-profile.d.ts +20 -0
- package/dist/runtime-template-profile.js +141 -0
- package/dist/scanner.js +2 -2
- package/dist/template.d.ts +7 -1
- package/dist/template.js +25 -23
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
const DEFAULT_RUNTIME_MODULES = Object.freeze([
|
|
2
|
+
{ sourceFile: 'reactivity-core.js', contributorId: 'reactivity-core.js' },
|
|
3
|
+
{ sourceFile: 'side-effect-scope.js', contributorId: 'side-effect-scope.js' },
|
|
4
|
+
{ sourceFile: 'effect-utils.js', contributorId: 'effect-utils.js' },
|
|
5
|
+
{ sourceFile: 'effect-scheduler.js', contributorId: 'effect-scheduler.js' },
|
|
6
|
+
{ sourceFile: 'effect-runtime.js', contributorId: 'effect-runtime.js' },
|
|
7
|
+
{ sourceFile: 'mount-runtime.js', contributorId: 'mount-runtime.js' },
|
|
8
|
+
{ sourceFile: 'zeneffect.js', contributorId: 'zeneffect.js' },
|
|
9
|
+
{ sourceFile: 'ref.js', contributorId: 'ref.js' },
|
|
10
|
+
{ sourceFile: 'env.js', contributorId: 'env.js' },
|
|
11
|
+
{ sourceFile: 'platform.js', contributorId: 'platform.js' },
|
|
12
|
+
{ sourceFile: 'presence.js', contributorId: 'presence.js' },
|
|
13
|
+
{ sourceFile: 'signal.js', contributorId: 'signal.js' },
|
|
14
|
+
{ sourceFile: 'state.js', contributorId: 'state.js' },
|
|
15
|
+
{ sourceFile: 'diagnostics.js', contributorId: 'diagnostics.js' },
|
|
16
|
+
{ sourceFile: 'cleanup.js', contributorId: 'cleanup.js' },
|
|
17
|
+
{ sourceFile: 'template-parser.js', contributorId: 'template-parser.js' },
|
|
18
|
+
{ sourceFile: 'markup.js', contributorId: 'markup.js' },
|
|
19
|
+
{ sourceFile: 'payload.js', contributorId: 'payload.js' },
|
|
20
|
+
{ sourceFile: 'expressions.js', contributorId: 'expressions.js' },
|
|
21
|
+
{ sourceFile: 'render.js', contributorId: 'render.js' },
|
|
22
|
+
{ sourceFile: 'fragment-patch.js', contributorId: 'fragment-patch.js' },
|
|
23
|
+
{ sourceFile: 'scanner.js', contributorId: 'scanner.js' },
|
|
24
|
+
{ sourceFile: 'events.js', contributorId: 'events.js' },
|
|
25
|
+
{ sourceFile: 'hydrate.js', contributorId: 'hydrate.js' }
|
|
26
|
+
]);
|
|
27
|
+
const PRODUCTION_EMITTED_RUNTIME_MODULES = Object.freeze([
|
|
28
|
+
{ sourceFile: 'reactivity-core.js', contributorId: 'reactivity-core.js' },
|
|
29
|
+
{ sourceFile: 'side-effect-scope.js', contributorId: 'side-effect-scope.js' },
|
|
30
|
+
{ sourceFile: 'effect-utils.js', contributorId: 'effect-utils.js' },
|
|
31
|
+
{ sourceFile: 'effect-scheduler.js', contributorId: 'effect-scheduler.js' },
|
|
32
|
+
{ sourceFile: 'effect-runtime.js', contributorId: 'effect-runtime.js' },
|
|
33
|
+
{ sourceFile: 'mount-runtime.js', contributorId: 'mount-runtime.js' },
|
|
34
|
+
{ sourceFile: 'zeneffect.js', contributorId: 'zeneffect.js' },
|
|
35
|
+
{ sourceFile: 'ref.js', contributorId: 'ref.js' },
|
|
36
|
+
{ sourceFile: 'env.js', contributorId: 'env.js' },
|
|
37
|
+
{ sourceFile: 'platform.js', contributorId: 'platform.js' },
|
|
38
|
+
{ sourceFile: 'signal.js', contributorId: 'signal.js' },
|
|
39
|
+
{ sourceFile: 'state.js', contributorId: 'state.js' },
|
|
40
|
+
{ sourceFile: 'diagnostics-production.js', contributorId: 'diagnostics.js' },
|
|
41
|
+
{ sourceFile: 'cleanup.js', contributorId: 'cleanup.js' },
|
|
42
|
+
{ sourceFile: 'template-parser.js', contributorId: 'template-parser.js' },
|
|
43
|
+
{ sourceFile: 'markup.js', contributorId: 'markup.js' },
|
|
44
|
+
{ sourceFile: 'payload.js', contributorId: 'payload.js' },
|
|
45
|
+
{ sourceFile: 'expressions.js', contributorId: 'expressions.js' },
|
|
46
|
+
{ sourceFile: 'render.js', contributorId: 'render.js' },
|
|
47
|
+
{ sourceFile: 'fragment-patch.js', contributorId: 'fragment-patch.js' },
|
|
48
|
+
{ sourceFile: 'scanner.js', contributorId: 'scanner.js' },
|
|
49
|
+
{ sourceFile: 'events.js', contributorId: 'events.js' },
|
|
50
|
+
{ sourceFile: 'hydrate.js', contributorId: 'hydrate.js' }
|
|
51
|
+
]);
|
|
52
|
+
const PRODUCTION_EMITTED_WITH_PRESENCE_RUNTIME_MODULES = Object.freeze([
|
|
53
|
+
{ sourceFile: 'reactivity-core.js', contributorId: 'reactivity-core.js' },
|
|
54
|
+
{ sourceFile: 'side-effect-scope.js', contributorId: 'side-effect-scope.js' },
|
|
55
|
+
{ sourceFile: 'effect-utils.js', contributorId: 'effect-utils.js' },
|
|
56
|
+
{ sourceFile: 'effect-scheduler.js', contributorId: 'effect-scheduler.js' },
|
|
57
|
+
{ sourceFile: 'effect-runtime.js', contributorId: 'effect-runtime.js' },
|
|
58
|
+
{ sourceFile: 'mount-runtime.js', contributorId: 'mount-runtime.js' },
|
|
59
|
+
{ sourceFile: 'zeneffect.js', contributorId: 'zeneffect.js' },
|
|
60
|
+
{ sourceFile: 'ref.js', contributorId: 'ref.js' },
|
|
61
|
+
{ sourceFile: 'env.js', contributorId: 'env.js' },
|
|
62
|
+
{ sourceFile: 'platform.js', contributorId: 'platform.js' },
|
|
63
|
+
{ sourceFile: 'presence.js', contributorId: 'presence.js' },
|
|
64
|
+
{ sourceFile: 'signal.js', contributorId: 'signal.js' },
|
|
65
|
+
{ sourceFile: 'state.js', contributorId: 'state.js' },
|
|
66
|
+
{ sourceFile: 'diagnostics-production.js', contributorId: 'diagnostics.js' },
|
|
67
|
+
{ sourceFile: 'cleanup.js', contributorId: 'cleanup.js' },
|
|
68
|
+
{ sourceFile: 'template-parser.js', contributorId: 'template-parser.js' },
|
|
69
|
+
{ sourceFile: 'markup.js', contributorId: 'markup.js' },
|
|
70
|
+
{ sourceFile: 'payload.js', contributorId: 'payload.js' },
|
|
71
|
+
{ sourceFile: 'expressions.js', contributorId: 'expressions.js' },
|
|
72
|
+
{ sourceFile: 'render.js', contributorId: 'render.js' },
|
|
73
|
+
{ sourceFile: 'fragment-patch.js', contributorId: 'fragment-patch.js' },
|
|
74
|
+
{ sourceFile: 'scanner.js', contributorId: 'scanner.js' },
|
|
75
|
+
{ sourceFile: 'events.js', contributorId: 'events.js' },
|
|
76
|
+
{ sourceFile: 'hydrate.js', contributorId: 'hydrate.js' }
|
|
77
|
+
]);
|
|
78
|
+
export const RUNTIME_TEMPLATE_PROFILES = Object.freeze({
|
|
79
|
+
DEFAULT: 'default',
|
|
80
|
+
PRODUCTION_EMITTED: 'production-emitted',
|
|
81
|
+
PRODUCTION_EMITTED_WITH_PRESENCE: 'production-emitted-with-presence'
|
|
82
|
+
});
|
|
83
|
+
function stripImports(source) {
|
|
84
|
+
return source
|
|
85
|
+
.replace(/^\s*import\s+[^;]+;\s*$/gm, '')
|
|
86
|
+
.replace(/^\s*export\s+\{[^}]+\}\s+from\s+['"]\.[^'"]+['"];\s*$/gm, '')
|
|
87
|
+
.trim();
|
|
88
|
+
}
|
|
89
|
+
export function normalizeRuntimeTemplateProfile(profile) {
|
|
90
|
+
if (profile === RUNTIME_TEMPLATE_PROFILES.PRODUCTION_EMITTED) {
|
|
91
|
+
return RUNTIME_TEMPLATE_PROFILES.PRODUCTION_EMITTED;
|
|
92
|
+
}
|
|
93
|
+
if (profile === RUNTIME_TEMPLATE_PROFILES.PRODUCTION_EMITTED_WITH_PRESENCE) {
|
|
94
|
+
return RUNTIME_TEMPLATE_PROFILES.PRODUCTION_EMITTED_WITH_PRESENCE;
|
|
95
|
+
}
|
|
96
|
+
return RUNTIME_TEMPLATE_PROFILES.DEFAULT;
|
|
97
|
+
}
|
|
98
|
+
function runtimeModulesForProfile(profile) {
|
|
99
|
+
switch (normalizeRuntimeTemplateProfile(profile)) {
|
|
100
|
+
case RUNTIME_TEMPLATE_PROFILES.PRODUCTION_EMITTED:
|
|
101
|
+
return PRODUCTION_EMITTED_RUNTIME_MODULES;
|
|
102
|
+
case RUNTIME_TEMPLATE_PROFILES.PRODUCTION_EMITTED_WITH_PRESENCE:
|
|
103
|
+
return PRODUCTION_EMITTED_WITH_PRESENCE_RUNTIME_MODULES;
|
|
104
|
+
default:
|
|
105
|
+
return DEFAULT_RUNTIME_MODULES;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function buildRuntimeTemplateProfile({ profile, normalizeNewlines, readRuntimeSourceFile }) {
|
|
109
|
+
const resolvedProfile = normalizeRuntimeTemplateProfile(profile);
|
|
110
|
+
const modules = runtimeModulesForProfile(resolvedProfile);
|
|
111
|
+
const segments = [];
|
|
112
|
+
const contributors = [];
|
|
113
|
+
let coverageBytes = 0;
|
|
114
|
+
for (let i = 0; i < modules.length; i += 1) {
|
|
115
|
+
const entry = modules[i];
|
|
116
|
+
const source = stripImports(readRuntimeSourceFile(entry.sourceFile));
|
|
117
|
+
if (!source)
|
|
118
|
+
continue;
|
|
119
|
+
segments.push(source);
|
|
120
|
+
const bytes = Buffer.byteLength(source, 'utf8');
|
|
121
|
+
coverageBytes += bytes;
|
|
122
|
+
contributors.push({
|
|
123
|
+
id: entry.contributorId,
|
|
124
|
+
sourceFile: entry.sourceFile,
|
|
125
|
+
bytes
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
contributors.sort((left, right) => {
|
|
129
|
+
if (right.bytes !== left.bytes)
|
|
130
|
+
return right.bytes - left.bytes;
|
|
131
|
+
if (left.id !== right.id)
|
|
132
|
+
return left.id.localeCompare(right.id);
|
|
133
|
+
return left.sourceFile.localeCompare(right.sourceFile);
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
profile: resolvedProfile,
|
|
137
|
+
source: normalizeNewlines(segments.join('\n\n')),
|
|
138
|
+
contributors,
|
|
139
|
+
coverageBytes
|
|
140
|
+
};
|
|
141
|
+
}
|
package/dist/scanner.js
CHANGED
|
@@ -15,8 +15,8 @@ export function createNodeResolver(root) {
|
|
|
15
15
|
marker: { type: kind, id: index },
|
|
16
16
|
path: `selector:${selector}`,
|
|
17
17
|
hint: isRef
|
|
18
|
-
? 'Use ref + zenMount and
|
|
19
|
-
: 'Confirm SSR marker attributes and
|
|
18
|
+
? 'Use ref + zenMount and bind the ref in markup before mount.'
|
|
19
|
+
: 'Confirm SSR marker attributes and selector tables match.',
|
|
20
20
|
docsLink: isRef ? DOCS_LINKS.refs : DOCS_LINKS.markerTable,
|
|
21
21
|
source
|
|
22
22
|
});
|
package/dist/template.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export function runtimeModuleSource():
|
|
1
|
+
export function runtimeModuleSource(): any;
|
|
2
|
+
export function runtimeModuleProfileSnapshot(profile?: "default"): {
|
|
3
|
+
profile: any;
|
|
4
|
+
source: any;
|
|
5
|
+
contributors: any;
|
|
6
|
+
coverageBytes: any;
|
|
7
|
+
};
|
|
2
8
|
export function runtimeDevClientSource(): string;
|
package/dist/template.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { buildRuntimeTemplateProfile, RUNTIME_TEMPLATE_PROFILES, normalizeRuntimeTemplateProfile } from './runtime-template-profile.js';
|
|
4
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
5
6
|
const __dirname = dirname(__filename);
|
|
6
|
-
function normalizeNewlines(value) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const segments = [
|
|
21
|
-
'reactivity-core.js', 'side-effect-scope.js', 'effect-utils.js', 'effect-scheduler.js',
|
|
22
|
-
'effect-runtime.js', 'mount-runtime.js', 'zeneffect.js', 'ref.js', 'env.js',
|
|
23
|
-
'platform.js', 'signal.js', 'state.js',
|
|
24
|
-
'diagnostics.js', 'cleanup.js', 'template-parser.js', 'markup.js', 'payload.js',
|
|
25
|
-
'expressions.js', 'render.js', 'fragment-patch.js', 'scanner.js', 'events.js', 'hydrate.js'
|
|
26
|
-
].map((fileName) => stripImports(readRuntimeSourceFile(fileName))).filter(Boolean);
|
|
27
|
-
return normalizeNewlines(segments.join('\n\n'));
|
|
7
|
+
function normalizeNewlines(value) { return String(value).replace(/\r\n/g, '\n').replace(/\r/g, '\n'); }
|
|
8
|
+
function readRuntimeSourceFile(fileName) { return normalizeNewlines(readFileSync(join(__dirname, fileName), 'utf8')); }
|
|
9
|
+
const runtimeTemplateProfileCache = new Map();
|
|
10
|
+
function resolveRuntimeTemplateProfile(profile) {
|
|
11
|
+
const resolvedProfile = normalizeRuntimeTemplateProfile(profile);
|
|
12
|
+
if (runtimeTemplateProfileCache.has(resolvedProfile))
|
|
13
|
+
return runtimeTemplateProfileCache.get(resolvedProfile);
|
|
14
|
+
const built = buildRuntimeTemplateProfile({
|
|
15
|
+
profile: resolvedProfile,
|
|
16
|
+
normalizeNewlines,
|
|
17
|
+
readRuntimeSourceFile
|
|
18
|
+
});
|
|
19
|
+
runtimeTemplateProfileCache.set(resolvedProfile, built);
|
|
20
|
+
return built;
|
|
28
21
|
}
|
|
29
|
-
const RUNTIME_MODULE_SOURCE =
|
|
22
|
+
const RUNTIME_MODULE_SOURCE = resolveRuntimeTemplateProfile(RUNTIME_TEMPLATE_PROFILES.DEFAULT).source;
|
|
30
23
|
export function runtimeModuleSource() {
|
|
31
24
|
return RUNTIME_MODULE_SOURCE;
|
|
32
25
|
}
|
|
26
|
+
export function runtimeModuleProfileSnapshot(profile = RUNTIME_TEMPLATE_PROFILES.DEFAULT) {
|
|
27
|
+
const resolved = resolveRuntimeTemplateProfile(profile);
|
|
28
|
+
return {
|
|
29
|
+
profile: resolved.profile,
|
|
30
|
+
source: resolved.source,
|
|
31
|
+
contributors: resolved.contributors.map((entry) => ({ ...entry })),
|
|
32
|
+
coverageBytes: resolved.coverageBytes
|
|
33
|
+
};
|
|
34
|
+
}
|
|
33
35
|
const RUNTIME_DEV_CLIENT_SOURCE = `(() => {
|
|
34
36
|
if (typeof window === 'undefined' || typeof document === 'undefined') return;
|
|
35
37
|
if (window.__zenithDevClientActive === true) return;
|