@kosdev-code/kos-asset-manager 0.0.1-next.31 → 0.0.1-next.32
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/README.md +49 -0
- package/bin/lib/declare-assets.mjs +24 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -184,6 +184,55 @@ tell what the root is, rather than guessing one. The target it writes then
|
|
|
184
184
|
scans the right folder and follows the project's own `descriptor` target
|
|
185
185
|
wherever that writes.
|
|
186
186
|
|
|
187
|
+
## Content in its own section
|
|
188
|
+
|
|
189
|
+
Content usually ships inside an application's section, and then it belongs to
|
|
190
|
+
that application: the kab's assets join the application's context and are
|
|
191
|
+
addressed by its id. Content that ships in a section of its own has no
|
|
192
|
+
application to take a name from, so it names itself:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"kondra": {
|
|
197
|
+
"ui": {
|
|
198
|
+
"assets": {
|
|
199
|
+
"context": "tccc.brandset",
|
|
200
|
+
"mediaSrc": "assets/logos",
|
|
201
|
+
"mediaRoot": "/logos"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
That name is what a ui asks for and addresses it by, exactly like an
|
|
209
|
+
application id:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
<KosAssetProvider contexts={['my.app.id', 'tccc.brandset']} gate>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
wrapAsset('tccc.brandset:coke/pour');
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Content in its own section that names nothing belongs to its manifest
|
|
220
|
+
section, under the section's name. Two kabs naming the same context
|
|
221
|
+
contribute to the same one.
|
|
222
|
+
|
|
223
|
+
Shipping separately is also what lets content replace what an application
|
|
224
|
+
declares. Within one context the first declaration of a key wins and the rest
|
|
225
|
+
are ignored, so a brandset packaged alongside an application can only add to
|
|
226
|
+
it. As its own context it is a separate set of keys, and a ui chooses which
|
|
227
|
+
one wins by the order it lists them in `contexts`.
|
|
228
|
+
|
|
229
|
+
Everything you author under `kondra.ui.assets` carries through to the
|
|
230
|
+
declaration, with what the build derives landing on top. The exception is the
|
|
231
|
+
handful of settings that drive the build rather than describe the result —
|
|
232
|
+
`keys`, `tags`, `mediaSrc`, `mediaRoot`, and the pattern form of `groups` and
|
|
233
|
+
`entries` — which are expanded into what the device reads and not shipped as
|
|
234
|
+
written.
|
|
235
|
+
|
|
187
236
|
## Installing
|
|
188
237
|
|
|
189
238
|
```sh
|
|
@@ -57,6 +57,20 @@ const TYPES = {
|
|
|
57
57
|
*/
|
|
58
58
|
const DATA_TYPES = new Set(['.json']);
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Authored to drive the build rather than to be read on the device. Patterns
|
|
62
|
+
* and partial entries are expanded into the real thing, so passing them
|
|
63
|
+
* through would ship a `groups` of patterns the device would read as keys.
|
|
64
|
+
*/
|
|
65
|
+
const BUILD_INPUTS = new Set([
|
|
66
|
+
'keys',
|
|
67
|
+
'tags',
|
|
68
|
+
'entries',
|
|
69
|
+
'groups',
|
|
70
|
+
'mediaSrc',
|
|
71
|
+
'mediaRoot',
|
|
72
|
+
]);
|
|
73
|
+
|
|
60
74
|
const isMedia = (name) => {
|
|
61
75
|
const ext = name.slice(name.lastIndexOf('.')).toLowerCase();
|
|
62
76
|
return Boolean(TYPES[ext]) && !DATA_TYPES.has(ext);
|
|
@@ -526,7 +540,16 @@ const buildAssets = (projectRoot) => {
|
|
|
526
540
|
);
|
|
527
541
|
}
|
|
528
542
|
|
|
543
|
+
// what a project authors under kondra.ui.assets carries through to the
|
|
544
|
+
// declaration, and what the build derives lands on top of it -- so a field
|
|
545
|
+
// the device reads, like the context a brandset belongs to, is authored
|
|
546
|
+
// once and needs nothing here to know about it
|
|
547
|
+
const authored = Object.fromEntries(
|
|
548
|
+
Object.entries(declared).filter(([key]) => !BUILD_INPUTS.has(key))
|
|
549
|
+
);
|
|
550
|
+
|
|
529
551
|
return {
|
|
552
|
+
...authored,
|
|
530
553
|
root: mediaRoot(declared),
|
|
531
554
|
entries,
|
|
532
555
|
...(Object.keys(groups).length > 0 ? { groups } : {}),
|
|
@@ -539,6 +562,7 @@ export {
|
|
|
539
562
|
ASSETS_ROOT,
|
|
540
563
|
TYPES,
|
|
541
564
|
DATA_TYPES,
|
|
565
|
+
BUILD_INPUTS,
|
|
542
566
|
isMedia,
|
|
543
567
|
mediaSource,
|
|
544
568
|
mediaRoot,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-asset-manager",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"kos": {
|
|
27
27
|
"build": {
|
|
28
|
-
"gitHash": "
|
|
28
|
+
"gitHash": "c7ed2185841d6bf5f7709af1d03dfbbd838e116b"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|