@mal-icons/core 0.1.0
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 +103 -0
- package/dist/index.cjs +73 -0
- package/dist/index.d.ts +130 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @mal-icons/core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@mal-icons/core)
|
|
4
|
+
[](https://github.com/mal-icons/mal-icons/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
The framework-agnostic foundation of [**mal-icons**](https://github.com/mal-icons/mal-icons) —
|
|
7
|
+
shared TypeScript types and theming utilities used by every framework adapter
|
|
8
|
+
(React, Vue, Svelte, Preact, Solid, Angular, Astro, React Native, and the web
|
|
9
|
+
renderer).
|
|
10
|
+
|
|
11
|
+
You normally don't install this package directly — it ships as a dependency of
|
|
12
|
+
each adapter. Install it only when you are **building your own adapter** or
|
|
13
|
+
need the shared types and theming primitives in framework-neutral code.
|
|
14
|
+
|
|
15
|
+
## Why it exists
|
|
16
|
+
|
|
17
|
+
Every mal-icons adapter renders the **same SVG markup** from the **same data
|
|
18
|
+
model**. `@mal-icons/core` is where that contract lives:
|
|
19
|
+
|
|
20
|
+
- One serializable icon data model (`IconData`, `IconNode`, `NodeTuple`).
|
|
21
|
+
- One prop surface (`IconBaseProps`) and theming contract (`IconContextValue`).
|
|
22
|
+
- One override-resolution rule (`resolveIconAttrs`) so per-icon props always
|
|
23
|
+
beat context.
|
|
24
|
+
- One set of differentiators: stroke `weight` presets and pure-CSS animations.
|
|
25
|
+
|
|
26
|
+
There is **no runtime dependency** and **no framework code** — just types and a
|
|
27
|
+
few tiny pure functions.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add @mal-icons/core
|
|
33
|
+
# or
|
|
34
|
+
npm install @mal-icons/core
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## What's inside
|
|
38
|
+
|
|
39
|
+
### Types
|
|
40
|
+
|
|
41
|
+
| Export | Description |
|
|
42
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `IconNode` | Recursive `{ tag, attr, child }` build-time icon shape |
|
|
44
|
+
| `NodeTuple` | Compact `[tag, attr]` tuple used at render time |
|
|
45
|
+
| `IconData` | Minimal `{ viewBox, nodes, defaultAttr? }` render payload |
|
|
46
|
+
| `IconDefinition` | Fully-described, deduplicatable icon (used by the pipeline) |
|
|
47
|
+
| `IconBaseProps<St>` | Props every generated icon component accepts |
|
|
48
|
+
| `IconContextValue<St>` | Theming values supplied through a framework provider |
|
|
49
|
+
| `IconsManifest` | Top-level manifest describing all available icon sets |
|
|
50
|
+
| `IconWeight` | `"thin" \| "light" \| "regular" \| "bold"` |
|
|
51
|
+
| `IconAnimation` | `"spin" \| "spin-reverse" \| "pulse" \| "beat" \| "bounce" \| "ping" \| "shake" \| "wiggle" \| "float" \| "heartbeat" \| "flip" \| "rotate" \| "zoom" \| "fade" \| "slide" \| "glow" \| "swing" \| "tada"` |
|
|
52
|
+
|
|
53
|
+
### Utilities
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import {
|
|
57
|
+
resolveIconAttrs,
|
|
58
|
+
WEIGHT_STROKE_WIDTH,
|
|
59
|
+
animationClass,
|
|
60
|
+
ICON_ANIMATIONS_CSS,
|
|
61
|
+
} from "@mal-icons/core";
|
|
62
|
+
|
|
63
|
+
// Merge per-icon props over context, following the override priority:
|
|
64
|
+
// props.color > context.color
|
|
65
|
+
// props.size > context.size > "1em"
|
|
66
|
+
const { size, color, className } = resolveIconAttrs(
|
|
67
|
+
{ size: 24, color: "#3366ff" },
|
|
68
|
+
{ size: 20 },
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Map a stroke weight preset to a concrete stroke-width.
|
|
72
|
+
WEIGHT_STROKE_WIDTH.bold; // 3
|
|
73
|
+
|
|
74
|
+
// Class name applied to the <svg> for a CSS animation.
|
|
75
|
+
animationClass("spin"); // "mal-icons-animate-spin"
|
|
76
|
+
|
|
77
|
+
// Inject once to enable the CSS animation presets (with a built-in
|
|
78
|
+
// prefers-reduced-motion guard).
|
|
79
|
+
document.head.insertAdjacentHTML(
|
|
80
|
+
"beforeend",
|
|
81
|
+
`<style>${ICON_ANIMATIONS_CSS}</style>`,
|
|
82
|
+
);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Building your own adapter
|
|
86
|
+
|
|
87
|
+
A framework adapter only needs to:
|
|
88
|
+
|
|
89
|
+
1. Read theming from `IconContextValue` via the framework's context/provider.
|
|
90
|
+
2. Call `resolveIconAttrs(props, context)` to compute the final attributes.
|
|
91
|
+
3. Render an `<svg viewBox={data.viewBox}>` and map `data.nodes` to elements.
|
|
92
|
+
|
|
93
|
+
That's the entire contract — the generated icon modules supply the `IconData`.
|
|
94
|
+
|
|
95
|
+
## Repository
|
|
96
|
+
|
|
97
|
+
Source, issues, and contribution guidelines live in the monorepo:
|
|
98
|
+
<https://github.com/mal-icons/mal-icons> · package directory
|
|
99
|
+
[`packages/core`](https://github.com/mal-icons/mal-icons/tree/main/packages/core).
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
[MIT](https://github.com/mal-icons/mal-icons/blob/main/LICENSE) © MALDevs
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// packages/core/src/index.ts
|
|
40
|
+
var exports_src = {};
|
|
41
|
+
__export(exports_src, {
|
|
42
|
+
resolveIconAttrs: () => resolveIconAttrs,
|
|
43
|
+
animationClass: () => animationClass,
|
|
44
|
+
WEIGHT_STROKE_WIDTH: () => WEIGHT_STROKE_WIDTH,
|
|
45
|
+
ICON_ANIMATIONS_CSS: () => ICON_ANIMATIONS_CSS
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(exports_src);
|
|
48
|
+
var WEIGHT_STROKE_WIDTH = {
|
|
49
|
+
thin: 1,
|
|
50
|
+
light: 1.5,
|
|
51
|
+
regular: 2,
|
|
52
|
+
bold: 3
|
|
53
|
+
};
|
|
54
|
+
function animationClass(animation) {
|
|
55
|
+
return `mal-icon-animate-${animation}`;
|
|
56
|
+
}
|
|
57
|
+
var ICON_ANIMATIONS_CSS = `@keyframes mal-icon-spin{to{transform:rotate(360deg)}}
|
|
58
|
+
@keyframes mal-icon-pulse{0%,100%{opacity:1}50%{opacity:.4}}
|
|
59
|
+
@keyframes mal-icon-beat{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}
|
|
60
|
+
@keyframes mal-icon-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-15%)}}
|
|
61
|
+
.mal-icon-animate-spin{animation:mal-icon-spin 1s linear infinite;will-change:transform}
|
|
62
|
+
.mal-icon-animate-spin-reverse{animation:mal-icon-spin 1s linear infinite reverse;will-change:transform}
|
|
63
|
+
.mal-icon-animate-pulse{animation:mal-icon-pulse 1.5s ease-in-out infinite}
|
|
64
|
+
.mal-icon-animate-beat{animation:mal-icon-beat 1s ease-in-out infinite;will-change:transform}
|
|
65
|
+
.mal-icon-animate-bounce{animation:mal-icon-bounce 1s ease infinite;will-change:transform}
|
|
66
|
+
@media (prefers-reduced-motion:reduce){[class*=mal-icon-animate-]{animation:none}}
|
|
67
|
+
`;
|
|
68
|
+
function resolveIconAttrs(props, context) {
|
|
69
|
+
const size = props.size ?? context.size ?? "1em";
|
|
70
|
+
const color = props.color ?? context.color;
|
|
71
|
+
const className = [context.className, props.className].filter(Boolean).join(" ") || undefined;
|
|
72
|
+
return { size, color, className };
|
|
73
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-agnostic icon data model.
|
|
3
|
+
*
|
|
4
|
+
* At build time we emit compile-time component code, but this is the
|
|
5
|
+
* intermediate, serializable model used by the pipeline and adapters.
|
|
6
|
+
*/
|
|
7
|
+
export interface IconNode {
|
|
8
|
+
/** Element tag, e.g. "path", "g", "circle". */
|
|
9
|
+
tag: string;
|
|
10
|
+
/** Element attributes, e.g. `{ d: "M0 0..." }`. */
|
|
11
|
+
attr: Record<string, string>;
|
|
12
|
+
/** Nested child nodes. */
|
|
13
|
+
child: IconNode[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A compact `[tag, attributes]` tuple used by the runtime `createIcon`
|
|
17
|
+
* factory. Children are built once at module load, never per render.
|
|
18
|
+
*/
|
|
19
|
+
export type NodeTuple = [tag: string, attr: Record<string, string>];
|
|
20
|
+
/**
|
|
21
|
+
* Minimal, serializable icon payload used by lazy/CDN and dynamic-by-name
|
|
22
|
+
* loaders. Mirrors what `createIcon` needs to render without bundling the
|
|
23
|
+
* whole set.
|
|
24
|
+
*/
|
|
25
|
+
export interface IconData {
|
|
26
|
+
/** SVG viewBox, e.g. "0 0 24 24". */
|
|
27
|
+
viewBox: string;
|
|
28
|
+
/** Shape children as compact tuples. */
|
|
29
|
+
nodes: NodeTuple[];
|
|
30
|
+
/** Optional root attributes (e.g. `fill: "none"`) for stroke-style sets. */
|
|
31
|
+
defaultAttr?: Record<string, string | number>;
|
|
32
|
+
}
|
|
33
|
+
/** A fully-described, deduplicatable icon definition. */
|
|
34
|
+
export interface IconDefinition {
|
|
35
|
+
/** PascalCase component name, e.g. "FiActivity". */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Set identifier, e.g. "fi" (Feather), "fa" (Font Awesome). */
|
|
38
|
+
set: string;
|
|
39
|
+
/** SVG viewBox, e.g. "0 0 24 24". */
|
|
40
|
+
viewBox: string;
|
|
41
|
+
/** Shape children of the icon. */
|
|
42
|
+
nodes: IconNode[];
|
|
43
|
+
/** Stable content hash, used for deduplication and determinism. */
|
|
44
|
+
contentHash: string;
|
|
45
|
+
}
|
|
46
|
+
/** A single icon set entry within the manifest. */
|
|
47
|
+
export interface IconSetManifestEntry {
|
|
48
|
+
/** Set identifier, e.g. "fa". */
|
|
49
|
+
id: string;
|
|
50
|
+
/** Human-readable name, e.g. "Font Awesome 6". */
|
|
51
|
+
name: string;
|
|
52
|
+
/** SPDX (or free-form) license identifier of the source set. */
|
|
53
|
+
license: string;
|
|
54
|
+
/** Number of icons in the set. */
|
|
55
|
+
count: number;
|
|
56
|
+
}
|
|
57
|
+
/** Top-level manifest describing all available icon sets. */
|
|
58
|
+
export interface IconsManifest {
|
|
59
|
+
sets: IconSetManifestEntry[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Runtime props accepted by every generated icon component.
|
|
63
|
+
*
|
|
64
|
+
* `St` is the framework-specific inline-style type, kept generic so
|
|
65
|
+
* `core` stays framework-agnostic.
|
|
66
|
+
*/
|
|
67
|
+
export interface IconBaseProps<St = Record<string, unknown>> {
|
|
68
|
+
/** Width and height. Defaults to "1em". */
|
|
69
|
+
size?: string | number;
|
|
70
|
+
/** Overrides `currentColor`. */
|
|
71
|
+
color?: string;
|
|
72
|
+
/** Accessible label; renders a `<title>` element. */
|
|
73
|
+
title?: string;
|
|
74
|
+
/** Additional class name(s). */
|
|
75
|
+
className?: string;
|
|
76
|
+
/** Inline styles. */
|
|
77
|
+
style?: St;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Theming configuration provided through a framework context/provider.
|
|
81
|
+
* Per-icon props always override these context values.
|
|
82
|
+
*/
|
|
83
|
+
export interface IconContextValue<St = Record<string, unknown>> {
|
|
84
|
+
color?: string;
|
|
85
|
+
size?: string | number;
|
|
86
|
+
className?: string;
|
|
87
|
+
style?: St;
|
|
88
|
+
/** Extra attributes spread onto the root `<svg>`. */
|
|
89
|
+
attr?: Record<string, string>;
|
|
90
|
+
}
|
|
91
|
+
/** Resolved attributes returned by {@link resolveIconAttrs}. */
|
|
92
|
+
export interface ResolvedIconAttrs {
|
|
93
|
+
size: string | number;
|
|
94
|
+
color: string | undefined;
|
|
95
|
+
className: string | undefined;
|
|
96
|
+
}
|
|
97
|
+
/** Stroke weight presets for stroke-based icon sets. */
|
|
98
|
+
export type IconWeight = "thin" | "light" | "regular" | "bold";
|
|
99
|
+
/** Maps a {@link IconWeight} to a concrete SVG `stroke-width`. */
|
|
100
|
+
export declare const WEIGHT_STROKE_WIDTH: Record<IconWeight, number>;
|
|
101
|
+
/** CSS-driven animation presets applied via the `animate` prop. */
|
|
102
|
+
export type IconAnimation = "spin" | "spin-reverse" | "pulse" | "beat" | "bounce";
|
|
103
|
+
/** Class name applied to the root `<svg>` for a given animation. */
|
|
104
|
+
export declare function animationClass(animation: IconAnimation): string;
|
|
105
|
+
/**
|
|
106
|
+
* CSS keyframes + classes backing {@link IconAnimation}. Consumers inject
|
|
107
|
+
* this once (e.g. a `<style>` tag); animations are pure CSS so they add no
|
|
108
|
+
* JS cost and only animate the icons that opt in (SRS §16.2).
|
|
109
|
+
*/
|
|
110
|
+
export declare const ICON_ANIMATIONS_CSS = "@keyframes mal-icons-spin{to{transform:rotate(360deg)}}\n@keyframes mal-icons-pulse{0%,100%{opacity:1}50%{opacity:.4}}\n@keyframes mal-icons-beat{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}\n@keyframes mal-icons-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-15%)}}\n.mal-icons-animate-spin{animation:mal-icons-spin 1s linear infinite;will-change:transform}\n.mal-icons-animate-spin-reverse{animation:mal-icons-spin 1s linear infinite reverse;will-change:transform}\n.mal-icons-animate-pulse{animation:mal-icons-pulse 1.5s ease-in-out infinite}\n.mal-icons-animate-beat{animation:mal-icons-beat 1s ease-in-out infinite;will-change:transform}\n.mal-icons-animate-bounce{animation:mal-icons-bounce 1s ease infinite;will-change:transform}\n@media (prefers-reduced-motion:reduce){[class*=mal-icons-animate-]{animation:none}}\n";
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the final size/color/className given per-icon props and the
|
|
113
|
+
* surrounding context, following the SRS override priority:
|
|
114
|
+
*
|
|
115
|
+
* ```
|
|
116
|
+
* props.color > context.color
|
|
117
|
+
* props.size > context.size > "1em"
|
|
118
|
+
* className = context.className + " " + props.className
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function resolveIconAttrs(props: {
|
|
122
|
+
size?: string | number;
|
|
123
|
+
color?: string;
|
|
124
|
+
className?: string;
|
|
125
|
+
}, context: {
|
|
126
|
+
size?: string | number;
|
|
127
|
+
color?: string;
|
|
128
|
+
className?: string;
|
|
129
|
+
}): ResolvedIconAttrs;
|
|
130
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// packages/core/src/index.ts
|
|
2
|
+
var WEIGHT_STROKE_WIDTH = {
|
|
3
|
+
thin: 1,
|
|
4
|
+
light: 1.5,
|
|
5
|
+
regular: 2,
|
|
6
|
+
bold: 3
|
|
7
|
+
};
|
|
8
|
+
function animationClass(animation) {
|
|
9
|
+
return `mal-icon-animate-${animation}`;
|
|
10
|
+
}
|
|
11
|
+
var ICON_ANIMATIONS_CSS = `@keyframes mal-icon-spin{to{transform:rotate(360deg)}}
|
|
12
|
+
@keyframes mal-icon-pulse{0%,100%{opacity:1}50%{opacity:.4}}
|
|
13
|
+
@keyframes mal-icon-beat{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}
|
|
14
|
+
@keyframes mal-icon-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-15%)}}
|
|
15
|
+
.mal-icon-animate-spin{animation:mal-icon-spin 1s linear infinite;will-change:transform}
|
|
16
|
+
.mal-icon-animate-spin-reverse{animation:mal-icon-spin 1s linear infinite reverse;will-change:transform}
|
|
17
|
+
.mal-icon-animate-pulse{animation:mal-icon-pulse 1.5s ease-in-out infinite}
|
|
18
|
+
.mal-icon-animate-beat{animation:mal-icon-beat 1s ease-in-out infinite;will-change:transform}
|
|
19
|
+
.mal-icon-animate-bounce{animation:mal-icon-bounce 1s ease infinite;will-change:transform}
|
|
20
|
+
@media (prefers-reduced-motion:reduce){[class*=mal-icon-animate-]{animation:none}}
|
|
21
|
+
`;
|
|
22
|
+
function resolveIconAttrs(props, context) {
|
|
23
|
+
const size = props.size ?? context.size ?? "1em";
|
|
24
|
+
const color = props.color ?? context.color;
|
|
25
|
+
const className = [context.className, props.className].filter(Boolean).join(" ") || undefined;
|
|
26
|
+
return { size, color, className };
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
resolveIconAttrs,
|
|
30
|
+
animationClass,
|
|
31
|
+
WEIGHT_STROKE_WIDTH,
|
|
32
|
+
ICON_ANIMATIONS_CSS
|
|
33
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mal-icons/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-agnostic types and theming utilities for mal-icons.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "MALDevs",
|
|
8
|
+
"homepage": "https://github.com/mal-icons/mal-icons#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/mal-icons/mal-icons/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/mal-icons/mal-icons.git",
|
|
15
|
+
"directory": "packages/core"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["icons", "svg", "typescript", "theming", "mal-icons"],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"files": ["dist", "!dist/.tsbuildinfo"],
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"bun": "./src/index.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|