@adaas/are-html 0.0.23 → 0.0.24
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/browser/index.d.mts +18 -2
- package/dist/browser/index.mjs +35 -10
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.mts +17 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.ts +17 -1
- package/dist/node/directives/AreDirectiveIf.directive.js +29 -6
- package/dist/node/directives/AreDirectiveIf.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.mjs +29 -6
- package/dist/node/directives/AreDirectiveIf.directive.mjs.map +1 -1
- package/dist/node/engine/AreHTML.compiler.d.mts +3 -1
- package/dist/node/engine/AreHTML.compiler.d.ts +3 -1
- package/dist/node/engine/AreHTML.compiler.js +7 -4
- package/dist/node/engine/AreHTML.compiler.js.map +1 -1
- package/dist/node/engine/AreHTML.compiler.mjs +7 -4
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
- package/examples/for-perf/dist/index.html +1 -1
- package/examples/for-perf/dist/{mqj1mpf2-z4aokv.js → mqp8i2py-vltsx0.js} +2488 -2373
- package/examples/lazy-loading/README.md +76 -0
- package/examples/lazy-loading/concept.ts +55 -0
- package/examples/lazy-loading/containers/UI.container.ts +215 -0
- package/examples/lazy-loading/dist/app.js +3803 -0
- package/examples/{for-perf/dist/mqj1mpff-4fr7mw.js → lazy-loading/dist/chunks/chunk-6K72IBO4.js} +2688 -5897
- package/examples/lazy-loading/dist/index.html +36 -0
- package/examples/lazy-loading/dist/lazy/about-page.js +59 -0
- package/examples/lazy-loading/dist/lazy/reports-page.js +65 -0
- package/examples/lazy-loading/dist/lazy/settings-page.js +54 -0
- package/examples/lazy-loading/public/index.html +36 -0
- package/examples/lazy-loading/src/components/AppShell.component.ts +44 -0
- package/examples/lazy-loading/src/components/HomePage.component.ts +59 -0
- package/examples/lazy-loading/src/components/LazyOutlet.component.ts +108 -0
- package/examples/lazy-loading/src/components/NavBar.component.ts +98 -0
- package/examples/lazy-loading/src/concept.ts +116 -0
- package/examples/lazy-loading/src/lazy/AboutPage.component.ts +54 -0
- package/examples/lazy-loading/src/lazy/ReportsPage.component.ts +56 -0
- package/examples/lazy-loading/src/lazy/SettingsPage.component.ts +45 -0
- package/examples/lazy-loading/src/runtime/ComponentManifest.fragment.ts +61 -0
- package/examples/lazy-loading/src/runtime/LazyComponentResolver.fragment.ts +77 -0
- package/examples/os-desktop/README.md +91 -0
- package/examples/os-desktop/concept.ts +54 -0
- package/examples/os-desktop/containers/OS.container.ts +198 -0
- package/examples/os-desktop/containers/apps/AppBackend.ts +29 -0
- package/examples/os-desktop/containers/apps/GanttApp.backend.ts +56 -0
- package/examples/os-desktop/containers/apps/MarketingApp.backend.ts +68 -0
- package/examples/os-desktop/dist/app.js +4410 -0
- package/examples/os-desktop/dist/apps/gantt/app.js +271 -0
- package/examples/os-desktop/dist/apps/marketing/app.js +346 -0
- package/examples/os-desktop/dist/chunks/chunk-6K72IBO4.js +12455 -0
- package/examples/os-desktop/dist/chunks/chunk-EIIGUL6N.js +30 -0
- package/examples/os-desktop/dist/chunks/chunk-WOH7L5UR.js +30 -0
- package/examples/os-desktop/dist/index.html +33 -0
- package/examples/os-desktop/public/index.html +33 -0
- package/examples/os-desktop/src/apps/gantt/GanttApp.component.ts +41 -0
- package/examples/os-desktop/src/apps/gantt/GanttChart.component.ts +126 -0
- package/examples/os-desktop/src/apps/gantt/GanttStore.ts +47 -0
- package/examples/os-desktop/src/apps/gantt/GanttToolbar.component.ts +73 -0
- package/examples/os-desktop/src/apps/gantt/index.ts +13 -0
- package/examples/os-desktop/src/apps/marketing/MarketingApp.component.ts +53 -0
- package/examples/os-desktop/src/apps/marketing/MarketingStore.ts +34 -0
- package/examples/os-desktop/src/apps/marketing/PostEditor.component.ts +153 -0
- package/examples/os-desktop/src/apps/marketing/PostPreview.component.ts +110 -0
- package/examples/os-desktop/src/apps/marketing/index.ts +16 -0
- package/examples/os-desktop/src/concept.ts +126 -0
- package/examples/os-desktop/src/os/AppStage.component.ts +112 -0
- package/examples/os-desktop/src/os/AppWindow.component.ts +102 -0
- package/examples/os-desktop/src/os/Desktop.component.ts +106 -0
- package/examples/os-desktop/src/os/Dock.component.ts +174 -0
- package/examples/os-desktop/src/os/Hud.component.ts +83 -0
- package/examples/os-desktop/src/os/Launchpad.component.ts +191 -0
- package/examples/os-desktop/src/os/MenuBar.component.ts +156 -0
- package/examples/os-desktop/src/runtime/AppComponentResolver.fragment.ts +121 -0
- package/examples/os-desktop/src/runtime/AppRegistry.fragment.ts +104 -0
- package/examples/os-desktop/src/signals/MouseState.signal.ts +34 -0
- package/examples/os-desktop/src/signals/OSRoute.signal.ts +37 -0
- package/examples/os-desktop/src/signals/SelectionState.signal.ts +34 -0
- package/examples/signal-routing/dist/index.html +1 -1
- package/examples/signal-routing/dist/{mqiwo23h-bhcolu.js → mqp8hgce-4d6rh0.js} +2911 -2708
- package/package.json +11 -7
- package/src/directives/AreDirectiveIf.directive.ts +33 -4
- package/src/engine/AreHTML.compiler.ts +12 -2
- package/tests/PropPropagation.test.ts +181 -0
- package/tests/jest.setup.ts +11 -0
package/dist/browser/index.d.mts
CHANGED
|
@@ -295,7 +295,23 @@ declare class AreDirectiveContext extends A_ExecutionContext {
|
|
|
295
295
|
declare class AreDirectiveIf extends AreDirective {
|
|
296
296
|
transform(attribute: AreDirectiveAttribute, scope: A_Scope, store: AreStore, scene: AreScene, logger: A_Logger, ...args: any[]): void;
|
|
297
297
|
compile(attribute: AreDirectiveAttribute, store: AreStore, scene: AreScene, syntax: AreSyntax, directiveContext?: AreDirectiveContext, ...args: any[]): void;
|
|
298
|
-
update(attribute: AreDirectiveAttribute, store: AreStore, scope: A_Scope, syntax: AreSyntax, scene: AreScene, ...args: any[]): void;
|
|
298
|
+
update(attribute: AreDirectiveAttribute, store: AreStore, scope: A_Scope, syntax: AreSyntax, scene: AreScene, directiveContext?: AreDirectiveContext, ...args: any[]): void;
|
|
299
|
+
/**
|
|
300
|
+
* Evaluates the `$if` condition defensively.
|
|
301
|
+
*
|
|
302
|
+
* A condition can reference data that is momentarily unavailable — most
|
|
303
|
+
* commonly a nested `$if` (e.g. `$if="selected.fields.length"`) living
|
|
304
|
+
* inside a parent `$if="selected"` whose object has just become `null`.
|
|
305
|
+
* Because the nested directive is still subscribed to the store, its
|
|
306
|
+
* update fires on that same change and the raw expression would throw
|
|
307
|
+
* `Cannot read properties of null`, crashing the whole update pipeline.
|
|
308
|
+
*
|
|
309
|
+
* Treating an evaluation error as `false` is the correct contract for a
|
|
310
|
+
* conditional: if the condition cannot be resolved, the subtree simply
|
|
311
|
+
* stays hidden until the referenced data is present again (at which point
|
|
312
|
+
* the parent `$if` re-activates and re-evaluates this one).
|
|
313
|
+
*/
|
|
314
|
+
private evaluateCondition;
|
|
299
315
|
}
|
|
300
316
|
|
|
301
317
|
/**
|
|
@@ -777,7 +793,7 @@ declare class AreHTMLCompiler extends AreCompiler {
|
|
|
777
793
|
compileStaticAttribute(attribute: AreStaticAttribute, scene: AreScene, ...args: any[]): void;
|
|
778
794
|
compileDirectiveAttribute(directive: AreDirectiveAttribute, store: AreStore, feature: A_Feature, logger?: A_Logger, ...args: any[]): void;
|
|
779
795
|
compileEventAttribute(attribute: AreEventAttribute, scene: AreScene, ...args: any[]): void;
|
|
780
|
-
compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, ...args: any[]): void;
|
|
796
|
+
compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, ...args: any[]): void;
|
|
781
797
|
}
|
|
782
798
|
|
|
783
799
|
/**
|
package/dist/browser/index.mjs
CHANGED
|
@@ -952,9 +952,7 @@ var AreDirectiveIf = class extends AreDirective {
|
|
|
952
952
|
attribute.template = ifTemplate;
|
|
953
953
|
}
|
|
954
954
|
compile(attribute, store, scene, syntax, directiveContext, ...args) {
|
|
955
|
-
attribute.value =
|
|
956
|
-
...directiveContext?.scope || {}
|
|
957
|
-
});
|
|
955
|
+
attribute.value = this.evaluateCondition(syntax, attribute, store, directiveContext);
|
|
958
956
|
const hostInstruction = scene.host;
|
|
959
957
|
const commentIdentifier = ` --- if: ${attribute.template.id} --- `;
|
|
960
958
|
const declaration = new AddCommentInstruction({ content: commentIdentifier });
|
|
@@ -966,9 +964,9 @@ var AreDirectiveIf = class extends AreDirective {
|
|
|
966
964
|
else
|
|
967
965
|
attribute.template.scene.deactivate();
|
|
968
966
|
}
|
|
969
|
-
update(attribute, store, scope, syntax, scene, ...args) {
|
|
967
|
+
update(attribute, store, scope, syntax, scene, directiveContext, ...args) {
|
|
970
968
|
const previous = !!attribute.value;
|
|
971
|
-
const next =
|
|
969
|
+
const next = this.evaluateCondition(syntax, attribute, store, directiveContext);
|
|
972
970
|
attribute.value = next;
|
|
973
971
|
if (previous === next) return;
|
|
974
972
|
if (next) {
|
|
@@ -979,6 +977,30 @@ var AreDirectiveIf = class extends AreDirective {
|
|
|
979
977
|
attribute.template.scene.deactivate();
|
|
980
978
|
}
|
|
981
979
|
}
|
|
980
|
+
/**
|
|
981
|
+
* Evaluates the `$if` condition defensively.
|
|
982
|
+
*
|
|
983
|
+
* A condition can reference data that is momentarily unavailable — most
|
|
984
|
+
* commonly a nested `$if` (e.g. `$if="selected.fields.length"`) living
|
|
985
|
+
* inside a parent `$if="selected"` whose object has just become `null`.
|
|
986
|
+
* Because the nested directive is still subscribed to the store, its
|
|
987
|
+
* update fires on that same change and the raw expression would throw
|
|
988
|
+
* `Cannot read properties of null`, crashing the whole update pipeline.
|
|
989
|
+
*
|
|
990
|
+
* Treating an evaluation error as `false` is the correct contract for a
|
|
991
|
+
* conditional: if the condition cannot be resolved, the subtree simply
|
|
992
|
+
* stays hidden until the referenced data is present again (at which point
|
|
993
|
+
* the parent `$if` re-activates and re-evaluates this one).
|
|
994
|
+
*/
|
|
995
|
+
evaluateCondition(syntax, attribute, store, directiveContext) {
|
|
996
|
+
try {
|
|
997
|
+
return !!syntax.evaluate(attribute.content, store, {
|
|
998
|
+
...directiveContext?.scope || {}
|
|
999
|
+
});
|
|
1000
|
+
} catch {
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
982
1004
|
};
|
|
983
1005
|
__decorateClass([
|
|
984
1006
|
AreDirective.Transform,
|
|
@@ -1002,7 +1024,8 @@ __decorateClass([
|
|
|
1002
1024
|
__decorateParam(1, A_Inject(AreStore)),
|
|
1003
1025
|
__decorateParam(2, A_Inject(A_Scope)),
|
|
1004
1026
|
__decorateParam(3, A_Inject(AreSyntax)),
|
|
1005
|
-
__decorateParam(4, A_Inject(AreScene))
|
|
1027
|
+
__decorateParam(4, A_Inject(AreScene)),
|
|
1028
|
+
__decorateParam(5, A_Inject(AreDirectiveContext))
|
|
1006
1029
|
], AreDirectiveIf.prototype, "update", 1);
|
|
1007
1030
|
AreDirectiveIf = __decorateClass([
|
|
1008
1031
|
A_Frame.Define({
|
|
@@ -1789,7 +1812,7 @@ var AreHTMLCompiler = class extends AreCompiler {
|
|
|
1789
1812
|
handler: attribute.content
|
|
1790
1813
|
}));
|
|
1791
1814
|
}
|
|
1792
|
-
compileBindingAttribute(attribute, scene, parentStore, store, syntax, ...args) {
|
|
1815
|
+
compileBindingAttribute(attribute, scene, parentStore, store, syntax, directiveContext, ...args) {
|
|
1793
1816
|
if (!scene.host)
|
|
1794
1817
|
throw new AreCompilerError({
|
|
1795
1818
|
title: "Scene Host Not Found",
|
|
@@ -1825,11 +1848,12 @@ var AreHTMLCompiler = class extends AreCompiler {
|
|
|
1825
1848
|
}
|
|
1826
1849
|
return value;
|
|
1827
1850
|
};
|
|
1851
|
+
const directiveScope = () => directiveContext?.scope ?? {};
|
|
1828
1852
|
const watcher = {
|
|
1829
1853
|
update: () => {
|
|
1830
1854
|
try {
|
|
1831
1855
|
parentStore.watch(watcher);
|
|
1832
|
-
const next = coerce(syntax.evaluate(attribute.content, parentStore));
|
|
1856
|
+
const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));
|
|
1833
1857
|
parentStore.unwatch(watcher);
|
|
1834
1858
|
store.set(propName, next);
|
|
1835
1859
|
} catch (e) {
|
|
@@ -1838,7 +1862,7 @@ var AreHTMLCompiler = class extends AreCompiler {
|
|
|
1838
1862
|
}
|
|
1839
1863
|
};
|
|
1840
1864
|
parentStore.watch(watcher);
|
|
1841
|
-
const initial = coerce(syntax.evaluate(attribute.content, parentStore));
|
|
1865
|
+
const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));
|
|
1842
1866
|
parentStore.unwatch(watcher);
|
|
1843
1867
|
store.set(propName, initial);
|
|
1844
1868
|
return;
|
|
@@ -1894,7 +1918,8 @@ __decorateClass([
|
|
|
1894
1918
|
__decorateParam(2, A_Dependency.Parent()),
|
|
1895
1919
|
__decorateParam(2, A_Inject(AreStore)),
|
|
1896
1920
|
__decorateParam(3, A_Inject(AreStore)),
|
|
1897
|
-
__decorateParam(4, A_Inject(AreSyntax))
|
|
1921
|
+
__decorateParam(4, A_Inject(AreSyntax)),
|
|
1922
|
+
__decorateParam(5, A_Inject(AreDirectiveContext))
|
|
1898
1923
|
], AreHTMLCompiler.prototype, "compileBindingAttribute", 1);
|
|
1899
1924
|
AreHTMLCompiler = __decorateClass([
|
|
1900
1925
|
A_Frame.Define({
|