@yaks/native 0.0.0-stage → 0.2.36

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Jeff Peterson
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # @yaks/native
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@yaks/native` paints the kits' Preact tree as plain native nodes. Preact
4
+ renders into @yaks/dom's in-memory DOM, as it does for a terminal, and `paint`
5
+ reads that tree into the kinds of node a native host draws with its own widgets:
6
+
7
+ - `box`: a flex box holding other nodes, pressable when the element takes a
8
+ click;
9
+ - `text`: words in one text view, with nested styled runs (`b`, `a`, `code`, a
10
+ `br`'s line break);
11
+ - `field`: an `input` or `textarea`, with the acts typing and submitting are and
12
+ its `traits`, the keyboard its entry takes in React Native's `TextInput`
13
+ terms: an email's, a number's or a password's from its `type` and `inputmode`,
14
+ its return key from `enterkeyhint`, and whether submitting keeps the keyboard
15
+ up (it does in a form with a submit button, so one entry follows another);
16
+ - `toggle`: a check box or radio, its label the words around it;
17
+ - `pick`: a `select`, its options and the act of choosing one;
18
+ - `drawing`: an `svg` (an icon, a chart), its shapes with their attributes and
19
+ the look their classes give them;
20
+ - `image`: an `img`, its address and words;
21
+ - `web`: what only a browser draws (a canvas, a frame, a video), which a host
22
+ shows as a notice that it is on the app's web page;
23
+ - a press on a `text` or `box`, which clicks the element, and submits its form
24
+ when it is a submit button.
25
+
26
+ A tree that throws while it renders paints as a `web` notice saying what went
27
+ wrong, so a broken view never takes its host down. Every part of @yaks/ui's kit
28
+ paints as these nodes; embedded browser content paints as a `web` notice.
29
+
30
+ A closed `details` paints its `summary` alone, which a press opens, as a
31
+ browser's does.
32
+
33
+ The package imports no platform and holds no widget, so it runs and is tested
34
+ anywhere. The iOS shell (`native/kit.tsx` at the repository root) is the host
35
+ that turns each node into a React Native view.
36
+
37
+ ```ts ignore
38
+ import { createElement as h } from 'react'
39
+ import { look, mount } from '@yaks/native'
40
+
41
+ let unmount = mount(h(App, {}), look(colors), (node) => draw(node))
42
+ ```
43
+
44
+ `mount(tree, look, drawn, { fell, follow })` renders the tree and calls `drawn`
45
+ with its painted nodes after every change, as a terminal repaints; `fell` hears
46
+ what a broken tree threw, and `follow` is given each pressed link no listener
47
+ took. The DOM is one per process, so one tree is mounted at a time.
48
+ `paint(element, look)` paints one element without mounting.
49
+
50
+ A node's style is its tag's defaults merged with the native style of each class
51
+ it wears, read from a `Look`. Words take the text style (colour, size, weight)
52
+ of the boxes around them, which a native box does not pass on by itself.
53
+ `@yaks/native/remote` is what a host outside a browser needs of the app itself:
54
+ `nativeOf(page, fetch)` is the view its front page names
55
+ (`<link rel="yaks-native" href="view.ts">`), `viewAt(url, carried, fetch)` loads
56
+ that module and what it imports by relative path, compiled from TypeScript, with
57
+ the host's own copies of the app's `"platform"` packages (`carried`) standing in
58
+ for them, and `store(api, fetch)` is the app's store over HTTP. The module's
59
+ default export is a component taking that `store`. The iOS shell and `yak open`
60
+ in a terminal (@yaks/browse) are its two hosts, each with its own `fetch`.
61
+
62
+ `look(colors, composition?)` is the native look over a theme's colours: the
63
+ tags' defaults, and each class's style, which every @yaks/ui part carries beside
64
+ its terminal `sheet` (`native`). The composition's kits and skin, @yaks/ui's own
65
+ by default, say which parts and how they are worn, so a white-labelled app
66
+ themes the look with data alone.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The native look a host reads through `paint`: the tags' defaults, and the
3
+ * style of each class the kit parts render (`Card`, `Card_Head`,
4
+ * `Button-go`), which each part carries beside its terminal `sheet` in
5
+ * @yaks/ui (`native`).
6
+ *
7
+ * @module
8
+ */ import { type Colors, type Composition } from "@yaks/ui";
9
+ import type { Look } from "./mod.js";
10
+ export type { Colors };
11
+ /** The native look over a theme's colours, of the parts in `at`'s kits as
12
+ * its skin wears them, @yaks/ui's own composition by default. A
13
+ * white-labelled app themes it with data: its colours, and the composition
14
+ * it wears. */ export declare let look: (c: Colors, at?: Composition) => Look;
15
+ //# sourceMappingURL=look.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"look.d.ts","sources":["../look.ts"],"names":[],"mappings":"AAAA;;;;;;;CAOC,GAED,SAAS,KAAK,MAAM,EAAE,KAAK,WAAW,wBAAkD;AACxF,cAAc,IAAI,mBAAkB;AAEpC,cAAc,MAAM,GAAE;AAEtB;;;aAGa,GACb,OAAO,YAAI,OAAQ,GAAG,QAAQ,KAAI,gBAA4B,KA8D5D"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,130 @@
1
+ /**
2
+ * @yaks/native: the kits' component tree, painted as native views. The host
3
+ * renders into @yaks/dom's in-memory DOM, as it does for a terminal; `paint`
4
+ * reads that tree into plain nodes a native host draws with its own widgets:
5
+ * a box, a run of text, a press, a field, a toggle, a pick, a drawing, an
6
+ * image, and what only a browser draws (`web`). It holds no widget and
7
+ * imports no platform, so it runs and is tested anywhere; the host (the iOS
8
+ * shell's `native/kit.tsx`) maps each node to a React Native view.
9
+ *
10
+ * A node's look is the merge of its tag's defaults and the native style of
11
+ * each class it wears, read from a {@link Look} (look.ts). What a press or a
12
+ * typed character means stays the app's: the node carries the act that
13
+ * delivers it to the element, as a browser's event would.
14
+ *
15
+ * @module
16
+ */ import { type ReactNode } from "@types/react";
17
+ import { type TElement } from "@yaks/dom";
18
+ /** A native style: a React Native style object's keys and values. */ export type Style = Record<string, string | number>;
19
+ /** The native look: each class's style, and each tag's. */ export type Look = {
20
+ classes: Record<string, Style>;
21
+ tags: Record<string, Style>;
22
+ };
23
+ /** One run of text inside a text node: words, or a styled inline element. */ export type Run = string | Text;
24
+ /** Words, drawn in one native text view; nested runs keep their style. */ export type Text = {
25
+ kind: 'text';
26
+ key: number;
27
+ style: Style;
28
+ runs: Run[];
29
+ press?: () => void;
30
+ };
31
+ /** A box laid out by flex, holding other nodes. */ export type Box = {
32
+ kind: 'box';
33
+ key: number;
34
+ style: Style;
35
+ children: Node[];
36
+ press?: () => void;
37
+ };
38
+ /** How a field's keyboard behaves, in React Native's `TextInput` terms,
39
+ * read from what the element says it takes (`type`, `inputmode`,
40
+ * `enterkeyhint`, `autocomplete`, `autocapitalize`, `autofocus`). */ export type Traits = {
41
+ keyboardType?: 'email-address' | 'numeric' | 'decimal-pad' | 'phone-pad' | 'url' | 'web-search';
42
+ secureTextEntry?: boolean;
43
+ returnKeyType: 'done' | 'go' | 'next' | 'search' | 'send';
44
+ autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
45
+ autoCorrect?: boolean;
46
+ autoComplete?: string;
47
+ autoFocus?: boolean;
48
+ editable?: boolean;
49
+ /** whether submitting keeps the keyboard up: a form that takes one entry
50
+ * after another (a list's "add") does, a lone field does not */ submitBehavior: 'submit' | 'blurAndSubmit' | 'newline';
51
+ };
52
+ /** A text field: what it shows, how its keyboard behaves, and the acts
53
+ * typing and submitting are. */ export type Field = {
54
+ kind: 'field';
55
+ key: number;
56
+ style: Style;
57
+ value: string;
58
+ placeholder: string;
59
+ lines: boolean;
60
+ traits: Traits;
61
+ type: (text: string) => void;
62
+ submit: () => void;
63
+ };
64
+ /** A choice of one among options (a `select`): the chosen value, what each
65
+ * option says, and the act of choosing one. */ export type Pick = {
66
+ kind: 'pick';
67
+ key: number;
68
+ style: Style;
69
+ value: string;
70
+ options: {
71
+ value: string;
72
+ label: string;
73
+ }[];
74
+ disabled: boolean;
75
+ choose: (value: string) => void;
76
+ };
77
+ /** One shape of a drawing: its tag (`path`, `circle`, `rect`, …), its
78
+ * attributes, the look its classes give it (`fill`, `stroke`), and the
79
+ * shapes it holds. */ export type Shape = {
80
+ tag: string;
81
+ attrs: Record<string, string>;
82
+ style: Style;
83
+ shapes: Shape[];
84
+ };
85
+ /** Lines and shapes (an `svg`, as an icon or a chart is), drawn in its
86
+ * words' colour where it says `currentColor`. */ export type Drawing = {
87
+ kind: 'drawing';
88
+ key: number;
89
+ style: Style;
90
+ attrs: Record<string, string>;
91
+ shapes: Shape[];
92
+ };
93
+ /** A picture from an address. */ export type Picture = {
94
+ kind: 'image';
95
+ key: number;
96
+ style: Style;
97
+ uri: string;
98
+ alt: string;
99
+ };
100
+ /** What only a browser draws (a canvas, a frame, a video), or a view that
101
+ * broke: shown as a notice that it is on the app's web page. */ export type Web = {
102
+ kind: 'web';
103
+ key: number;
104
+ style: Style;
105
+ tag: string;
106
+ words: string;
107
+ };
108
+ /** A check box: whether it is on, and the act of flipping it. */ export type Toggle = {
109
+ kind: 'toggle';
110
+ key: number;
111
+ style: Style;
112
+ on: boolean;
113
+ label: Run[];
114
+ flip: () => void;
115
+ };
116
+ /** What a native host draws. */ export type Node = Text | Box | Field | Toggle | Pick | Drawing | Picture | Web;
117
+ /** How a field's keyboard behaves: what it takes, as its attributes say,
118
+ * and whether submitting keeps it up (a form with a submit button does, so
119
+ * one entry follows another, as a list's "add" field does on iOS). */ export declare let traits: (el: TElement) => Traits;
120
+ /** Paint one element and what it holds as native nodes; a text node beside
121
+ * elements becomes a text of its own, since a native box holds no bare
122
+ * words. */ export declare let paint: (el: TElement, look: Look, around?: Style) => Node | null;
123
+ /** Render a tree into the in-memory DOM and hand `drawn` its painted nodes
124
+ * after every change, as a terminal repaints; the answer unmounts it. The
125
+ * DOM is one per process, so one tree is mounted at a time. A tree that
126
+ * throws while it renders paints as a {@link Web} notice saying so, and
127
+ * `fell` hears what it threw; a pressed link no listener took is `follow`ed,
128
+ * as a browser loads it. */ export declare let mount: (node: ReactNode, look: Look, drawn: (painted: Node | null) => void, _dts_1: never) => () => void;
129
+ export { type Colors, look } from "./look.js";
130
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAEyC,SAAwC,KAAK,SAAS,uBAA0B;AAE1H,S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;EACP,OAAO,OAAO,MAAM,EAAE,MAAM;EAC5B,QAAQ;;AAGV,+BAA+B,GAC/B,YAAY;EACV,MAAM;EACN,KAAK,MAAM;EACX,OAAO;EACP,KAAK,MAAM;EACX,KAAK,MAAM;;AAGb;8DAC8D,GAC9D,YAAY;EACV,MAAM;EACN,KAAK,MAAM;EACX,OAAO;EACP,KAAK,MAAM;EACX,OAAO,MAAM;;AAGf,+DAA+D,GAC/D,YAAY;EACV,MAAM;EACN,KAAK,MAAM;EACX,OAAO;EACP,IAAI,OAAO;EACX,OAAO;EACP,YAAY,IAAI;;AAGlB,8BAA8B,GAC9B,YAAY,OAAO,OAAO,MAAM,QAAQ,SAAS,OAAO,UAAU,UAAU;AAqJ5E;;oEAEoE,GACpE,OAAO,YAAI,SAAU,IAAI,aAAW,OAwBnC;AAyFD;;UAEU,GACV,OAAO,YAAI,QACT,IAAI,UACJ,MAAM,MACN,SAAQ,UACP,OAAO,IAAI,CA8Db;AAwBD;;;;;0BAK0B,GAC1B,OAAO,YAAI,QACT,MAAM,WACN,MAAM,MACN,QAAQ,SAAS,OAAO,IAAI,KAAK,IAAI,EACrC,wBAIO,IAAI,CAsBZ;AAED,SAAS,KAAK,MAAM,EAAE,IAAI,oBAAmB"}
@@ -0,0 +1,45 @@
1
+ import type { ComponentType } from "@types/react";
2
+ /** The packages a host carries for a remote view, by the names it imports
3
+ * them by: `{ preact, 'preact/hooks': hooks, '@yaks/ui': ui }`. */ export type Carried = Record<string, unknown>;
4
+ /** A view module's component: it draws the app over its store. */ export type NativeView = ComponentType<{
5
+ store: Store;
6
+ }>;
7
+ /** An app's store, as a page's `./api/client.js` offers it. */ export type Store = {
8
+ query: <T = unknown>(filter: string) => Promise<T[]>;
9
+ apply: (bundles: object[]) => Promise<unknown>;
10
+ };
11
+ /** The app's view could not be loaded; its web page still opens. */ export declare class Unloadable extends Error {
12
+ }
13
+ /** A path against the URL it is named from, as a browser resolves an href:
14
+ * absolute, from the origin, or beside the file.
15
+ *
16
+ * ```ts
17
+ * import { assertEquals } from '@std/assert'
18
+ * let page = 'https://a.yaks.app/packing/'
19
+ * assertEquals(against(page, 'view.ts'), 'https://a.yaks.app/packing/view.ts')
20
+ * assertEquals(against(page + 'lib/a.ts', '../b.ts'), page + 'b.ts')
21
+ * assertEquals(against(page, '/x/'), 'https://a.yaks.app/x/')
22
+ * ```
23
+ */ export declare let against: (from: string, path: string) => string;
24
+ /** The URL of the view a page names, against its `<base>` when it has one,
25
+ * or null when it names none.
26
+ *
27
+ * ```ts
28
+ * import { assertEquals } from '@std/assert'
29
+ * let html = '<base href="/packing/"><link rel="yaks-native" href="view.ts">'
30
+ * assertEquals(
31
+ * viewOf(html, 'https://a.yaks.app/packing'),
32
+ * 'https://a.yaks.app/packing/view.ts',
33
+ * )
34
+ * assertEquals(viewOf('<link rel="icon" href="i.png">', 'https://a/'), null)
35
+ * ```
36
+ */ export declare let viewOf: (html: string, page: string) => string | null;
37
+ /** The URL of the view an app's page names, or null when it names none. */ export declare let nativeOf: (page: string, go?: typeof fetch) => Promise<string | null>;
38
+ /** Fetch a view's module graph so its host can select the renderer before it runs. */ export declare let prepareView: (url: string, go?: typeof fetch) => Promise<{
39
+ imports: string[];
40
+ open: (carried: Carried) => NativeView;
41
+ }>;
42
+ /** Load a view module and what it imports, its platform packages the host's. */ export declare let viewAt: (url: string, carried: Carried, go?: typeof fetch) => Promise<NativeView>;
43
+ /** An app's store over HTTP, at its `api` (`https://a.yaks.app/packing/api`),
44
+ * as its page's `./api/client.js` offers it. */ export declare let store: (api: string, go?: typeof fetch) => Store;
45
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","sources":["../remote.ts"],"names":[],"mappings":"AAmB0C,cAAc,aAAa,uBAA0B;AAE/F;iEACiE,GACjE,YAAY,UAAU,OAAO,MAAM,EAAE,OAAO;AAE5C,gEAAgE,GAChE,YAAY,aAAa;EAAgB,OAAO;;AAEhD,6DAA6D,GAC7D,YAAY;EACV,QAAQ,IAAI,OAAO,EAAE,QAAQ,MAAM,KAAK,QAAQ;EAChD,QAAQ,SAAS,MAAM,OAAO,QAAQ,OAAO;;AAG/C,kEAAkE,GAClE,OAAO,cAAM,mBAAmB;AAAO;AAEvC;;;;;;;;;;CAUC,GACD,OAAO,YAAI,UAAW,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,CAUxD;AASD;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SAAU,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,IAAI,CAK9D;AAED,yEAAyE,GACzE,OAAO,YAAI,WACT,MAAM,MAAM,EACZ,YAAW,UACV,QAAQ,MAAM,GAAG,IAAI,EAOvB;AAqDD,oFAAoF,GACpF,OAAO,YAAI,cACT,KAAK,MAAM,EACX,YAAW,UACV;EAAU,SAAS,MAAM;EAAI,OAAO,SAAS,YAAY;GA2B3D;AAED,8EAA8E,GAC9E,OAAO,YAAI,SACT,KAAK,MAAM,EACX,SAAS,SACT,YAAW,UACV,QAAQ,YAAyD;AAepE;8CAC8C,GAC9C,OAAO,YAAI,QAAS,KAAK,MAAM,EAAE,YAAW,UAAgB,MAe1D"}
package/deno.json ADDED
@@ -0,0 +1 @@
1
+ {"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/native","version":"0.2.36","license":"Apache-2.0","description":"Loads a kit-built app's view and store outside a browser and turns its Preact tree into native nodes that a host draws with its own widgets.","exports":{".":"./mod.ts","./remote":"./remote.ts"},"imports":{"@yaks/native":"./mod.ts","@yaks/native/remote":"./remote.ts"}}
package/look.js ADDED
@@ -0,0 +1,171 @@
1
+ /**
2
+ * The native look a host reads through `paint`: the tags' defaults, and the
3
+ * style of each class the kit parts render (`Card`, `Card_Head`,
4
+ * `Button-go`), which each part carries beside its terminal `sheet` in
5
+ * @yaks/ui (`native`).
6
+ *
7
+ * @module
8
+ */ import { composition, native } from "@yaks/ui";
9
+ /** The native look over a theme's colours, of the parts in `at`'s kits as
10
+ * its skin wears them, @yaks/ui's own composition by default. A
11
+ * white-labelled app themes it with data: its colours, and the composition
12
+ * it wears. */ export let look = (c, at = composition)=>({
13
+ tags: {
14
+ root: {
15
+ flex: 1,
16
+ backgroundColor: c.bg
17
+ },
18
+ main: {
19
+ padding: 16,
20
+ gap: 16
21
+ },
22
+ h1: {
23
+ fontSize: 28,
24
+ fontWeight: '700',
25
+ color: c.heading
26
+ },
27
+ h2: {
28
+ fontSize: 20,
29
+ fontWeight: '600',
30
+ color: c.heading
31
+ },
32
+ h3: {
33
+ fontSize: 17,
34
+ fontWeight: '600',
35
+ color: c.heading
36
+ },
37
+ p: {
38
+ fontSize: 16,
39
+ color: c.text
40
+ },
41
+ span: {
42
+ color: c.text
43
+ },
44
+ label: {
45
+ fontSize: 16,
46
+ color: c.text
47
+ },
48
+ ul: {
49
+ gap: 4
50
+ },
51
+ li: {
52
+ fontSize: 16,
53
+ color: c.text
54
+ },
55
+ a: {
56
+ color: c.link
57
+ },
58
+ b: {
59
+ fontWeight: '700'
60
+ },
61
+ strong: {
62
+ fontWeight: '700'
63
+ },
64
+ em: {
65
+ fontStyle: 'italic'
66
+ },
67
+ code: {
68
+ fontFamily: 'Menlo',
69
+ fontSize: 14,
70
+ color: c.literal
71
+ },
72
+ pre: {
73
+ fontFamily: 'Menlo',
74
+ fontSize: 13,
75
+ color: c.text
76
+ },
77
+ details: {
78
+ gap: 6
79
+ },
80
+ summary: {
81
+ fontSize: 15,
82
+ color: c.muted
83
+ },
84
+ dl: {
85
+ gap: 4
86
+ },
87
+ dt: {
88
+ fontSize: 13,
89
+ color: c.dim
90
+ },
91
+ dd: {
92
+ fontSize: 15,
93
+ color: c.text,
94
+ paddingLeft: 8
95
+ },
96
+ time: {
97
+ fontSize: 12,
98
+ color: c.dim
99
+ },
100
+ form: {
101
+ flexDirection: 'row',
102
+ gap: 8,
103
+ alignItems: 'center'
104
+ },
105
+ button: {
106
+ paddingVertical: 10,
107
+ paddingHorizontal: 14,
108
+ borderRadius: 10,
109
+ color: c.accent,
110
+ fontSize: 16,
111
+ fontWeight: '600'
112
+ },
113
+ img: {
114
+ width: 64,
115
+ height: 64,
116
+ borderRadius: 8
117
+ },
118
+ hr: {
119
+ height: 1,
120
+ backgroundColor: c.border,
121
+ marginVertical: 8
122
+ },
123
+ table: {
124
+ gap: 2
125
+ },
126
+ tr: {
127
+ flexDirection: 'row',
128
+ gap: 12
129
+ },
130
+ th: {
131
+ flex: 1,
132
+ fontSize: 13,
133
+ fontWeight: '600',
134
+ color: c.dim
135
+ },
136
+ td: {
137
+ flex: 1,
138
+ fontSize: 15,
139
+ color: c.text
140
+ },
141
+ select: {
142
+ fontSize: 16,
143
+ color: c.text,
144
+ backgroundColor: c.surface,
145
+ borderColor: c.border,
146
+ borderWidth: 1,
147
+ borderRadius: 10,
148
+ paddingVertical: 10,
149
+ paddingHorizontal: 12
150
+ },
151
+ input: {
152
+ flex: 1,
153
+ fontSize: 16,
154
+ color: c.text,
155
+ backgroundColor: c.surface,
156
+ borderColor: c.border,
157
+ borderWidth: 1,
158
+ borderRadius: 10,
159
+ paddingVertical: 10,
160
+ paddingHorizontal: 12
161
+ }
162
+ },
163
+ classes: native({
164
+ ...at,
165
+ theme: {
166
+ ...at.theme,
167
+ colors: c
168
+ }
169
+ })
170
+ });
171
+ //# sourceMappingURL=look.js.map
package/look.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"look.js","sources":["./look.ts"],"names":[],"mappings":"AAAA;;;;;;;CAOC,GAED,SAAwC,WAAW,EAAE,MAAM,wBAA6B;AAKxF;;;aAGa,GACb,OAAO,IAAI,OAAO,CAAC,GAAW,KAAkB,WAAW,GAAW,CAAC;IACrE,MAAM;MACJ,MAAM;QAAE,MAAM;QAAG,iBAAiB,EAAE,EAAE;MAAC;MACvC,MAAM;QAAE,SAAS;QAAI,KAAK;MAAG;MAC7B,IAAI;QAAE,UAAU;QAAI,YAAY;QAAO,OAAO,EAAE,OAAO;MAAC;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