@async/framework 0.11.22 → 0.11.23
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/CHANGELOG.md +15 -0
- package/README.md +64 -11
- package/browser.d.ts +28 -1
- package/browser.js +266 -15
- package/browser.min.js +1 -1
- package/browser.ts +266 -15
- package/browser.umd.js +266 -15
- package/browser.umd.min.js +1 -1
- package/framework.d.ts +28 -1
- package/framework.ts +266 -15
- package/jsx/buildtime/jsx-dev-runtime.d.ts +12 -0
- package/jsx/buildtime/jsx-dev-runtime.js +2 -0
- package/jsx/buildtime/jsx-runtime.d.ts +12 -0
- package/jsx/buildtime/jsx-runtime.js +2 -0
- package/jsx/buildtime.d.ts +5 -0
- package/jsx/buildtime.js +11 -0
- package/jsx/jsx-runtime.js +29 -0
- package/jsx/runtime/jsx-dev-runtime.d.ts +12 -0
- package/jsx/runtime/jsx-dev-runtime.js +2 -0
- package/jsx/runtime/jsx-runtime.d.ts +12 -0
- package/jsx/runtime/jsx-runtime.js +2 -0
- package/jsx/runtime.d.ts +5 -0
- package/jsx/runtime.js +11 -0
- package/jsx/types.d.ts +108 -0
- package/package.json +45 -1
- package/server.js +266 -15
package/framework.ts
CHANGED
|
@@ -2045,10 +2045,11 @@ const __componentModule = (() => {
|
|
|
2045
2045
|
const { createLazyRegistry, isLazyDescriptor } = __lazyRegistryModule;
|
|
2046
2046
|
const componentKind = Symbol.for("@async/framework.component");
|
|
2047
2047
|
let componentCounter = 0;
|
|
2048
|
+
let defineComponentWarned = false;
|
|
2048
2049
|
|
|
2049
|
-
function
|
|
2050
|
+
function component(fn) {
|
|
2050
2051
|
if (typeof fn !== "function") {
|
|
2051
|
-
throw new TypeError("
|
|
2052
|
+
throw new TypeError("component(fn) requires a function.");
|
|
2052
2053
|
}
|
|
2053
2054
|
Object.defineProperty(fn, componentKind, {
|
|
2054
2055
|
configurable: true,
|
|
@@ -2057,7 +2058,13 @@ const __componentModule = (() => {
|
|
|
2057
2058
|
return fn;
|
|
2058
2059
|
}
|
|
2059
2060
|
|
|
2060
|
-
|
|
2061
|
+
function defineComponent(fn) {
|
|
2062
|
+
if (!defineComponentWarned) {
|
|
2063
|
+
defineComponentWarned = true;
|
|
2064
|
+
console.warn?.("defineComponent(...) is deprecated. Use component(...) instead.");
|
|
2065
|
+
}
|
|
2066
|
+
return component(fn);
|
|
2067
|
+
}
|
|
2061
2068
|
|
|
2062
2069
|
function createComponentRegistry(initialMap = {}, options = {}) {
|
|
2063
2070
|
const registryStore = options.registry ?? createRegistryStore();
|
|
@@ -2256,10 +2263,11 @@ const __componentModule = (() => {
|
|
|
2256
2263
|
}
|
|
2257
2264
|
|
|
2258
2265
|
function createComponentContext({ runtime, scope, cleanups, attachHooks, visibleHooks, intersectionHooks, destroyHooks, renderScopedTemplate }) {
|
|
2259
|
-
const { signals, handlers, loader, server, router, cache, scheduler } = runtime;
|
|
2266
|
+
const { signals, handlers, loader, server, router, cache, components, scheduler } = runtime;
|
|
2260
2267
|
const generatedHandlers = new WeakMap();
|
|
2261
2268
|
let generatedHandlerCounter = 0;
|
|
2262
2269
|
let generatedSignalCounter = 0;
|
|
2270
|
+
let generatedSlotCounter = 0;
|
|
2263
2271
|
const context = {
|
|
2264
2272
|
scope,
|
|
2265
2273
|
signals,
|
|
@@ -2268,6 +2276,7 @@ const __componentModule = (() => {
|
|
|
2268
2276
|
server,
|
|
2269
2277
|
router,
|
|
2270
2278
|
cache,
|
|
2279
|
+
components,
|
|
2271
2280
|
scheduler,
|
|
2272
2281
|
|
|
2273
2282
|
signal(name, initial) {
|
|
@@ -2347,6 +2356,38 @@ const __componentModule = (() => {
|
|
|
2347
2356
|
return rawHtml(child.html);
|
|
2348
2357
|
},
|
|
2349
2358
|
|
|
2359
|
+
slot(Child, propsOrFn = {}) {
|
|
2360
|
+
let target;
|
|
2361
|
+
let latestProps = {};
|
|
2362
|
+
const renderSlot = () => {
|
|
2363
|
+
if (!target) {
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
loader.mount(target, Child, latestProps);
|
|
2367
|
+
};
|
|
2368
|
+
const attach = registerScopedHandler(`slot.${++generatedSlotCounter}.attach`, function ({ element }) {
|
|
2369
|
+
target = element;
|
|
2370
|
+
renderSlot();
|
|
2371
|
+
return () => {
|
|
2372
|
+
target = undefined;
|
|
2373
|
+
};
|
|
2374
|
+
});
|
|
2375
|
+
const cleanup = signals.effect(() => {
|
|
2376
|
+
latestProps = typeof propsOrFn === "function" ? propsOrFn.call(context) : propsOrFn;
|
|
2377
|
+
renderSlot();
|
|
2378
|
+
}, {
|
|
2379
|
+
scheduler,
|
|
2380
|
+
phase: "effect",
|
|
2381
|
+
scope,
|
|
2382
|
+
key: `slot:${generatedSlotCounter}`
|
|
2383
|
+
});
|
|
2384
|
+
cleanups.push(cleanup);
|
|
2385
|
+
return {
|
|
2386
|
+
attach,
|
|
2387
|
+
render: renderSlot
|
|
2388
|
+
};
|
|
2389
|
+
},
|
|
2390
|
+
|
|
2350
2391
|
suspense(signalRef, views) {
|
|
2351
2392
|
const id = signalRef?.id;
|
|
2352
2393
|
if (!id) {
|
|
@@ -2466,7 +2507,7 @@ const __componentModule = (() => {
|
|
|
2466
2507
|
function componentName(Component) {
|
|
2467
2508
|
return Component.displayName || Component.name || "anonymous";
|
|
2468
2509
|
}
|
|
2469
|
-
return { defineComponent, createComponentRegistry, isComponent, renderComponent
|
|
2510
|
+
return { component, defineComponent, createComponentRegistry, isComponent, renderComponent };
|
|
2470
2511
|
})();
|
|
2471
2512
|
|
|
2472
2513
|
const __serverModule = (() => {
|
|
@@ -3523,7 +3564,7 @@ const __loaderModule = (() => {
|
|
|
3523
3564
|
const { matchAttribute, normalizeAttributeConfig, readAttribute } = __attributesModule;
|
|
3524
3565
|
const inlineBindingPrefix = "__async:inline:";
|
|
3525
3566
|
|
|
3526
|
-
function Loader({ root, signals, handlers, server, router, cache, attributes, scheduler } = {}) {
|
|
3567
|
+
function Loader({ root, signals, handlers, server, router, cache, components, attributes, scheduler } = {}) {
|
|
3527
3568
|
const documentRef = root?.ownerDocument ?? root ?? globalThis.document;
|
|
3528
3569
|
const rootNode = root ?? documentRef;
|
|
3529
3570
|
const signalRegistry = signals ?? createSignalRegistry();
|
|
@@ -3539,6 +3580,7 @@ const __loaderModule = (() => {
|
|
|
3539
3580
|
const intersectionBindings = new WeakMap();
|
|
3540
3581
|
const boundaryState = new WeakMap();
|
|
3541
3582
|
const renderingBoundaries = new WeakSet();
|
|
3583
|
+
const componentBindings = new WeakSet();
|
|
3542
3584
|
const inlineBindings = new Map();
|
|
3543
3585
|
const scopedCleanups = new WeakMap();
|
|
3544
3586
|
let inlineBindingCounter = 0;
|
|
@@ -3551,6 +3593,7 @@ const __loaderModule = (() => {
|
|
|
3551
3593
|
server,
|
|
3552
3594
|
router,
|
|
3553
3595
|
cache,
|
|
3596
|
+
components,
|
|
3554
3597
|
scheduler: schedulerInstance,
|
|
3555
3598
|
attributes: attributeConfig,
|
|
3556
3599
|
|
|
@@ -3567,6 +3610,7 @@ const __loaderModule = (() => {
|
|
|
3567
3610
|
bindClassAttributes(rootOrFragment);
|
|
3568
3611
|
bindEventAttributes(rootOrFragment);
|
|
3569
3612
|
bindBoundaries(rootOrFragment);
|
|
3613
|
+
bindComponentAttributes(rootOrFragment);
|
|
3570
3614
|
runPseudoEvents(rootOrFragment);
|
|
3571
3615
|
return api;
|
|
3572
3616
|
},
|
|
@@ -3592,6 +3636,7 @@ const __loaderModule = (() => {
|
|
|
3592
3636
|
server: api.server,
|
|
3593
3637
|
router: api.router,
|
|
3594
3638
|
cache: api.cache,
|
|
3639
|
+
components: api.components,
|
|
3595
3640
|
scheduler: schedulerInstance,
|
|
3596
3641
|
attributes: attributeConfig
|
|
3597
3642
|
});
|
|
@@ -3886,6 +3931,32 @@ const __loaderModule = (() => {
|
|
|
3886
3931
|
}
|
|
3887
3932
|
}
|
|
3888
3933
|
|
|
3934
|
+
function bindComponentAttributes(scope) {
|
|
3935
|
+
for (const element of elementsIn(scope)) {
|
|
3936
|
+
const id = readAttribute(element, attributeConfig, "async", "component");
|
|
3937
|
+
if (id == null) {
|
|
3938
|
+
continue;
|
|
3939
|
+
}
|
|
3940
|
+
if (componentBindings.has(element)) {
|
|
3941
|
+
continue;
|
|
3942
|
+
}
|
|
3943
|
+
if (!components?.resolve) {
|
|
3944
|
+
throw new Error(`Component "${id}" cannot be mounted because no component registry is available.`);
|
|
3945
|
+
}
|
|
3946
|
+
const Component = components.resolve(id);
|
|
3947
|
+
if (!Component) {
|
|
3948
|
+
throw new Error(`Component "${id}" was not found.`);
|
|
3949
|
+
}
|
|
3950
|
+
componentBindings.add(element);
|
|
3951
|
+
try {
|
|
3952
|
+
api.mount(element, Component);
|
|
3953
|
+
} catch (error) {
|
|
3954
|
+
componentBindings.delete(element);
|
|
3955
|
+
throw error;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3889
3960
|
function renderBoundary(boundary) {
|
|
3890
3961
|
const state = boundaryState.get(boundary);
|
|
3891
3962
|
if (!state) {
|
|
@@ -5265,9 +5336,12 @@ const __appModule = (() => {
|
|
|
5265
5336
|
const registry = createRegistryStore(undefined, { target: "browser" });
|
|
5266
5337
|
const runtimes = new Set();
|
|
5267
5338
|
const createRuntime = options.createRuntime ?? createApp;
|
|
5339
|
+
const loaderFacade = createLoaderFacade();
|
|
5340
|
+
let currentRuntime;
|
|
5268
5341
|
|
|
5269
5342
|
const app = {
|
|
5270
5343
|
registry,
|
|
5344
|
+
loader: loaderFacade,
|
|
5271
5345
|
|
|
5272
5346
|
use(typeOrModule, entries) {
|
|
5273
5347
|
const normalized = normalizeUse(typeOrModule, entries);
|
|
@@ -5284,7 +5358,7 @@ const __appModule = (() => {
|
|
|
5284
5358
|
|
|
5285
5359
|
start(options = {}) {
|
|
5286
5360
|
const runtime = createRuntime(app, options).start();
|
|
5287
|
-
|
|
5361
|
+
setCurrentRuntime(runtime);
|
|
5288
5362
|
return runtime;
|
|
5289
5363
|
},
|
|
5290
5364
|
|
|
@@ -5293,12 +5367,12 @@ const __appModule = (() => {
|
|
|
5293
5367
|
},
|
|
5294
5368
|
|
|
5295
5369
|
detachRoot(root) {
|
|
5296
|
-
return
|
|
5370
|
+
return currentRuntime?.detachRoot(root) ?? app;
|
|
5297
5371
|
},
|
|
5298
5372
|
|
|
5299
5373
|
applySnapshot(snapshot, snapshotOptions = {}) {
|
|
5300
|
-
if (
|
|
5301
|
-
|
|
5374
|
+
if (currentRuntime) {
|
|
5375
|
+
currentRuntime.applySnapshot(snapshot, snapshotOptions);
|
|
5302
5376
|
return app;
|
|
5303
5377
|
}
|
|
5304
5378
|
appendSnapshotDeclarations(registry, snapshot, snapshotOptions);
|
|
@@ -5306,7 +5380,11 @@ const __appModule = (() => {
|
|
|
5306
5380
|
},
|
|
5307
5381
|
|
|
5308
5382
|
inspectRoots() {
|
|
5309
|
-
return
|
|
5383
|
+
return currentRuntime?.inspectRoots() ?? { count: 0, roots: [] };
|
|
5384
|
+
},
|
|
5385
|
+
|
|
5386
|
+
inspectRuntime() {
|
|
5387
|
+
return inspectRuntimeState(currentRuntime, loaderFacade);
|
|
5310
5388
|
},
|
|
5311
5389
|
|
|
5312
5390
|
_attach(runtime) {
|
|
@@ -5316,14 +5394,36 @@ const __appModule = (() => {
|
|
|
5316
5394
|
|
|
5317
5395
|
_detach(runtime) {
|
|
5318
5396
|
runtimes.delete(runtime);
|
|
5397
|
+
if (currentRuntime === runtime) {
|
|
5398
|
+
currentRuntime = latestRuntime(runtimes);
|
|
5399
|
+
}
|
|
5319
5400
|
}
|
|
5320
5401
|
};
|
|
5321
5402
|
|
|
5403
|
+
Object.defineProperties(app, {
|
|
5404
|
+
_runtime: {
|
|
5405
|
+
get() {
|
|
5406
|
+
return currentRuntime;
|
|
5407
|
+
}
|
|
5408
|
+
},
|
|
5409
|
+
_setRuntime: {
|
|
5410
|
+
value(runtime) {
|
|
5411
|
+
setCurrentRuntime(runtime);
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5414
|
+
});
|
|
5415
|
+
|
|
5322
5416
|
if (initial) {
|
|
5323
5417
|
app.use(initial);
|
|
5324
5418
|
}
|
|
5325
5419
|
|
|
5326
5420
|
return app;
|
|
5421
|
+
|
|
5422
|
+
function setCurrentRuntime(runtime) {
|
|
5423
|
+
if (runtime) {
|
|
5424
|
+
currentRuntime = runtime;
|
|
5425
|
+
}
|
|
5426
|
+
}
|
|
5327
5427
|
}
|
|
5328
5428
|
|
|
5329
5429
|
function createApp(appOrDefinition = Async, options = {}) {
|
|
@@ -5386,6 +5486,7 @@ const __appModule = (() => {
|
|
|
5386
5486
|
return runtime;
|
|
5387
5487
|
}
|
|
5388
5488
|
started = true;
|
|
5489
|
+
app._setRuntime?.(runtime);
|
|
5389
5490
|
|
|
5390
5491
|
if (target !== "server") {
|
|
5391
5492
|
configureServerContext({ cache: browserCache });
|
|
@@ -5395,6 +5496,7 @@ const __appModule = (() => {
|
|
|
5395
5496
|
registerRootLoader(loader.root, loader);
|
|
5396
5497
|
loader.start();
|
|
5397
5498
|
startRouterFor(loader.root);
|
|
5499
|
+
app.loader._setCurrent(runtime.loader);
|
|
5398
5500
|
} else if (startupRoot != null) {
|
|
5399
5501
|
runtime.attachRoot(startupRoot);
|
|
5400
5502
|
}
|
|
@@ -5431,6 +5533,7 @@ const __appModule = (() => {
|
|
|
5431
5533
|
handlers,
|
|
5432
5534
|
server,
|
|
5433
5535
|
cache: browserCache,
|
|
5536
|
+
components,
|
|
5434
5537
|
scheduler,
|
|
5435
5538
|
attributes
|
|
5436
5539
|
});
|
|
@@ -5439,6 +5542,7 @@ const __appModule = (() => {
|
|
|
5439
5542
|
configureServerContext({ cache: browserCache });
|
|
5440
5543
|
signals._setContext?.({ server, loader: runtime.loader, cache: browserCache, scheduler });
|
|
5441
5544
|
startRouterFor(root);
|
|
5545
|
+
app.loader._setCurrent(runtime.loader);
|
|
5442
5546
|
return runtime;
|
|
5443
5547
|
},
|
|
5444
5548
|
|
|
@@ -5448,6 +5552,7 @@ const __appModule = (() => {
|
|
|
5448
5552
|
return runtime;
|
|
5449
5553
|
}
|
|
5450
5554
|
if (root == null) {
|
|
5555
|
+
const detachedLoaders = [...new Set(rootLoaders.values())];
|
|
5451
5556
|
for (const rootLoader of new Set(rootLoaders.values())) {
|
|
5452
5557
|
rootLoader.destroy?.();
|
|
5453
5558
|
}
|
|
@@ -5458,6 +5563,7 @@ const __appModule = (() => {
|
|
|
5458
5563
|
loader = undefined;
|
|
5459
5564
|
runtime.loader = undefined;
|
|
5460
5565
|
runtime.router = undefined;
|
|
5566
|
+
app.loader._clearCurrent(detachedLoaders);
|
|
5461
5567
|
return runtime;
|
|
5462
5568
|
}
|
|
5463
5569
|
const rootLoader = rootLoaders.get(root);
|
|
@@ -5476,6 +5582,9 @@ const __appModule = (() => {
|
|
|
5476
5582
|
runtime.router = undefined;
|
|
5477
5583
|
if (next) {
|
|
5478
5584
|
startRouterFor(next.root);
|
|
5585
|
+
app.loader._setCurrent(next);
|
|
5586
|
+
} else {
|
|
5587
|
+
app.loader._clearCurrent(rootLoader);
|
|
5479
5588
|
}
|
|
5480
5589
|
}
|
|
5481
5590
|
return runtime;
|
|
@@ -5563,6 +5672,8 @@ const __appModule = (() => {
|
|
|
5563
5672
|
if (loader && !destroyedLoaders.has(loader)) {
|
|
5564
5673
|
loader?.destroy?.();
|
|
5565
5674
|
}
|
|
5675
|
+
app.loader._clearCurrent([...destroyedLoaders, loader]);
|
|
5676
|
+
app.loader._rejectPending(new Error("Async loader queue was cleared because the runtime was destroyed."));
|
|
5566
5677
|
signals.destroy?.();
|
|
5567
5678
|
if (ownsScheduler) {
|
|
5568
5679
|
scheduler.destroy();
|
|
@@ -5574,6 +5685,22 @@ const __appModule = (() => {
|
|
|
5574
5685
|
}
|
|
5575
5686
|
};
|
|
5576
5687
|
|
|
5688
|
+
Object.defineProperties(runtime, {
|
|
5689
|
+
_inspect: {
|
|
5690
|
+
value() {
|
|
5691
|
+
return {
|
|
5692
|
+
active: !destroyed,
|
|
5693
|
+
started,
|
|
5694
|
+
destroyed,
|
|
5695
|
+
target,
|
|
5696
|
+
roots: runtime.inspectRoots(),
|
|
5697
|
+
loader: app.loader.inspect(),
|
|
5698
|
+
router: Boolean(runtime.router)
|
|
5699
|
+
};
|
|
5700
|
+
}
|
|
5701
|
+
}
|
|
5702
|
+
});
|
|
5703
|
+
|
|
5577
5704
|
server.cache = serverCache;
|
|
5578
5705
|
runtime.server.cache = serverCache;
|
|
5579
5706
|
runtime.applySnapshot(initialSnapshot, { strict: options.strictSnapshots ?? true });
|
|
@@ -5650,6 +5777,107 @@ const __appModule = (() => {
|
|
|
5650
5777
|
|
|
5651
5778
|
const Async = defineApp();
|
|
5652
5779
|
|
|
5780
|
+
function createLoaderFacade() {
|
|
5781
|
+
let current;
|
|
5782
|
+
const pending = [];
|
|
5783
|
+
const readyWaiters = [];
|
|
5784
|
+
|
|
5785
|
+
const facade = {
|
|
5786
|
+
get current() {
|
|
5787
|
+
return current;
|
|
5788
|
+
},
|
|
5789
|
+
|
|
5790
|
+
ready() {
|
|
5791
|
+
if (current) {
|
|
5792
|
+
return Promise.resolve(current);
|
|
5793
|
+
}
|
|
5794
|
+
return new Promise((resolve, reject) => {
|
|
5795
|
+
readyWaiters.push({ resolve, reject });
|
|
5796
|
+
});
|
|
5797
|
+
},
|
|
5798
|
+
|
|
5799
|
+
scan(rootOrFragment) {
|
|
5800
|
+
return enqueue("scan", [rootOrFragment]);
|
|
5801
|
+
},
|
|
5802
|
+
|
|
5803
|
+
swap(boundaryId, fragmentOrTemplate) {
|
|
5804
|
+
return enqueue("swap", [boundaryId, fragmentOrTemplate]);
|
|
5805
|
+
},
|
|
5806
|
+
|
|
5807
|
+
mount(target, Component, props) {
|
|
5808
|
+
return enqueue("mount", [target, Component, props]);
|
|
5809
|
+
},
|
|
5810
|
+
|
|
5811
|
+
inspect() {
|
|
5812
|
+
return {
|
|
5813
|
+
ready: Boolean(current),
|
|
5814
|
+
pending: pending.length,
|
|
5815
|
+
root: current?.root
|
|
5816
|
+
};
|
|
5817
|
+
}
|
|
5818
|
+
};
|
|
5819
|
+
|
|
5820
|
+
Object.defineProperties(facade, {
|
|
5821
|
+
_setCurrent: {
|
|
5822
|
+
value(loader) {
|
|
5823
|
+
if (!loader) {
|
|
5824
|
+
return;
|
|
5825
|
+
}
|
|
5826
|
+
current = loader;
|
|
5827
|
+
while (readyWaiters.length > 0) {
|
|
5828
|
+
readyWaiters.shift().resolve(loader);
|
|
5829
|
+
}
|
|
5830
|
+
flushPending(loader);
|
|
5831
|
+
}
|
|
5832
|
+
},
|
|
5833
|
+
_clearCurrent: {
|
|
5834
|
+
value(loaderOrLoaders) {
|
|
5835
|
+
if (loaderOrLoaders === undefined) {
|
|
5836
|
+
current = undefined;
|
|
5837
|
+
return;
|
|
5838
|
+
}
|
|
5839
|
+
const loaders = Array.isArray(loaderOrLoaders) ? loaderOrLoaders : [loaderOrLoaders];
|
|
5840
|
+
if (loaders.includes(current)) {
|
|
5841
|
+
current = undefined;
|
|
5842
|
+
}
|
|
5843
|
+
}
|
|
5844
|
+
},
|
|
5845
|
+
_rejectPending: {
|
|
5846
|
+
value(error) {
|
|
5847
|
+
while (pending.length > 0) {
|
|
5848
|
+
pending.shift().reject(error);
|
|
5849
|
+
}
|
|
5850
|
+
while (readyWaiters.length > 0) {
|
|
5851
|
+
readyWaiters.shift().reject(error);
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5855
|
+
});
|
|
5856
|
+
|
|
5857
|
+
return facade;
|
|
5858
|
+
|
|
5859
|
+
function enqueue(method, args) {
|
|
5860
|
+
if (current) {
|
|
5861
|
+
return invoke(current, method, args);
|
|
5862
|
+
}
|
|
5863
|
+
return new Promise((resolve, reject) => {
|
|
5864
|
+
pending.push({ method, args, resolve, reject });
|
|
5865
|
+
});
|
|
5866
|
+
}
|
|
5867
|
+
|
|
5868
|
+
function flushPending(loader) {
|
|
5869
|
+
while (pending.length > 0) {
|
|
5870
|
+
const operation = pending.shift();
|
|
5871
|
+
invoke(loader, operation.method, operation.args)
|
|
5872
|
+
.then(operation.resolve, operation.reject);
|
|
5873
|
+
}
|
|
5874
|
+
}
|
|
5875
|
+
|
|
5876
|
+
async function invoke(loader, method, args) {
|
|
5877
|
+
return loader[method](...args);
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
|
|
5653
5881
|
function readSnapshot(root = globalThis.document, { attributes } = {}) {
|
|
5654
5882
|
const attributeConfig = normalizeAttributeConfig(attributes);
|
|
5655
5883
|
const snapshotAttr = attributeName(attributeConfig, "async", "snapshot");
|
|
@@ -5800,10 +6028,33 @@ const __appModule = (() => {
|
|
|
5800
6028
|
}
|
|
5801
6029
|
|
|
5802
6030
|
function ensureRuntime(app) {
|
|
5803
|
-
if (!app.
|
|
6031
|
+
if (!app._runtime) {
|
|
5804
6032
|
app.start();
|
|
5805
6033
|
}
|
|
5806
|
-
return app.
|
|
6034
|
+
return app._runtime;
|
|
6035
|
+
}
|
|
6036
|
+
|
|
6037
|
+
function latestRuntime(runtimes) {
|
|
6038
|
+
let latest;
|
|
6039
|
+
for (const runtime of runtimes) {
|
|
6040
|
+
latest = runtime;
|
|
6041
|
+
}
|
|
6042
|
+
return latest;
|
|
6043
|
+
}
|
|
6044
|
+
|
|
6045
|
+
function inspectRuntimeState(runtime, loaderFacade) {
|
|
6046
|
+
if (runtime?._inspect) {
|
|
6047
|
+
return runtime._inspect();
|
|
6048
|
+
}
|
|
6049
|
+
return {
|
|
6050
|
+
active: Boolean(runtime),
|
|
6051
|
+
started: Boolean(runtime),
|
|
6052
|
+
destroyed: false,
|
|
6053
|
+
target: runtime?.target,
|
|
6054
|
+
roots: runtime?.inspectRoots?.() ?? { count: 0, roots: [] },
|
|
6055
|
+
loader: loaderFacade.inspect(),
|
|
6056
|
+
router: Boolean(runtime?.router)
|
|
6057
|
+
};
|
|
5807
6058
|
}
|
|
5808
6059
|
|
|
5809
6060
|
function applySnapshotToRuntime(runtime, snapshot = {}, options = {}) {
|
|
@@ -6750,7 +7001,7 @@ const __boundaryReceiverModule = (() => {
|
|
|
6750
7001
|
if (options.receiver && typeof options.receiver.apply === "function") {
|
|
6751
7002
|
return options.receiver;
|
|
6752
7003
|
}
|
|
6753
|
-
const runtime = options.runtime ?? globalThis.Async?.
|
|
7004
|
+
const runtime = options.runtime ?? globalThis.Async?._runtime;
|
|
6754
7005
|
const loader = options.loader ?? runtime?.loader;
|
|
6755
7006
|
if (!loader) {
|
|
6756
7007
|
throw new TypeError("AsyncStream requires receiver, loader, or runtime.loader.");
|
|
@@ -7347,7 +7598,7 @@ const __elementsModule = (() => {
|
|
|
7347
7598
|
if (this.__asyncAttached) {
|
|
7348
7599
|
return;
|
|
7349
7600
|
}
|
|
7350
|
-
const runtime = app.
|
|
7601
|
+
const runtime = app._runtime ?? app.start?.();
|
|
7351
7602
|
runtime?.attachRoot?.(this);
|
|
7352
7603
|
this.__asyncRuntime = runtime;
|
|
7353
7604
|
this.__asyncAttached = true;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by scripts/build-framework-bundle.js. Do not edit by hand.
|
|
2
|
+
// Automatic JSX runtime declarations for the buildtime JSX profile.
|
|
3
|
+
|
|
4
|
+
export { Fragment, jsx, jsxDEV, jsxs } from "../jsx-runtime.js";
|
|
5
|
+
import type { AsyncJSXChildren, AsyncJSXElement, BuildtimeIntrinsicElements } from "../types.js";
|
|
6
|
+
export namespace JSX {
|
|
7
|
+
type Element = AsyncJSXElement;
|
|
8
|
+
interface ElementChildrenAttribute {
|
|
9
|
+
children: AsyncJSXChildren;
|
|
10
|
+
}
|
|
11
|
+
type IntrinsicElements = BuildtimeIntrinsicElements;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by scripts/build-framework-bundle.js. Do not edit by hand.
|
|
2
|
+
// Automatic JSX runtime declarations for the buildtime JSX profile.
|
|
3
|
+
|
|
4
|
+
export { Fragment, jsx, jsxDEV, jsxs } from "../jsx-runtime.js";
|
|
5
|
+
import type { AsyncJSXChildren, AsyncJSXElement, BuildtimeIntrinsicElements } from "../types.js";
|
|
6
|
+
export namespace JSX {
|
|
7
|
+
type Element = AsyncJSXElement;
|
|
8
|
+
interface ElementChildrenAttribute {
|
|
9
|
+
children: AsyncJSXChildren;
|
|
10
|
+
}
|
|
11
|
+
type IntrinsicElements = BuildtimeIntrinsicElements;
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Generated by scripts/build-framework-bundle.js. Do not edit by hand.
|
|
2
|
+
// Buildtime/build-required JSX profile declarations.
|
|
3
|
+
|
|
4
|
+
export { ASYNC_JSX_COMPONENT, ASYNC_JSX_REVEAL, ASYNC_JSX_SIGNAL, ASYNC_JSX_SUSPENSE, Reveal, Suspense, component, signal } from "../jsx.js";
|
|
5
|
+
export type { AsyncEventHandler, AsyncHTMLElements, AsyncJSX, AsyncJSXChild, AsyncJSXChildren, AsyncJSXElement, AsyncJsxProfile, AsyncSVGElements, AsyncSignal, BuildtimeIntrinsicElements, BuildtimeJSX, ComputedSignal, PropsOf, RuntimeIntrinsicElements, RuntimeJSX, Signal, SignalValue, WritableSignal } from "./types.js";
|
package/jsx/buildtime.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const Fragment = Symbol.for("async.framework.jsx.fragment");
|
|
2
|
+
|
|
3
|
+
export function jsx(type, props, key) {
|
|
4
|
+
return createJsxNode(type, props, key);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function jsxs(type, props, key) {
|
|
8
|
+
return createJsxNode(type, props, key);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
12
|
+
return createJsxNode(type, props, key, {
|
|
13
|
+
dev: true,
|
|
14
|
+
isStaticChildren,
|
|
15
|
+
source,
|
|
16
|
+
self
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function createJsxNode(type, props, key, dev) {
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
kind: "async-jsx-node",
|
|
23
|
+
type,
|
|
24
|
+
props: props ?? {},
|
|
25
|
+
key: key ?? null,
|
|
26
|
+
dev: dev ? Object.freeze(dev) : undefined
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by scripts/build-framework-bundle.js. Do not edit by hand.
|
|
2
|
+
// Automatic JSX runtime declarations for the runtime JSX profile.
|
|
3
|
+
|
|
4
|
+
export { Fragment, jsx, jsxDEV, jsxs } from "../jsx-runtime.js";
|
|
5
|
+
import type { AsyncJSXChildren, AsyncJSXElement, RuntimeIntrinsicElements } from "../types.js";
|
|
6
|
+
export namespace JSX {
|
|
7
|
+
type Element = AsyncJSXElement;
|
|
8
|
+
interface ElementChildrenAttribute {
|
|
9
|
+
children: AsyncJSXChildren;
|
|
10
|
+
}
|
|
11
|
+
type IntrinsicElements = RuntimeIntrinsicElements;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by scripts/build-framework-bundle.js. Do not edit by hand.
|
|
2
|
+
// Automatic JSX runtime declarations for the runtime JSX profile.
|
|
3
|
+
|
|
4
|
+
export { Fragment, jsx, jsxDEV, jsxs } from "../jsx-runtime.js";
|
|
5
|
+
import type { AsyncJSXChildren, AsyncJSXElement, RuntimeIntrinsicElements } from "../types.js";
|
|
6
|
+
export namespace JSX {
|
|
7
|
+
type Element = AsyncJSXElement;
|
|
8
|
+
interface ElementChildrenAttribute {
|
|
9
|
+
children: AsyncJSXChildren;
|
|
10
|
+
}
|
|
11
|
+
type IntrinsicElements = RuntimeIntrinsicElements;
|
|
12
|
+
}
|
package/jsx/runtime.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Generated by scripts/build-framework-bundle.js. Do not edit by hand.
|
|
2
|
+
// Runtime/no-build JSX profile declarations.
|
|
3
|
+
|
|
4
|
+
export { ASYNC_JSX_COMPONENT, ASYNC_JSX_REVEAL, ASYNC_JSX_SIGNAL, ASYNC_JSX_SUSPENSE, Reveal, Suspense, component, signal } from "../jsx.js";
|
|
5
|
+
export type { AsyncEventHandler, AsyncHTMLElements, AsyncJSX, AsyncJSXChild, AsyncJSXChildren, AsyncJSXElement, AsyncJsxProfile, AsyncSVGElements, AsyncSignal, BuildtimeIntrinsicElements, BuildtimeJSX, ComputedSignal, PropsOf, RuntimeIntrinsicElements, RuntimeJSX, Signal, SignalValue, WritableSignal } from "./types.js";
|