@flightdev/ui 2.0.0
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/.turbo/turbo-build.log +81 -0
- package/.turbo/turbo-lint.log +40 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/TESTING.md +124 -0
- package/dist/adapter-MMD-iHNx.d.ts +424 -0
- package/dist/adapters/tier-1/angular.d.ts +60 -0
- package/dist/adapters/tier-1/angular.js +2 -0
- package/dist/adapters/tier-1/index.d.ts +7 -0
- package/dist/adapters/tier-1/index.js +7 -0
- package/dist/adapters/tier-1/qwik.d.ts +55 -0
- package/dist/adapters/tier-1/qwik.js +2 -0
- package/dist/adapters/tier-1/react.d.ts +67 -0
- package/dist/adapters/tier-1/react.js +2 -0
- package/dist/adapters/tier-1/solid.d.ts +45 -0
- package/dist/adapters/tier-1/solid.js +2 -0
- package/dist/adapters/tier-1/svelte.d.ts +48 -0
- package/dist/adapters/tier-1/svelte.js +2 -0
- package/dist/adapters/tier-1/vue.d.ts +47 -0
- package/dist/adapters/tier-1/vue.js +2 -0
- package/dist/adapters/tier-2/index.d.ts +7 -0
- package/dist/adapters/tier-2/index.js +7 -0
- package/dist/adapters/tier-2/inferno.d.ts +31 -0
- package/dist/adapters/tier-2/inferno.js +2 -0
- package/dist/adapters/tier-2/lit.d.ts +34 -0
- package/dist/adapters/tier-2/lit.js +2 -0
- package/dist/adapters/tier-2/marko.d.ts +59 -0
- package/dist/adapters/tier-2/marko.js +2 -0
- package/dist/adapters/tier-2/mithril.d.ts +31 -0
- package/dist/adapters/tier-2/mithril.js +2 -0
- package/dist/adapters/tier-2/preact.d.ts +33 -0
- package/dist/adapters/tier-2/preact.js +2 -0
- package/dist/adapters/tier-2/stencil.d.ts +52 -0
- package/dist/adapters/tier-2/stencil.js +2 -0
- package/dist/adapters/tier-3/alpine.d.ts +73 -0
- package/dist/adapters/tier-3/alpine.js +2 -0
- package/dist/adapters/tier-3/hotwire.d.ts +71 -0
- package/dist/adapters/tier-3/hotwire.js +2 -0
- package/dist/adapters/tier-3/htmx.d.ts +88 -0
- package/dist/adapters/tier-3/htmx.js +2 -0
- package/dist/adapters/tier-3/index.d.ts +7 -0
- package/dist/adapters/tier-3/index.js +7 -0
- package/dist/adapters/tier-3/petite-vue.d.ts +56 -0
- package/dist/adapters/tier-3/petite-vue.js +2 -0
- package/dist/adapters/tier-3/stimulus.d.ts +63 -0
- package/dist/adapters/tier-3/stimulus.js +2 -0
- package/dist/adapters/tier-3/vanilla.d.ts +63 -0
- package/dist/adapters/tier-3/vanilla.js +2 -0
- package/dist/chunk-2SNQ6PTM.js +217 -0
- package/dist/chunk-3D4XMIZI.js +136 -0
- package/dist/chunk-3HU6GSQ4.js +125 -0
- package/dist/chunk-4PZDNFL7.js +148 -0
- package/dist/chunk-5IBLFTYL.js +114 -0
- package/dist/chunk-64JZJ7OK.js +142 -0
- package/dist/chunk-7ZJI3QU2.js +132 -0
- package/dist/chunk-CE4FJHQJ.js +133 -0
- package/dist/chunk-DTCAUBH5.js +87 -0
- package/dist/chunk-NTASPOHG.js +106 -0
- package/dist/chunk-OI2AMQLG.js +152 -0
- package/dist/chunk-Q7HUE44H.js +106 -0
- package/dist/chunk-QH3LOWXU.js +155 -0
- package/dist/chunk-QIVAK6BH.js +103 -0
- package/dist/chunk-V34XPVGK.js +103 -0
- package/dist/chunk-VK7ZPMO7.js +221 -0
- package/dist/chunk-X6CNUW6T.js +136 -0
- package/dist/chunk-XTDK7ME5.js +382 -0
- package/dist/chunk-YFGSHW5S.js +121 -0
- package/dist/chunk-ZAJVSE7J.js +90 -0
- package/dist/core/index.d.ts +161 -0
- package/dist/core/index.js +2 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +71 -0
- package/docs/ADAPTERS.md +946 -0
- package/docs/PATTERNS.md +836 -0
- package/package.json +229 -0
- package/src/adapters/tier-1/angular.ts +223 -0
- package/src/adapters/tier-1/index.ts +12 -0
- package/src/adapters/tier-1/qwik.ts +177 -0
- package/src/adapters/tier-1/react.ts +330 -0
- package/src/adapters/tier-1/solid.ts +222 -0
- package/src/adapters/tier-1/svelte.ts +211 -0
- package/src/adapters/tier-1/vue.ts +234 -0
- package/src/adapters/tier-2/index.ts +12 -0
- package/src/adapters/tier-2/inferno.ts +149 -0
- package/src/adapters/tier-2/lit.ts +191 -0
- package/src/adapters/tier-2/marko.ts +199 -0
- package/src/adapters/tier-2/mithril.ts +152 -0
- package/src/adapters/tier-2/preact.ts +133 -0
- package/src/adapters/tier-2/stencil.ts +214 -0
- package/src/adapters/tier-3/alpine.ts +218 -0
- package/src/adapters/tier-3/hotwire.ts +254 -0
- package/src/adapters/tier-3/htmx.ts +263 -0
- package/src/adapters/tier-3/index.ts +12 -0
- package/src/adapters/tier-3/petite-vue.ts +163 -0
- package/src/adapters/tier-3/stimulus.ts +233 -0
- package/src/adapters/tier-3/vanilla.ts +252 -0
- package/src/ambient.d.ts +310 -0
- package/src/core/adapter.ts +366 -0
- package/src/core/index.ts +56 -0
- package/src/core/registry.ts +518 -0
- package/src/core/types.ts +461 -0
- package/src/htmx.ts +134 -0
- package/src/index.ts +263 -0
- package/test/__mocks__/stencil-core.ts +19 -0
- package/test/__mocks__/stencil-hydrate.ts +15 -0
- package/test/adapters/tier-1.test.ts +206 -0
- package/test/adapters/tier-2.test.ts +175 -0
- package/test/adapters/tier-3.test.ts +284 -0
- package/test/contracts/adapter.contract.ts +293 -0
- package/test/core/core.test.ts +310 -0
- package/test/errors/error-handling.test.ts +454 -0
- package/test/integration/htmx.integration.test.ts +246 -0
- package/test/integration/react.integration.test.ts +271 -0
- package/test/integration/registry.integration.test.ts +308 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +93 -0
- package/vitest.config.ts +101 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// src/core/types.ts
|
|
2
|
+
var DEFAULT_CAPABILITIES = {
|
|
3
|
+
streaming: false,
|
|
4
|
+
partialHydration: false,
|
|
5
|
+
islands: false,
|
|
6
|
+
resumable: false,
|
|
7
|
+
ssg: true,
|
|
8
|
+
csr: true,
|
|
9
|
+
serverComponents: false
|
|
10
|
+
};
|
|
11
|
+
var TIER_INFO = {
|
|
12
|
+
"tier-1": {
|
|
13
|
+
tier: "tier-1",
|
|
14
|
+
name: "Full Support",
|
|
15
|
+
description: "Complete SSR, streaming, hydration, and advanced features",
|
|
16
|
+
features: ["SSR", "Streaming", "Hydration", "Islands", "DevTools"]
|
|
17
|
+
},
|
|
18
|
+
"tier-2": {
|
|
19
|
+
tier: "tier-2",
|
|
20
|
+
name: "Standard Support",
|
|
21
|
+
description: "SSR and hydration with framework-specific optimizations",
|
|
22
|
+
features: ["SSR", "Hydration", "Partial Islands"]
|
|
23
|
+
},
|
|
24
|
+
"tier-3": {
|
|
25
|
+
tier: "tier-3",
|
|
26
|
+
name: "HTML-First",
|
|
27
|
+
description: "Server-rendered HTML with minimal JavaScript enhancement",
|
|
28
|
+
features: ["SSR", "Progressive Enhancement"]
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/core/registry.ts
|
|
33
|
+
var AdapterRegistry = class {
|
|
34
|
+
metadata = /* @__PURE__ */ new Map();
|
|
35
|
+
instances = /* @__PURE__ */ new Map();
|
|
36
|
+
loading = /* @__PURE__ */ new Map();
|
|
37
|
+
/**
|
|
38
|
+
* Register an adapter with the registry.
|
|
39
|
+
*/
|
|
40
|
+
register(metadata) {
|
|
41
|
+
if (this.metadata.has(metadata.id)) {
|
|
42
|
+
console.warn(`[AdapterRegistry] Overwriting existing adapter: ${metadata.id}`);
|
|
43
|
+
}
|
|
44
|
+
this.metadata.set(metadata.id, metadata);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Register multiple adapters at once.
|
|
48
|
+
*/
|
|
49
|
+
registerAll(adapters) {
|
|
50
|
+
for (const adapter of adapters) {
|
|
51
|
+
this.register(adapter);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Unregister an adapter.
|
|
56
|
+
*/
|
|
57
|
+
unregister(id) {
|
|
58
|
+
this.instances.delete(id);
|
|
59
|
+
this.loading.delete(id);
|
|
60
|
+
return this.metadata.delete(id);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if an adapter is registered.
|
|
64
|
+
*/
|
|
65
|
+
has(id) {
|
|
66
|
+
return this.metadata.has(id);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get an adapter by ID (lazy loads if not already loaded).
|
|
70
|
+
*/
|
|
71
|
+
async get(id) {
|
|
72
|
+
const existing = this.instances.get(id);
|
|
73
|
+
if (existing) {
|
|
74
|
+
return existing;
|
|
75
|
+
}
|
|
76
|
+
const loadingPromise = this.loading.get(id);
|
|
77
|
+
if (loadingPromise) {
|
|
78
|
+
return loadingPromise;
|
|
79
|
+
}
|
|
80
|
+
const meta = this.metadata.get(id);
|
|
81
|
+
if (!meta) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
const promise = this.loadAdapter(meta);
|
|
85
|
+
this.loading.set(id, promise);
|
|
86
|
+
try {
|
|
87
|
+
const adapter = await promise;
|
|
88
|
+
this.instances.set(id, adapter);
|
|
89
|
+
this.loading.delete(id);
|
|
90
|
+
return adapter;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
this.loading.delete(id);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get an adapter synchronously (only if already loaded).
|
|
98
|
+
*/
|
|
99
|
+
getSync(id) {
|
|
100
|
+
return this.instances.get(id);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get adapter metadata without loading.
|
|
104
|
+
*/
|
|
105
|
+
getMetadata(id) {
|
|
106
|
+
return this.metadata.get(id);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* List all registered adapter IDs.
|
|
110
|
+
*/
|
|
111
|
+
list() {
|
|
112
|
+
return Array.from(this.metadata.keys());
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* List adapters matching query options.
|
|
116
|
+
*/
|
|
117
|
+
query(options) {
|
|
118
|
+
const results = [];
|
|
119
|
+
for (const meta of this.metadata.values()) {
|
|
120
|
+
if (options.tier && meta.tier !== options.tier) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (options.capability && !meta.capabilities?.[options.capability]) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (options.framework) {
|
|
127
|
+
if (typeof options.framework === "string") {
|
|
128
|
+
if (!meta.framework.includes(options.framework)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
} else if (!options.framework.test(meta.framework)) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
results.push(meta);
|
|
136
|
+
}
|
|
137
|
+
return results;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* List adapters by tier.
|
|
141
|
+
*/
|
|
142
|
+
listByTier(tier) {
|
|
143
|
+
return this.query({ tier }).map((m) => m.id);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* List adapters by capability.
|
|
147
|
+
*/
|
|
148
|
+
listByCapability(capability) {
|
|
149
|
+
return this.query({ capability }).map((m) => m.id);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Preload adapters for faster access later.
|
|
153
|
+
*/
|
|
154
|
+
async preload(ids) {
|
|
155
|
+
await Promise.all(ids.map((id) => this.get(id)));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get all loaded adapters.
|
|
159
|
+
*/
|
|
160
|
+
getLoaded() {
|
|
161
|
+
return new Map(this.instances);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Clear all cached adapter instances (but keep registrations).
|
|
165
|
+
*/
|
|
166
|
+
clearCache() {
|
|
167
|
+
this.instances.clear();
|
|
168
|
+
this.loading.clear();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Clear everything (registrations and cache).
|
|
172
|
+
*/
|
|
173
|
+
clear() {
|
|
174
|
+
this.metadata.clear();
|
|
175
|
+
this.instances.clear();
|
|
176
|
+
this.loading.clear();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get registry statistics.
|
|
180
|
+
*/
|
|
181
|
+
stats() {
|
|
182
|
+
const byTier = {
|
|
183
|
+
"tier-1": 0,
|
|
184
|
+
"tier-2": 0,
|
|
185
|
+
"tier-3": 0
|
|
186
|
+
};
|
|
187
|
+
for (const meta of this.metadata.values()) {
|
|
188
|
+
byTier[meta.tier]++;
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
registered: this.metadata.size,
|
|
192
|
+
loaded: this.instances.size,
|
|
193
|
+
loading: this.loading.size,
|
|
194
|
+
byTier
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Load an adapter from metadata.
|
|
199
|
+
*/
|
|
200
|
+
async loadAdapter(meta) {
|
|
201
|
+
try {
|
|
202
|
+
const adapter = await meta.loader();
|
|
203
|
+
if (adapter.init) {
|
|
204
|
+
await adapter.init();
|
|
205
|
+
}
|
|
206
|
+
return adapter;
|
|
207
|
+
} catch (error) {
|
|
208
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
209
|
+
throw new Error(
|
|
210
|
+
`[AdapterRegistry] Failed to load adapter '${meta.id}': ${message}
|
|
211
|
+
Required peer dependencies: ${meta.peerDependencies?.join(", ") ?? "none"}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var adapterRegistry = new AdapterRegistry();
|
|
217
|
+
function registerBuiltinAdapters() {
|
|
218
|
+
adapterRegistry.register({
|
|
219
|
+
id: "react",
|
|
220
|
+
name: "React",
|
|
221
|
+
framework: "react",
|
|
222
|
+
tier: "tier-1",
|
|
223
|
+
capabilities: { streaming: true, partialHydration: true, serverComponents: true },
|
|
224
|
+
peerDependencies: ["react", "react-dom"],
|
|
225
|
+
loader: () => import('./adapters/tier-1/react.js').then((m) => m.default())
|
|
226
|
+
});
|
|
227
|
+
adapterRegistry.register({
|
|
228
|
+
id: "vue",
|
|
229
|
+
name: "Vue",
|
|
230
|
+
framework: "vue",
|
|
231
|
+
tier: "tier-1",
|
|
232
|
+
capabilities: { streaming: true, partialHydration: true },
|
|
233
|
+
peerDependencies: ["vue"],
|
|
234
|
+
loader: () => import('./adapters/tier-1/vue.js').then((m) => m.default())
|
|
235
|
+
});
|
|
236
|
+
adapterRegistry.register({
|
|
237
|
+
id: "svelte",
|
|
238
|
+
name: "Svelte",
|
|
239
|
+
framework: "svelte",
|
|
240
|
+
tier: "tier-1",
|
|
241
|
+
capabilities: { streaming: false, partialHydration: true },
|
|
242
|
+
peerDependencies: ["svelte"],
|
|
243
|
+
loader: () => import('./adapters/tier-1/svelte.js').then((m) => m.default())
|
|
244
|
+
});
|
|
245
|
+
adapterRegistry.register({
|
|
246
|
+
id: "solid",
|
|
247
|
+
name: "Solid",
|
|
248
|
+
framework: "solid",
|
|
249
|
+
tier: "tier-1",
|
|
250
|
+
capabilities: { streaming: true, partialHydration: true },
|
|
251
|
+
peerDependencies: ["solid-js"],
|
|
252
|
+
loader: () => import('./adapters/tier-1/solid.js').then((m) => m.default())
|
|
253
|
+
});
|
|
254
|
+
adapterRegistry.register({
|
|
255
|
+
id: "angular",
|
|
256
|
+
name: "Angular",
|
|
257
|
+
framework: "angular",
|
|
258
|
+
tier: "tier-1",
|
|
259
|
+
capabilities: { streaming: true, partialHydration: true },
|
|
260
|
+
peerDependencies: ["@angular/core", "@angular/platform-server", "@angular/platform-browser"],
|
|
261
|
+
loader: () => import('./adapters/tier-1/angular.js').then((m) => m.default())
|
|
262
|
+
});
|
|
263
|
+
adapterRegistry.register({
|
|
264
|
+
id: "qwik",
|
|
265
|
+
name: "Qwik",
|
|
266
|
+
framework: "qwik",
|
|
267
|
+
tier: "tier-1",
|
|
268
|
+
capabilities: { streaming: true, resumable: true, partialHydration: true },
|
|
269
|
+
peerDependencies: ["@builder.io/qwik"],
|
|
270
|
+
loader: () => import('./adapters/tier-1/qwik.js').then((m) => m.default())
|
|
271
|
+
});
|
|
272
|
+
adapterRegistry.register({
|
|
273
|
+
id: "preact",
|
|
274
|
+
name: "Preact",
|
|
275
|
+
framework: "preact",
|
|
276
|
+
tier: "tier-2",
|
|
277
|
+
capabilities: { streaming: false, partialHydration: true },
|
|
278
|
+
peerDependencies: ["preact"],
|
|
279
|
+
loader: () => import('./adapters/tier-2/preact.js').then((m) => m.default())
|
|
280
|
+
});
|
|
281
|
+
adapterRegistry.register({
|
|
282
|
+
id: "lit",
|
|
283
|
+
name: "Lit",
|
|
284
|
+
framework: "lit",
|
|
285
|
+
tier: "tier-2",
|
|
286
|
+
capabilities: { islands: true },
|
|
287
|
+
peerDependencies: ["lit"],
|
|
288
|
+
loader: () => import('./adapters/tier-2/lit.js').then((m) => m.default())
|
|
289
|
+
});
|
|
290
|
+
adapterRegistry.register({
|
|
291
|
+
id: "marko",
|
|
292
|
+
name: "Marko",
|
|
293
|
+
framework: "marko",
|
|
294
|
+
tier: "tier-2",
|
|
295
|
+
capabilities: { streaming: true, partialHydration: true, islands: true },
|
|
296
|
+
peerDependencies: ["marko"],
|
|
297
|
+
loader: () => import('./adapters/tier-2/marko.js').then((m) => m.default())
|
|
298
|
+
});
|
|
299
|
+
adapterRegistry.register({
|
|
300
|
+
id: "stencil",
|
|
301
|
+
name: "Stencil",
|
|
302
|
+
framework: "stencil",
|
|
303
|
+
tier: "tier-2",
|
|
304
|
+
capabilities: { islands: true },
|
|
305
|
+
peerDependencies: ["@stencil/core"],
|
|
306
|
+
loader: () => import('./adapters/tier-2/stencil.js').then((m) => m.default())
|
|
307
|
+
});
|
|
308
|
+
adapterRegistry.register({
|
|
309
|
+
id: "mithril",
|
|
310
|
+
name: "Mithril",
|
|
311
|
+
framework: "mithril",
|
|
312
|
+
tier: "tier-2",
|
|
313
|
+
capabilities: {},
|
|
314
|
+
peerDependencies: ["mithril"],
|
|
315
|
+
loader: () => import('./adapters/tier-2/mithril.js').then((m) => m.default())
|
|
316
|
+
});
|
|
317
|
+
adapterRegistry.register({
|
|
318
|
+
id: "inferno",
|
|
319
|
+
name: "Inferno",
|
|
320
|
+
framework: "inferno",
|
|
321
|
+
tier: "tier-2",
|
|
322
|
+
capabilities: { streaming: false },
|
|
323
|
+
peerDependencies: ["inferno"],
|
|
324
|
+
loader: () => import('./adapters/tier-2/inferno.js').then((m) => m.default())
|
|
325
|
+
});
|
|
326
|
+
adapterRegistry.register({
|
|
327
|
+
id: "htmx",
|
|
328
|
+
name: "HTMX",
|
|
329
|
+
framework: "htmx",
|
|
330
|
+
tier: "tier-3",
|
|
331
|
+
capabilities: {},
|
|
332
|
+
peerDependencies: [],
|
|
333
|
+
loader: () => import('./adapters/tier-3/htmx.js').then((m) => m.default())
|
|
334
|
+
});
|
|
335
|
+
adapterRegistry.register({
|
|
336
|
+
id: "alpine",
|
|
337
|
+
name: "Alpine.js",
|
|
338
|
+
framework: "alpine",
|
|
339
|
+
tier: "tier-3",
|
|
340
|
+
capabilities: {},
|
|
341
|
+
peerDependencies: [],
|
|
342
|
+
loader: () => import('./adapters/tier-3/alpine.js').then((m) => m.default())
|
|
343
|
+
});
|
|
344
|
+
adapterRegistry.register({
|
|
345
|
+
id: "hotwire",
|
|
346
|
+
name: "Hotwire",
|
|
347
|
+
framework: "hotwire",
|
|
348
|
+
tier: "tier-3",
|
|
349
|
+
capabilities: {},
|
|
350
|
+
peerDependencies: ["@hotwired/turbo"],
|
|
351
|
+
loader: () => import('./adapters/tier-3/hotwire.js').then((m) => m.default())
|
|
352
|
+
});
|
|
353
|
+
adapterRegistry.register({
|
|
354
|
+
id: "stimulus",
|
|
355
|
+
name: "Stimulus",
|
|
356
|
+
framework: "stimulus",
|
|
357
|
+
tier: "tier-3",
|
|
358
|
+
capabilities: {},
|
|
359
|
+
peerDependencies: ["@hotwired/stimulus"],
|
|
360
|
+
loader: () => import('./adapters/tier-3/stimulus.js').then((m) => m.default())
|
|
361
|
+
});
|
|
362
|
+
adapterRegistry.register({
|
|
363
|
+
id: "petite-vue",
|
|
364
|
+
name: "Petite-vue",
|
|
365
|
+
framework: "petite-vue",
|
|
366
|
+
tier: "tier-3",
|
|
367
|
+
capabilities: {},
|
|
368
|
+
peerDependencies: ["petite-vue"],
|
|
369
|
+
loader: () => import('./adapters/tier-3/petite-vue.js').then((m) => m.default())
|
|
370
|
+
});
|
|
371
|
+
adapterRegistry.register({
|
|
372
|
+
id: "vanilla",
|
|
373
|
+
name: "Vanilla Web Components",
|
|
374
|
+
framework: "vanilla",
|
|
375
|
+
tier: "tier-3",
|
|
376
|
+
capabilities: { islands: true },
|
|
377
|
+
peerDependencies: [],
|
|
378
|
+
loader: () => import('./adapters/tier-3/vanilla.js').then((m) => m.default())
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export { DEFAULT_CAPABILITIES, TIER_INFO, adapterRegistry, registerBuiltinAdapters };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
|
|
2
|
+
|
|
3
|
+
// src/adapters/tier-2/lit.ts
|
|
4
|
+
var LitAdapter = class extends BaseUIAdapter {
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
super();
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
id = "lit";
|
|
10
|
+
name = "Lit";
|
|
11
|
+
framework = "lit";
|
|
12
|
+
frameworkVersion = "3+";
|
|
13
|
+
tier = "tier-2";
|
|
14
|
+
capabilities = {
|
|
15
|
+
streaming: false,
|
|
16
|
+
partialHydration: true,
|
|
17
|
+
islands: true,
|
|
18
|
+
resumable: false,
|
|
19
|
+
ssg: true,
|
|
20
|
+
csr: true,
|
|
21
|
+
serverComponents: false
|
|
22
|
+
};
|
|
23
|
+
async renderToString(component, _context) {
|
|
24
|
+
const startTime = performance.now();
|
|
25
|
+
try {
|
|
26
|
+
const { render } = await import('@lit-labs/ssr');
|
|
27
|
+
const { html } = await import('lit');
|
|
28
|
+
const { collectResult } = await import('@lit-labs/ssr/lib/render-result.js');
|
|
29
|
+
let template;
|
|
30
|
+
if (typeof component.component === "string") {
|
|
31
|
+
const tagName = component.component;
|
|
32
|
+
const props = component.props ?? {};
|
|
33
|
+
const attrs = Object.entries(props).map(([key, value]) => {
|
|
34
|
+
const attrName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
35
|
+
return `${attrName}="${this.escapeHtml(String(value))}"`;
|
|
36
|
+
}).join(" ");
|
|
37
|
+
template = html`<${tagName} ${attrs}></${tagName}>`;
|
|
38
|
+
} else if (typeof component.component === "function") {
|
|
39
|
+
template = component.component(component.props ?? {});
|
|
40
|
+
} else {
|
|
41
|
+
template = component.component;
|
|
42
|
+
}
|
|
43
|
+
const ssrResult = render(template);
|
|
44
|
+
const htmlString = await collectResult(ssrResult);
|
|
45
|
+
return {
|
|
46
|
+
html: htmlString,
|
|
47
|
+
hydrationData: {
|
|
48
|
+
props: component.props,
|
|
49
|
+
componentId: component.id ?? this.generateId()
|
|
50
|
+
},
|
|
51
|
+
timing: this.createTiming(startTime)
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
if (message.includes("Cannot find module '@lit-labs/ssr'")) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"[Flight/Lit] Lit SSR package not found.\nInstall required packages:\n npm install lit @lit-labs/ssr"
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
createIsland(component, props, options) {
|
|
64
|
+
const tagName = component;
|
|
65
|
+
const id = this.generateId();
|
|
66
|
+
const deferHydration = this.options.deferHydration ?? false;
|
|
67
|
+
const attrs = Object.entries(props ?? {}).map(([key, value]) => {
|
|
68
|
+
const attrName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
69
|
+
return `${attrName}="${this.escapeHtml(String(value))}"`;
|
|
70
|
+
}).join(" ");
|
|
71
|
+
const placeholder = `
|
|
72
|
+
<${tagName}
|
|
73
|
+
${attrs}
|
|
74
|
+
data-flight-island="${id}"
|
|
75
|
+
${deferHydration ? "defer-hydration" : ""}
|
|
76
|
+
></${tagName}>
|
|
77
|
+
`.trim();
|
|
78
|
+
return {
|
|
79
|
+
id,
|
|
80
|
+
component,
|
|
81
|
+
props,
|
|
82
|
+
options: options ?? { hydrate: "load" },
|
|
83
|
+
placeholder
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
getHydrationScript(result) {
|
|
87
|
+
const data = this.serializeProps(result.hydrationData);
|
|
88
|
+
return `
|
|
89
|
+
<script type="module">
|
|
90
|
+
window.__FLIGHT_DATA__ = ${data};
|
|
91
|
+
window.__FLIGHT_ADAPTER__ = 'lit';
|
|
92
|
+
|
|
93
|
+
// Lit components hydrate when their definition is loaded
|
|
94
|
+
// If using defer-hydration, call removeAttribute('defer-hydration')
|
|
95
|
+
document.querySelectorAll('[defer-hydration]').forEach(el => {
|
|
96
|
+
el.removeAttribute('defer-hydration');
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
99
|
+
`.trim();
|
|
100
|
+
}
|
|
101
|
+
getClientEntry() {
|
|
102
|
+
return `
|
|
103
|
+
// Lit Client Entry
|
|
104
|
+
// Lit components self-hydrate when their definitions are loaded
|
|
105
|
+
|
|
106
|
+
export function hydrate() {
|
|
107
|
+
// Remove defer-hydration attributes to trigger hydration
|
|
108
|
+
document.querySelectorAll('[defer-hydration]').forEach(el => {
|
|
109
|
+
el.removeAttribute('defer-hydration');
|
|
110
|
+
});
|
|
111
|
+
console.log('[Flight/Lit] Components hydrated');
|
|
112
|
+
}
|
|
113
|
+
`.trim();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function lit(options) {
|
|
117
|
+
return new LitAdapter(options);
|
|
118
|
+
}
|
|
119
|
+
var lit_default = lit;
|
|
120
|
+
|
|
121
|
+
export { LitAdapter, lit, lit_default };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
|
|
2
|
+
|
|
3
|
+
// src/adapters/tier-3/petite-vue.ts
|
|
4
|
+
var PetiteVueAdapter = class extends BaseUIAdapter {
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
super();
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
id = "petite-vue";
|
|
10
|
+
name = "Petite-vue";
|
|
11
|
+
framework = "petite-vue";
|
|
12
|
+
frameworkVersion = "0.4+";
|
|
13
|
+
tier = "tier-3";
|
|
14
|
+
capabilities = {
|
|
15
|
+
streaming: false,
|
|
16
|
+
partialHydration: false,
|
|
17
|
+
islands: false,
|
|
18
|
+
resumable: false,
|
|
19
|
+
ssg: true,
|
|
20
|
+
csr: true,
|
|
21
|
+
serverComponents: false
|
|
22
|
+
};
|
|
23
|
+
async renderToString(component, _context) {
|
|
24
|
+
const startTime = performance.now();
|
|
25
|
+
let html;
|
|
26
|
+
if (typeof component.component === "function") {
|
|
27
|
+
html = component.component(component.props ?? {});
|
|
28
|
+
} else if (typeof component.component === "string") {
|
|
29
|
+
html = component.component;
|
|
30
|
+
} else {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"[Flight/Petite-vue] Components must be HTML strings or template functions.\nUse v-scope for state and @click, v-model, etc. for interactivity."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
html,
|
|
37
|
+
hydrationData: component.props,
|
|
38
|
+
timing: this.createTiming(startTime)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
getHydrationScript(_result) {
|
|
42
|
+
const {
|
|
43
|
+
version = "0.4.1",
|
|
44
|
+
autoInit = true
|
|
45
|
+
} = this.options;
|
|
46
|
+
return `
|
|
47
|
+
<!-- Flight/Petite-vue -->
|
|
48
|
+
<script type="module">
|
|
49
|
+
import { createApp } from 'https://esm.sh/petite-vue@${version}';
|
|
50
|
+
|
|
51
|
+
window.__FLIGHT_ADAPTER__ = 'petite-vue';
|
|
52
|
+
${autoInit ? `createApp().mount();` : "// Manual init: createApp().mount()"}
|
|
53
|
+
|
|
54
|
+
console.log('[Flight/Petite-vue] Initialized');
|
|
55
|
+
</script>
|
|
56
|
+
`.trim();
|
|
57
|
+
}
|
|
58
|
+
getClientEntry() {
|
|
59
|
+
return `
|
|
60
|
+
import { createApp, reactive } from 'petite-vue';
|
|
61
|
+
|
|
62
|
+
export { createApp, reactive };
|
|
63
|
+
|
|
64
|
+
export function hydrate() {
|
|
65
|
+
createApp().mount();
|
|
66
|
+
console.log('[Flight/Petite-vue] Application mounted');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function createScope(initialState) {
|
|
70
|
+
return reactive(initialState);
|
|
71
|
+
}
|
|
72
|
+
`.trim();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function vScope(state, content) {
|
|
76
|
+
const stateStr = JSON.stringify(state).replace(/"/g, "'");
|
|
77
|
+
return `<div v-scope="${stateStr}">${content}</div>`;
|
|
78
|
+
}
|
|
79
|
+
function vFor(items, itemName, content) {
|
|
80
|
+
return `<template v-for="${itemName} in ${items}">${content}</template>`;
|
|
81
|
+
}
|
|
82
|
+
function vIf(condition, content) {
|
|
83
|
+
return `<template v-if="${condition}">${content}</template>`;
|
|
84
|
+
}
|
|
85
|
+
function petiteVue(options) {
|
|
86
|
+
return new PetiteVueAdapter(options);
|
|
87
|
+
}
|
|
88
|
+
var petite_vue_default = petiteVue;
|
|
89
|
+
|
|
90
|
+
export { PetiteVueAdapter, petiteVue, petite_vue_default, vFor, vIf, vScope };
|