@adukiorg/anza 0.2.0 → 0.2.2
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 +81 -4
- package/README.md +97 -133
- package/bin/anza/anza +0 -0
- package/bin/anza/anza.exe +0 -0
- package/bin/anza/find.js +35 -0
- package/bin/anza/index.js +34 -0
- package/bin/anza/launch.js +19 -0
- package/bin/common/index.js +7 -0
- package/bin/common/logs.js +62 -0
- package/bin/create/copy.js +18 -0
- package/bin/create/index.js +45 -0
- package/bin/create/run.js +210 -0
- package/bin/create/write.js +19 -0
- package/importmap.json +4 -0
- package/package.json +16 -10
- package/src/core/offline/{usage.md → notes/usage.md} +11 -1
- package/src/core/router/boot.js +82 -0
- package/src/core/router/cascade.js +76 -0
- package/src/core/router/container.js +63 -72
- package/src/core/router/graph.js +144 -0
- package/src/core/router/index.js +12 -2
- package/src/core/router/intercept.js +26 -7
- package/src/core/router/lca.js +58 -0
- package/src/core/router/match.js +49 -36
- package/src/core/router/notes/audit-old.md +887 -0
- package/src/core/router/notes/audti.md +773 -0
- package/src/core/router/notes/tasks.md +473 -0
- package/src/core/router/{usage.md → notes/usage.md} +57 -35
- package/src/core/router/sync/tab.js +6 -4
- package/src/core/router/transitions.js +35 -8
- package/src/core/router/trie.js +130 -0
- package/src/core/security/{usage.md → notes/usage.md} +1 -2
- package/src/core/storage/{usage.md → notes/usage.md} +6 -6
- package/src/core/theme/index.js +78 -0
- package/src/core/ui/define/index.js +2 -1
- package/src/core/ui/define/orchestrator.js +10 -4
- package/src/core/ui/defs/dock.js +134 -0
- package/src/core/ui/defs/index.js +20 -0
- package/src/core/ui/defs/page.js +89 -0
- package/src/core/ui/defs/part.js +28 -0
- package/src/core/ui/defs/spec.js +96 -0
- package/src/core/ui/defs/view.js +23 -0
- package/src/core/ui/index.js +16 -3
- package/src/core/ui/notes/definations.md +979 -0
- package/src/tokens/index.css +1 -0
- package/src/tokens/semantic/contrast.css +18 -0
- package/src/tokens/semantic/transitions.css +32 -0
- package/types/core/platform/index.d.ts +39 -10
- package/types/core/router/index.d.ts +9 -0
- package/types/core/theme/index.d.ts +18 -0
- package/types/core/ui/index.d.ts +11 -0
- package/types/index.d.ts +1 -0
- package/bin/anza.js +0 -63
- package/bin/create.js +0 -150
- package/src/core/api/plan.md +0 -209
- package/src/core/events/missing.md +0 -103
- package/src/core/events/plan.md +0 -177
- package/src/core/offline/missing.md +0 -89
- package/src/core/offline/plan.md +0 -143
- package/src/core/platform/missing.md +0 -119
- package/src/core/platform/platform.d.ts +0 -88
- package/src/core/router/missing.md +0 -716
- package/src/core/router/outlet.js +0 -139
- package/src/core/router/plan.md +0 -370
- package/src/core/security/missing.md +0 -97
- package/src/core/state/missing.md +0 -165
- package/src/core/storage/missing.md +0 -165
- package/src/core/storage/plan.md +0 -69
- package/src/core/ui/implementation.md +0 -170
- package/src/core/ui/plan.md +0 -510
- package/src/core/ui/ui.types.md +0 -890
- /package/src/core/animations/{usage.md → notes/usage.md} +0 -0
- /package/src/core/api/{usage.md → notes/usage.md} +0 -0
- /package/src/core/events/{usage.md → notes/usage.md} +0 -0
- /package/src/core/platform/{usage.md → notes/usage.md} +0 -0
- /package/src/core/state/{usage.md → notes/usage.md} +0 -0
- /package/src/core/ui/{usage.md → notes/usage.md} +0 -0
- /package/src/core/ui/{watch.md → notes/watch.md} +0 -0
- /package/src/core/workers/{plan.md → notes/plan.md} +0 -0
- /package/src/core/workers/{usage.md → notes/usage.md} +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/core/ui/defs/spec.js
|
|
3
|
+
*
|
|
4
|
+
* Shared translator. Converts the declarative `page`/`dock`/`view`/`part`
|
|
5
|
+
* config shape (from definations.md) into the lower-level `element()` spec
|
|
6
|
+
* shape (element.js), so the four definition helpers reuse one battle-tested
|
|
7
|
+
* custom-element factory instead of each re-implementing props, resources,
|
|
8
|
+
* shadow DOM, and update batching.
|
|
9
|
+
*
|
|
10
|
+
* Config shape (definations.md):
|
|
11
|
+
* {
|
|
12
|
+
* tag, props, query, methods,
|
|
13
|
+
* template: { html, css, shadow },
|
|
14
|
+
* on: { load, connect, disconnect, change, ...helpers }
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* Source: tasks.md Phase 6
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// Lifecycle hook names that map onto the factory's mount/unmount/update slots.
|
|
21
|
+
// Every other entry under `on` is installed as a plain instance method so a
|
|
22
|
+
// hook body can call `this.render()` etc.
|
|
23
|
+
const HOOKS = new Set(['load', 'connect', 'disconnect', 'change']);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Collects the route-derived params currently set on an element, keyed by the
|
|
27
|
+
* declared prop names. Used to hand `on.load`/`on.connect` a `{ params }` bag.
|
|
28
|
+
*/
|
|
29
|
+
function paramsOf(el, props) {
|
|
30
|
+
const out = {};
|
|
31
|
+
if (props) {
|
|
32
|
+
for (const key of Object.keys(props)) out[key] = el[key];
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Translates a declarative definition config into an `element()` spec.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} config - the page/dock/view/part config.
|
|
41
|
+
* @param {object} [opts]
|
|
42
|
+
* @param {boolean} [opts.visual=false] - route updates through rAF when true.
|
|
43
|
+
* @returns {object} a spec consumable by element().
|
|
44
|
+
*/
|
|
45
|
+
export function translate(config, opts = {}) {
|
|
46
|
+
const spec = {};
|
|
47
|
+
const tpl = config.template ?? {};
|
|
48
|
+
|
|
49
|
+
// Template + style + shadow mode. `element()` takes html/css as separate
|
|
50
|
+
// string fields (inline source or a resolvable file path) and a shadow mode.
|
|
51
|
+
if (tpl.html != null) spec.template = tpl.html;
|
|
52
|
+
if (tpl.css != null) spec.style = tpl.css;
|
|
53
|
+
spec.mode = tpl.shadow === 'closed' ? 'closed' : 'open';
|
|
54
|
+
if (tpl.shadow === false) {
|
|
55
|
+
console.warn('[Native UI] Light DOM (shadow: false) is not supported by the element factory; falling back to open shadow root.');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (config.props) spec.props = config.props;
|
|
59
|
+
if (config.form) spec.form = config.form;
|
|
60
|
+
if (config.query) spec.query = config.query;
|
|
61
|
+
|
|
62
|
+
// Install all `on` entries (helpers + hooks) and explicit `methods` as
|
|
63
|
+
// instance methods, so a hook body can call `this.<helper>()`.
|
|
64
|
+
const on = config.on ?? {};
|
|
65
|
+
const methods = { ...config.methods };
|
|
66
|
+
for (const [name, fn] of Object.entries(on)) {
|
|
67
|
+
if (typeof fn === 'function') methods[name] = fn;
|
|
68
|
+
}
|
|
69
|
+
if (Object.keys(methods).length) spec.methods = methods;
|
|
70
|
+
|
|
71
|
+
// Map lifecycle hooks onto the factory's slots, invoking each with
|
|
72
|
+
// `this` bound to the element and the lifecycle context as the argument.
|
|
73
|
+
if (on.load || on.connect) {
|
|
74
|
+
spec.mount = async (ctx) => {
|
|
75
|
+
const el = ctx.el;
|
|
76
|
+
if (on.load) {
|
|
77
|
+
await on.load.call(el, { params: paramsOf(el, config.props), ...ctx });
|
|
78
|
+
}
|
|
79
|
+
if (on.connect) {
|
|
80
|
+
await on.connect.call(el, ctx);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (on.disconnect) {
|
|
86
|
+
spec.unmount = (ctx) => on.disconnect.call(ctx.el, ctx);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (on.change) {
|
|
90
|
+
const update = (ctx) => on.change.call(ctx.el, ctx);
|
|
91
|
+
if (opts.visual) update.visual = true;
|
|
92
|
+
spec.update = update;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return spec;
|
|
96
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/core/ui/defs/view.js
|
|
3
|
+
*
|
|
4
|
+
* `view(tag, config, base)` — a composable, stateful Web Component with no
|
|
5
|
+
* route and no container-graph presence. The router never touches it directly.
|
|
6
|
+
* A `page` is a `view` that also owns a URL.
|
|
7
|
+
*
|
|
8
|
+
* Source: definations.md §5, tasks.md Phase 6
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { element } from '../define/element.js';
|
|
12
|
+
import { translate } from './spec.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} tag - custom element tag name (must contain a hyphen).
|
|
16
|
+
* @param {object} config - view definition (props, template, on, methods).
|
|
17
|
+
* @param {string} [base] - import.meta.url of the caller; required when
|
|
18
|
+
* template/style are file paths.
|
|
19
|
+
*/
|
|
20
|
+
export function view(tag, config, base) {
|
|
21
|
+
const spec = translate(config, { visual: true });
|
|
22
|
+
element(tag, spec, base);
|
|
23
|
+
}
|
package/src/core/ui/index.js
CHANGED
|
@@ -9,22 +9,30 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { BaseElement } from './base.js';
|
|
12
|
-
import { define, element, container } from './define/index.js';
|
|
12
|
+
import { define, element, container, page, dock, view, part } from './define/index.js';
|
|
13
13
|
import { schedule, scheduleFrame, yieldTask } from './schedule.js';
|
|
14
14
|
import { transition } from './transitions.js';
|
|
15
15
|
import { template } from './template.js';
|
|
16
16
|
import * as observe from './observe.js';
|
|
17
|
+
import { theme } from '../theme/index.js';
|
|
18
|
+
|
|
19
|
+
export * from './defs/index.js';
|
|
17
20
|
|
|
18
21
|
export const ui = {
|
|
19
22
|
define,
|
|
20
23
|
element,
|
|
21
24
|
container,
|
|
25
|
+
page,
|
|
26
|
+
dock,
|
|
27
|
+
view,
|
|
28
|
+
part,
|
|
22
29
|
schedule,
|
|
23
30
|
scheduleFrame,
|
|
24
31
|
yield: yieldTask,
|
|
25
32
|
transition,
|
|
26
33
|
template,
|
|
27
|
-
observe
|
|
34
|
+
observe,
|
|
35
|
+
theme
|
|
28
36
|
};
|
|
29
37
|
|
|
30
38
|
export {
|
|
@@ -32,10 +40,15 @@ export {
|
|
|
32
40
|
define,
|
|
33
41
|
element,
|
|
34
42
|
container,
|
|
43
|
+
page,
|
|
44
|
+
dock,
|
|
45
|
+
view,
|
|
46
|
+
part,
|
|
35
47
|
schedule,
|
|
36
48
|
scheduleFrame,
|
|
37
49
|
yieldTask,
|
|
38
50
|
transition,
|
|
39
51
|
template,
|
|
40
|
-
observe
|
|
52
|
+
observe,
|
|
53
|
+
theme
|
|
41
54
|
};
|