@netlisian/softconfig 0.0.9 → 0.0.11
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/puck/index.d.mts +2 -0
- package/dist/puck/index.d.ts +2 -0
- package/dist/puck/index.js +68 -9
- package/dist/puck/index.mjs +68 -9
- package/package.json +2 -2
package/dist/puck/index.d.mts
CHANGED
|
@@ -265,6 +265,8 @@ type AppStore = {
|
|
|
265
265
|
removeSoftCategoryConfig: (key: string) => void;
|
|
266
266
|
builder: BuildersSlice;
|
|
267
267
|
setSoftComponent: (key: string, version: string, component: SoftComponent) => void;
|
|
268
|
+
setSoftComponents: (components: SoftComponents) => void;
|
|
269
|
+
hydrateTransforms: () => void;
|
|
268
270
|
setSoftComponentDefaultVersion: (key: string, version: string) => void;
|
|
269
271
|
removeSoftComponent: (key: string) => void;
|
|
270
272
|
};
|
package/dist/puck/index.d.ts
CHANGED
|
@@ -265,6 +265,8 @@ type AppStore = {
|
|
|
265
265
|
removeSoftCategoryConfig: (key: string) => void;
|
|
266
266
|
builder: BuildersSlice;
|
|
267
267
|
setSoftComponent: (key: string, version: string, component: SoftComponent) => void;
|
|
268
|
+
setSoftComponents: (components: SoftComponents) => void;
|
|
269
|
+
hydrateTransforms: () => void;
|
|
268
270
|
setSoftComponentDefaultVersion: (key: string, version: string) => void;
|
|
269
271
|
removeSoftComponent: (key: string) => void;
|
|
270
272
|
};
|
package/dist/puck/index.js
CHANGED
|
@@ -1905,6 +1905,65 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
1905
1905
|
};
|
|
1906
1906
|
});
|
|
1907
1907
|
},
|
|
1908
|
+
setSoftComponents: (incomingComponents) => {
|
|
1909
|
+
const state = get();
|
|
1910
|
+
const nextSoftComponents = __spreadValues({}, state.softComponents);
|
|
1911
|
+
const nextConfigComponents = __spreadValues({}, state.softConfig.components);
|
|
1912
|
+
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
1913
|
+
const existing = nextSoftComponents[name];
|
|
1914
|
+
const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
1915
|
+
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
1916
|
+
}) : data;
|
|
1917
|
+
nextSoftComponents[name] = finalComponentData;
|
|
1918
|
+
const activeVersion = finalComponentData.defaultVersion;
|
|
1919
|
+
const activeVersionData = finalComponentData.versions[activeVersion];
|
|
1920
|
+
if (activeVersionData) {
|
|
1921
|
+
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
1922
|
+
name,
|
|
1923
|
+
activeVersion,
|
|
1924
|
+
Object.keys(finalComponentData.versions),
|
|
1925
|
+
state.softConfig,
|
|
1926
|
+
nextSoftComponents,
|
|
1927
|
+
activeVersionData.defaultProps
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1931
|
+
set({
|
|
1932
|
+
softComponents: nextSoftComponents,
|
|
1933
|
+
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
1934
|
+
components: nextConfigComponents
|
|
1935
|
+
})
|
|
1936
|
+
});
|
|
1937
|
+
},
|
|
1938
|
+
hydrateTransforms: () => {
|
|
1939
|
+
const { overrides: overrides2, softComponents: softComponents2, softConfig } = get();
|
|
1940
|
+
if (!(overrides2 == null ? void 0 : overrides2.hydrateMapTransform)) return;
|
|
1941
|
+
const hydratedComponents = hydrateSoftComponentsTransforms(
|
|
1942
|
+
softComponents2,
|
|
1943
|
+
overrides2.hydrateMapTransform
|
|
1944
|
+
);
|
|
1945
|
+
const nextConfigComponents = __spreadValues({}, softConfig.components);
|
|
1946
|
+
Object.entries(hydratedComponents).forEach(([name, componentData]) => {
|
|
1947
|
+
const activeVersion = componentData.defaultVersion;
|
|
1948
|
+
const activeVersionData = componentData.versions[activeVersion];
|
|
1949
|
+
if (activeVersionData) {
|
|
1950
|
+
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
1951
|
+
name,
|
|
1952
|
+
activeVersion,
|
|
1953
|
+
Object.keys(componentData.versions),
|
|
1954
|
+
softConfig,
|
|
1955
|
+
hydratedComponents,
|
|
1956
|
+
activeVersionData.defaultProps
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1959
|
+
});
|
|
1960
|
+
set({
|
|
1961
|
+
softComponents: hydratedComponents,
|
|
1962
|
+
softConfig: __spreadProps(__spreadValues({}, softConfig), {
|
|
1963
|
+
components: nextConfigComponents
|
|
1964
|
+
})
|
|
1965
|
+
});
|
|
1966
|
+
},
|
|
1908
1967
|
setSoftComponentDefaultVersion: (name, version) => {
|
|
1909
1968
|
var _a, _b, _c;
|
|
1910
1969
|
const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
@@ -2124,7 +2183,7 @@ var useBuild = () => {
|
|
|
2124
2183
|
try {
|
|
2125
2184
|
build(history, selectedItem, itemSelector, dispatch);
|
|
2126
2185
|
if (selectedItem == null ? void 0 : selectedItem.type) {
|
|
2127
|
-
triggerAction({
|
|
2186
|
+
void triggerAction({
|
|
2128
2187
|
type: "build",
|
|
2129
2188
|
payload: {
|
|
2130
2189
|
id: selectedItem.type
|
|
@@ -2165,7 +2224,7 @@ var useRemodel = () => {
|
|
|
2165
2224
|
}
|
|
2166
2225
|
try {
|
|
2167
2226
|
remodel(history, selectedItem, itemSelector, dispatch);
|
|
2168
|
-
triggerAction({
|
|
2227
|
+
void triggerAction({
|
|
2169
2228
|
type: "remodel",
|
|
2170
2229
|
payload: {
|
|
2171
2230
|
id: name
|
|
@@ -2209,7 +2268,7 @@ var useComplete = () => {
|
|
|
2209
2268
|
const componentData = appState.data.root;
|
|
2210
2269
|
const softComponent = (_b = softComponents[componentName]) == null ? void 0 : _b.versions[(_a = softComponents[componentName]) == null ? void 0 : _a.defaultVersion];
|
|
2211
2270
|
if (softComponent && componentData) {
|
|
2212
|
-
triggerAction({
|
|
2271
|
+
void triggerAction({
|
|
2213
2272
|
type: "complete",
|
|
2214
2273
|
payload: {
|
|
2215
2274
|
id: componentName,
|
|
@@ -2246,7 +2305,7 @@ var useCancel = () => {
|
|
|
2246
2305
|
}
|
|
2247
2306
|
try {
|
|
2248
2307
|
cancel(setHistories);
|
|
2249
|
-
triggerAction({
|
|
2308
|
+
void triggerAction({
|
|
2250
2309
|
type: "cancel",
|
|
2251
2310
|
payload: {}
|
|
2252
2311
|
});
|
|
@@ -2278,7 +2337,7 @@ var useInspect = (componentName) => {
|
|
|
2278
2337
|
}
|
|
2279
2338
|
try {
|
|
2280
2339
|
inspect(componentName, dispatch);
|
|
2281
|
-
triggerAction({
|
|
2340
|
+
void triggerAction({
|
|
2282
2341
|
type: "inspect",
|
|
2283
2342
|
payload: {
|
|
2284
2343
|
id: componentName
|
|
@@ -2337,7 +2396,7 @@ var useDecompose = () => {
|
|
|
2337
2396
|
type: "setData",
|
|
2338
2397
|
data: newData
|
|
2339
2398
|
});
|
|
2340
|
-
triggerAction({
|
|
2399
|
+
void triggerAction({
|
|
2341
2400
|
type: "decompose",
|
|
2342
2401
|
payload: {
|
|
2343
2402
|
id: componentName
|
|
@@ -2378,7 +2437,7 @@ var useDemolish = () => {
|
|
|
2378
2437
|
}
|
|
2379
2438
|
try {
|
|
2380
2439
|
demolish(componentName, data, dispatch);
|
|
2381
|
-
triggerAction({
|
|
2440
|
+
void triggerAction({
|
|
2382
2441
|
type: "demolish",
|
|
2383
2442
|
payload: {
|
|
2384
2443
|
id: componentName
|
|
@@ -2417,7 +2476,7 @@ var useSetDefaultVersion = () => {
|
|
|
2417
2476
|
return;
|
|
2418
2477
|
}
|
|
2419
2478
|
setSoftComponentDefaultVersion(componentName, version);
|
|
2420
|
-
triggerAction({
|
|
2479
|
+
void triggerAction({
|
|
2421
2480
|
type: "setDefaultVersion",
|
|
2422
2481
|
payload: {
|
|
2423
2482
|
id: componentName,
|
|
@@ -2473,7 +2532,7 @@ var usePublish = () => {
|
|
|
2473
2532
|
const rootComponentType = (_a = data.root) == null ? void 0 : _a.type;
|
|
2474
2533
|
const rootVersion = (_b = components[rootComponentType]) == null ? void 0 : _b.defaultVersion;
|
|
2475
2534
|
if (rootComponentType && rootVersion) {
|
|
2476
|
-
triggerAction({
|
|
2535
|
+
void triggerAction({
|
|
2477
2536
|
type: "publish",
|
|
2478
2537
|
payload: {
|
|
2479
2538
|
id: rootComponentType,
|
package/dist/puck/index.mjs
CHANGED
|
@@ -1855,6 +1855,65 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
1855
1855
|
};
|
|
1856
1856
|
});
|
|
1857
1857
|
},
|
|
1858
|
+
setSoftComponents: (incomingComponents) => {
|
|
1859
|
+
const state = get();
|
|
1860
|
+
const nextSoftComponents = __spreadValues({}, state.softComponents);
|
|
1861
|
+
const nextConfigComponents = __spreadValues({}, state.softConfig.components);
|
|
1862
|
+
Object.entries(incomingComponents).forEach(([name, data]) => {
|
|
1863
|
+
const existing = nextSoftComponents[name];
|
|
1864
|
+
const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
|
|
1865
|
+
versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
|
|
1866
|
+
}) : data;
|
|
1867
|
+
nextSoftComponents[name] = finalComponentData;
|
|
1868
|
+
const activeVersion = finalComponentData.defaultVersion;
|
|
1869
|
+
const activeVersionData = finalComponentData.versions[activeVersion];
|
|
1870
|
+
if (activeVersionData) {
|
|
1871
|
+
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
1872
|
+
name,
|
|
1873
|
+
activeVersion,
|
|
1874
|
+
Object.keys(finalComponentData.versions),
|
|
1875
|
+
state.softConfig,
|
|
1876
|
+
nextSoftComponents,
|
|
1877
|
+
activeVersionData.defaultProps
|
|
1878
|
+
);
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
set({
|
|
1882
|
+
softComponents: nextSoftComponents,
|
|
1883
|
+
softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
|
|
1884
|
+
components: nextConfigComponents
|
|
1885
|
+
})
|
|
1886
|
+
});
|
|
1887
|
+
},
|
|
1888
|
+
hydrateTransforms: () => {
|
|
1889
|
+
const { overrides: overrides2, softComponents: softComponents2, softConfig } = get();
|
|
1890
|
+
if (!(overrides2 == null ? void 0 : overrides2.hydrateMapTransform)) return;
|
|
1891
|
+
const hydratedComponents = hydrateSoftComponentsTransforms(
|
|
1892
|
+
softComponents2,
|
|
1893
|
+
overrides2.hydrateMapTransform
|
|
1894
|
+
);
|
|
1895
|
+
const nextConfigComponents = __spreadValues({}, softConfig.components);
|
|
1896
|
+
Object.entries(hydratedComponents).forEach(([name, componentData]) => {
|
|
1897
|
+
const activeVersion = componentData.defaultVersion;
|
|
1898
|
+
const activeVersionData = componentData.versions[activeVersion];
|
|
1899
|
+
if (activeVersionData) {
|
|
1900
|
+
nextConfigComponents[name] = createVersionedComponentConfig(
|
|
1901
|
+
name,
|
|
1902
|
+
activeVersion,
|
|
1903
|
+
Object.keys(componentData.versions),
|
|
1904
|
+
softConfig,
|
|
1905
|
+
hydratedComponents,
|
|
1906
|
+
activeVersionData.defaultProps
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
set({
|
|
1911
|
+
softComponents: hydratedComponents,
|
|
1912
|
+
softConfig: __spreadProps(__spreadValues({}, softConfig), {
|
|
1913
|
+
components: nextConfigComponents
|
|
1914
|
+
})
|
|
1915
|
+
});
|
|
1916
|
+
},
|
|
1858
1917
|
setSoftComponentDefaultVersion: (name, version) => {
|
|
1859
1918
|
var _a, _b, _c;
|
|
1860
1919
|
const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
|
|
@@ -2074,7 +2133,7 @@ var useBuild = () => {
|
|
|
2074
2133
|
try {
|
|
2075
2134
|
build(history, selectedItem, itemSelector, dispatch);
|
|
2076
2135
|
if (selectedItem == null ? void 0 : selectedItem.type) {
|
|
2077
|
-
triggerAction({
|
|
2136
|
+
void triggerAction({
|
|
2078
2137
|
type: "build",
|
|
2079
2138
|
payload: {
|
|
2080
2139
|
id: selectedItem.type
|
|
@@ -2115,7 +2174,7 @@ var useRemodel = () => {
|
|
|
2115
2174
|
}
|
|
2116
2175
|
try {
|
|
2117
2176
|
remodel(history, selectedItem, itemSelector, dispatch);
|
|
2118
|
-
triggerAction({
|
|
2177
|
+
void triggerAction({
|
|
2119
2178
|
type: "remodel",
|
|
2120
2179
|
payload: {
|
|
2121
2180
|
id: name
|
|
@@ -2159,7 +2218,7 @@ var useComplete = () => {
|
|
|
2159
2218
|
const componentData = appState.data.root;
|
|
2160
2219
|
const softComponent = (_b = softComponents[componentName]) == null ? void 0 : _b.versions[(_a = softComponents[componentName]) == null ? void 0 : _a.defaultVersion];
|
|
2161
2220
|
if (softComponent && componentData) {
|
|
2162
|
-
triggerAction({
|
|
2221
|
+
void triggerAction({
|
|
2163
2222
|
type: "complete",
|
|
2164
2223
|
payload: {
|
|
2165
2224
|
id: componentName,
|
|
@@ -2196,7 +2255,7 @@ var useCancel = () => {
|
|
|
2196
2255
|
}
|
|
2197
2256
|
try {
|
|
2198
2257
|
cancel(setHistories);
|
|
2199
|
-
triggerAction({
|
|
2258
|
+
void triggerAction({
|
|
2200
2259
|
type: "cancel",
|
|
2201
2260
|
payload: {}
|
|
2202
2261
|
});
|
|
@@ -2228,7 +2287,7 @@ var useInspect = (componentName) => {
|
|
|
2228
2287
|
}
|
|
2229
2288
|
try {
|
|
2230
2289
|
inspect(componentName, dispatch);
|
|
2231
|
-
triggerAction({
|
|
2290
|
+
void triggerAction({
|
|
2232
2291
|
type: "inspect",
|
|
2233
2292
|
payload: {
|
|
2234
2293
|
id: componentName
|
|
@@ -2287,7 +2346,7 @@ var useDecompose = () => {
|
|
|
2287
2346
|
type: "setData",
|
|
2288
2347
|
data: newData
|
|
2289
2348
|
});
|
|
2290
|
-
triggerAction({
|
|
2349
|
+
void triggerAction({
|
|
2291
2350
|
type: "decompose",
|
|
2292
2351
|
payload: {
|
|
2293
2352
|
id: componentName
|
|
@@ -2328,7 +2387,7 @@ var useDemolish = () => {
|
|
|
2328
2387
|
}
|
|
2329
2388
|
try {
|
|
2330
2389
|
demolish(componentName, data, dispatch);
|
|
2331
|
-
triggerAction({
|
|
2390
|
+
void triggerAction({
|
|
2332
2391
|
type: "demolish",
|
|
2333
2392
|
payload: {
|
|
2334
2393
|
id: componentName
|
|
@@ -2367,7 +2426,7 @@ var useSetDefaultVersion = () => {
|
|
|
2367
2426
|
return;
|
|
2368
2427
|
}
|
|
2369
2428
|
setSoftComponentDefaultVersion(componentName, version);
|
|
2370
|
-
triggerAction({
|
|
2429
|
+
void triggerAction({
|
|
2371
2430
|
type: "setDefaultVersion",
|
|
2372
2431
|
payload: {
|
|
2373
2432
|
id: componentName,
|
|
@@ -2423,7 +2482,7 @@ var usePublish = () => {
|
|
|
2423
2482
|
const rootComponentType = (_a = data.root) == null ? void 0 : _a.type;
|
|
2424
2483
|
const rootVersion = (_b = components[rootComponentType]) == null ? void 0 : _b.defaultVersion;
|
|
2425
2484
|
if (rootComponentType && rootVersion) {
|
|
2426
|
-
triggerAction({
|
|
2485
|
+
void triggerAction({
|
|
2427
2486
|
type: "publish",
|
|
2428
2487
|
payload: {
|
|
2429
2488
|
id: rootComponentType,
|
package/package.json
CHANGED