@superblocksteam/cli 2.0.0-next.6 → 2.0.0-next.7
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 +1 -1
- package/dist/index.js +55 -51
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ $ npm install -g @superblocksteam/cli
|
|
|
14
14
|
$ superblocks COMMAND
|
|
15
15
|
running command...
|
|
16
16
|
$ superblocks (--version)
|
|
17
|
-
@superblocksteam/cli/2.0.0-next.
|
|
17
|
+
@superblocksteam/cli/2.0.0-next.7 linux-x64 node-v20.19.0
|
|
18
18
|
$ superblocks --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ superblocks COMMAND
|
package/dist/index.js
CHANGED
|
@@ -263726,7 +263726,7 @@ init_esm();
|
|
|
263726
263726
|
// ../sdk/package.json
|
|
263727
263727
|
var package_default = {
|
|
263728
263728
|
name: "@superblocksteam/sdk",
|
|
263729
|
-
version: "2.0.0-next.
|
|
263729
|
+
version: "2.0.0-next.7",
|
|
263730
263730
|
type: "module",
|
|
263731
263731
|
description: "Superblocks JS SDK",
|
|
263732
263732
|
homepage: "https://www.superblocks.com",
|
|
@@ -263763,8 +263763,8 @@ var package_default = {
|
|
|
263763
263763
|
"@rollup/wasm-node": "^4.35.0",
|
|
263764
263764
|
"@superblocksteam/bucketeer-sdk": "0.4.1",
|
|
263765
263765
|
"@superblocksteam/shared": "0.9122.0",
|
|
263766
|
-
"@superblocksteam/util": "2.0.0-next.
|
|
263767
|
-
"@superblocksteam/vite-plugin-file-sync": "2.0.0-next.
|
|
263766
|
+
"@superblocksteam/util": "2.0.0-next.7",
|
|
263767
|
+
"@superblocksteam/vite-plugin-file-sync": "2.0.0-next.7",
|
|
263768
263768
|
"@vitejs/plugin-react": "^4.3.4",
|
|
263769
263769
|
axios: "^1.4.0",
|
|
263770
263770
|
chokidar: "^4.0.3",
|
|
@@ -263908,11 +263908,12 @@ init_cjs_shims();
|
|
|
263908
263908
|
|
|
263909
263909
|
// ../../../library-shared/dist/utils/properties.js
|
|
263910
263910
|
init_cjs_shims();
|
|
263911
|
-
function PropertyInfo(value2, type2 = "STATIC") {
|
|
263911
|
+
function PropertyInfo(value2, type2 = "STATIC", extra) {
|
|
263912
263912
|
return {
|
|
263913
263913
|
__info: true,
|
|
263914
263914
|
value: value2,
|
|
263915
|
-
type: type2
|
|
263915
|
+
type: type2,
|
|
263916
|
+
...extra
|
|
263916
263917
|
};
|
|
263917
263918
|
}
|
|
263918
263919
|
var Property = {
|
|
@@ -263922,7 +263923,7 @@ var Property = {
|
|
|
263922
263923
|
Expression: (value2) => PropertyInfo(value2, "EXPRESSION"),
|
|
263923
263924
|
Event: (value2) => PropertyInfo(value2, "EVENT"),
|
|
263924
263925
|
Dimension: (value2) => PropertyInfo(value2, "DIMENSION"),
|
|
263925
|
-
Computed: (value2) => PropertyInfo(value2, "COMPUTED"),
|
|
263926
|
+
Computed: (value2, args) => PropertyInfo(value2, "COMPUTED", args ? { args } : {}),
|
|
263926
263927
|
Any: (value2, type2 = "STATIC") => PropertyInfo(value2, type2)
|
|
263927
263928
|
};
|
|
263928
263929
|
function isPropertyInfo(value2) {
|
|
@@ -276058,11 +276059,11 @@ function isValidJSXExpression(value2) {
|
|
|
276058
276059
|
}
|
|
276059
276060
|
}
|
|
276060
276061
|
var transformers = {
|
|
276061
|
-
oneLineArrow: (value2) => value2.startsWith("{") ? `() => (${value2})` : `() => ${value2}`,
|
|
276062
|
-
multiLineArrow: (value2) => `() => {
|
|
276062
|
+
oneLineArrow: (value2, argsString) => value2.startsWith("{") ? `(${argsString}) => (${value2})` : `(${argsString}) => ${value2}`,
|
|
276063
|
+
multiLineArrow: (value2, argsString) => `(${argsString}) => {
|
|
276063
276064
|
${value2}
|
|
276064
276065
|
}`,
|
|
276065
|
-
traditional: (value2) => `function (this: any) {
|
|
276066
|
+
traditional: (value2, argsString) => `function (this: any${argsString ? `, ${argsString}` : ""}) {
|
|
276066
276067
|
${value2}
|
|
276067
276068
|
}`,
|
|
276068
276069
|
computed: (value2) => `sbComputed(${value2})`
|
|
@@ -276070,24 +276071,28 @@ var transformers = {
|
|
|
276070
276071
|
function findFirstValidExpression(testCases) {
|
|
276071
276072
|
return testCases.find(isValidJSXExpression);
|
|
276072
276073
|
}
|
|
276073
|
-
function toCodeComputed(value2) {
|
|
276074
|
+
function toCodeComputed(value2, info) {
|
|
276075
|
+
let argsString = "";
|
|
276076
|
+
if (isComputedPropertyInfo(info)) {
|
|
276077
|
+
argsString = info.args ? `{ ${info.args.join(", ")} }` : "";
|
|
276078
|
+
}
|
|
276074
276079
|
const { hasThisReference, hasReturnStatement } = getFunctionBodyThisExpressionData(value2);
|
|
276075
276080
|
if (hasThisReference) {
|
|
276076
276081
|
if (!hasReturnStatement) {
|
|
276077
|
-
return transformers.computed(transformers.traditional(`return ${value2}
|
|
276082
|
+
return transformers.computed(transformers.traditional(`return ${value2}`, argsString));
|
|
276078
276083
|
}
|
|
276079
|
-
return transformers.computed(transformers.traditional(value2));
|
|
276084
|
+
return transformers.computed(transformers.traditional(value2, argsString));
|
|
276080
276085
|
}
|
|
276081
276086
|
const computedTestCases = [
|
|
276082
|
-
transformers.oneLineArrow(value2),
|
|
276083
|
-
transformers.multiLineArrow(value2),
|
|
276084
|
-
transformers.traditional(value2)
|
|
276087
|
+
transformers.oneLineArrow(value2, argsString),
|
|
276088
|
+
transformers.multiLineArrow(value2, argsString),
|
|
276089
|
+
transformers.traditional(value2, argsString)
|
|
276085
276090
|
];
|
|
276086
276091
|
const validComputedExpression = findFirstValidExpression(computedTestCases);
|
|
276087
276092
|
if (validComputedExpression) {
|
|
276088
276093
|
return transformers.computed(validComputedExpression);
|
|
276089
276094
|
}
|
|
276090
|
-
return transformers.computed(transformers.multiLineArrow(value2));
|
|
276095
|
+
return transformers.computed(transformers.multiLineArrow(value2, argsString));
|
|
276091
276096
|
}
|
|
276092
276097
|
|
|
276093
276098
|
// ../../../vite-plugin-file-sync/dist/parsing/computed/to-value-computed.js
|
|
@@ -276103,7 +276108,7 @@ function toValueComputed(expression) {
|
|
|
276103
276108
|
|
|
276104
276109
|
// ../../../vite-plugin-file-sync/dist/parsing/computed/index.js
|
|
276105
276110
|
var parser5 = {
|
|
276106
|
-
toCode: (value2) => toCodeComputed(value2),
|
|
276111
|
+
toCode: (value2, info) => toCodeComputed(value2, info),
|
|
276107
276112
|
toValue: (code) => toValueComputed(code)
|
|
276108
276113
|
};
|
|
276109
276114
|
|
|
@@ -277096,15 +277101,15 @@ function generateJSXElement({ id: id2, tagName, properties, children }) {
|
|
|
277096
277101
|
jsxElement.children = childElements;
|
|
277097
277102
|
return jsxElement;
|
|
277098
277103
|
}
|
|
277099
|
-
function generateJSXAttribute(name17,
|
|
277100
|
-
const valueNode = getPropertyExpression(
|
|
277104
|
+
function generateJSXAttribute(name17, info) {
|
|
277105
|
+
const valueNode = getPropertyExpression(info, name17);
|
|
277101
277106
|
if (import_types11.default.isStringLiteral(valueNode)) {
|
|
277102
277107
|
return import_types11.default.jsxAttribute(import_types11.default.jsxIdentifier(name17), valueNode);
|
|
277103
277108
|
} else {
|
|
277104
277109
|
return import_types11.default.jsxAttribute(import_types11.default.jsxIdentifier(name17), import_types11.default.jsxExpressionContainer(valueNode));
|
|
277105
277110
|
}
|
|
277106
277111
|
}
|
|
277107
|
-
function writeNestedProperty({ node, paths,
|
|
277112
|
+
function writeNestedProperty({ node, paths, info }) {
|
|
277108
277113
|
let currentNode = node;
|
|
277109
277114
|
const cleanedPaths = paths.map((path45) => {
|
|
277110
277115
|
if (path45.startsWith("[")) {
|
|
@@ -277123,16 +277128,16 @@ function writeNestedProperty({ node, paths, value: value2, type: type2 }) {
|
|
|
277123
277128
|
if (currentNode.isObjectExpression()) {
|
|
277124
277129
|
let property = currentNode.get("properties").find((prop) => prop.isObjectProperty() && getIdentiferName(prop.node.key) === currentKey);
|
|
277125
277130
|
if (!property) {
|
|
277126
|
-
const
|
|
277131
|
+
const value3 = cleanedPaths.length > 0 ? import_types11.default.objectExpression([]) : import_types11.default.stringLiteral("");
|
|
277127
277132
|
property = currentNode.pushContainer("properties", [
|
|
277128
|
-
import_types11.default.objectProperty(import_types11.default.identifier(currentKey.toString()),
|
|
277133
|
+
import_types11.default.objectProperty(import_types11.default.identifier(currentKey.toString()), value3)
|
|
277129
277134
|
])[0];
|
|
277130
277135
|
}
|
|
277131
|
-
const
|
|
277132
|
-
if (!
|
|
277136
|
+
const value2 = property?.get("value");
|
|
277137
|
+
if (!value2) {
|
|
277133
277138
|
break;
|
|
277134
277139
|
}
|
|
277135
|
-
currentNode = Array.isArray(
|
|
277140
|
+
currentNode = Array.isArray(value2) ? value2[0] : value2;
|
|
277136
277141
|
} else if (currentNode.isArrayExpression() && typeof currentKey === "number") {
|
|
277137
277142
|
const index = currentKey;
|
|
277138
277143
|
const nodeAtIndex = currentNode.get("elements")[index];
|
|
@@ -277157,7 +277162,7 @@ function writeNestedProperty({ node, paths, value: value2, type: type2 }) {
|
|
|
277157
277162
|
}
|
|
277158
277163
|
} else {
|
|
277159
277164
|
currentNode = currentNode.pushContainer("elements", [
|
|
277160
|
-
import_types11.default.stringLiteral(String(
|
|
277165
|
+
import_types11.default.stringLiteral(String(info.value))
|
|
277161
277166
|
])[0];
|
|
277162
277167
|
}
|
|
277163
277168
|
} else {
|
|
@@ -277166,18 +277171,19 @@ function writeNestedProperty({ node, paths, value: value2, type: type2 }) {
|
|
|
277166
277171
|
}
|
|
277167
277172
|
}
|
|
277168
277173
|
if (currentNode) {
|
|
277169
|
-
const valueNode = getPropertyExpression(
|
|
277174
|
+
const valueNode = getPropertyExpression(info, "");
|
|
277170
277175
|
currentNode.replaceWith(valueNode);
|
|
277171
277176
|
}
|
|
277172
277177
|
}
|
|
277173
|
-
function getPropertyExpression(
|
|
277178
|
+
function getPropertyExpression(info, fieldName = "") {
|
|
277174
277179
|
const logger3 = getLogger();
|
|
277180
|
+
const { value: value2, type: type2 } = info;
|
|
277175
277181
|
try {
|
|
277176
277182
|
if (type2 === "BINDING") {
|
|
277177
277183
|
const cleanedValue = typeof value2 === "string" ? value2.replaceAll("${", "\\${") : value2;
|
|
277178
277184
|
return stringToTaggedTemplate(cleanedValue);
|
|
277179
277185
|
} else if (type2 === "TEMPLATE") {
|
|
277180
|
-
const code = parsingRegistry.TEMPLATE.toCode(value2);
|
|
277186
|
+
const code = parsingRegistry.TEMPLATE.toCode(value2, info);
|
|
277181
277187
|
const expression = parseExpression(code);
|
|
277182
277188
|
if (expression) {
|
|
277183
277189
|
return expression;
|
|
@@ -277185,7 +277191,7 @@ function getPropertyExpression({ value: value2, type: type2 }, fieldName = "") {
|
|
|
277185
277191
|
return import_types11.default.stringLiteral(code);
|
|
277186
277192
|
}
|
|
277187
277193
|
} else if (type2 === "DIMENSION") {
|
|
277188
|
-
const code = parsingRegistry.DIMENSION.toCode(value2);
|
|
277194
|
+
const code = parsingRegistry.DIMENSION.toCode(value2, info);
|
|
277189
277195
|
const expression = parseExpression(code);
|
|
277190
277196
|
if (expression) {
|
|
277191
277197
|
return expression;
|
|
@@ -277194,7 +277200,7 @@ function getPropertyExpression({ value: value2, type: type2 }, fieldName = "") {
|
|
|
277194
277200
|
}
|
|
277195
277201
|
}
|
|
277196
277202
|
if (type2 === "EVENT") {
|
|
277197
|
-
const code = parsingRegistry.EVENT.toCode(value2);
|
|
277203
|
+
const code = parsingRegistry.EVENT.toCode(value2, info);
|
|
277198
277204
|
const expression = parseExpression(code);
|
|
277199
277205
|
if (expression) {
|
|
277200
277206
|
return expression;
|
|
@@ -277218,7 +277224,7 @@ function getPropertyExpression({ value: value2, type: type2 }, fieldName = "") {
|
|
|
277218
277224
|
}
|
|
277219
277225
|
if (parsed === void 0) {
|
|
277220
277226
|
try {
|
|
277221
|
-
const code = parsingRegistry.COMPUTED.toCode(value2);
|
|
277227
|
+
const code = parsingRegistry.COMPUTED.toCode(value2, info);
|
|
277222
277228
|
const computedExpression = parseExpression(code);
|
|
277223
277229
|
if (computedExpression) {
|
|
277224
277230
|
return computedExpression;
|
|
@@ -302669,7 +302675,7 @@ var SourceTracker = class {
|
|
|
302669
302675
|
* And you want to update the `accessor` property, you can use this function to do so, passing a property path like
|
|
302670
302676
|
* `columns.name.accessor`, rather than the entire columns object.
|
|
302671
302677
|
*/
|
|
302672
|
-
setNestedAttribute = ({ openingTag, property,
|
|
302678
|
+
setNestedAttribute = ({ openingTag, property, info }) => {
|
|
302673
302679
|
const [parent, ...paths] = splitJSPathAdvanced(property, []);
|
|
302674
302680
|
let parentAttr = openingTag.get("attributes").find((attr) => attr.isJSXAttribute() && attr.node.name.name === parent);
|
|
302675
302681
|
if (!parentAttr && parent) {
|
|
@@ -302686,14 +302692,13 @@ var SourceTracker = class {
|
|
|
302686
302692
|
writeNestedProperty({
|
|
302687
302693
|
node: currentNode,
|
|
302688
302694
|
paths,
|
|
302689
|
-
|
|
302690
|
-
type: type2
|
|
302695
|
+
info
|
|
302691
302696
|
});
|
|
302692
302697
|
};
|
|
302693
|
-
setAttribute = (openingTag, property,
|
|
302698
|
+
setAttribute = (openingTag, property, info) => {
|
|
302694
302699
|
const paths = splitJSPath(property);
|
|
302695
302700
|
if (Array.isArray(paths) && paths.length > 1) {
|
|
302696
|
-
this.setNestedAttribute({ openingTag, property,
|
|
302701
|
+
this.setNestedAttribute({ openingTag, property, info });
|
|
302697
302702
|
return;
|
|
302698
302703
|
}
|
|
302699
302704
|
let attr = openingTag.get("attributes").find((attr2) => attr2.isJSXAttribute() && attr2.node.name.name === property);
|
|
@@ -302702,6 +302707,7 @@ var SourceTracker = class {
|
|
|
302702
302707
|
import_types22.default.jsxAttribute(import_types22.default.jsxIdentifier(property), import_types22.default.stringLiteral(""))
|
|
302703
302708
|
])[0];
|
|
302704
302709
|
}
|
|
302710
|
+
const value2 = info.value;
|
|
302705
302711
|
if (value2 === void 0 || typeof value2 === "string" && value2 === "") {
|
|
302706
302712
|
attr.remove();
|
|
302707
302713
|
return;
|
|
@@ -302711,7 +302717,7 @@ var SourceTracker = class {
|
|
|
302711
302717
|
throw new Error("Attribute name not found");
|
|
302712
302718
|
}
|
|
302713
302719
|
const attrValue = attr.get("value");
|
|
302714
|
-
const jsxAttribute = generateJSXAttribute(property,
|
|
302720
|
+
const jsxAttribute = generateJSXAttribute(property, info);
|
|
302715
302721
|
if (jsxAttribute.value) {
|
|
302716
302722
|
attrValue.replaceWith(jsxAttribute.value);
|
|
302717
302723
|
}
|
|
@@ -302728,10 +302734,10 @@ var SourceTracker = class {
|
|
|
302728
302734
|
element.node.closingElement = import_types22.default.jsxClosingElement(import_types22.default.jsxIdentifier(getTagName(openingElement.node.name) ?? ""));
|
|
302729
302735
|
}
|
|
302730
302736
|
};
|
|
302731
|
-
setProperty = async ({ source: source2, property,
|
|
302737
|
+
setProperty = async ({ source: source2, property, info }) => {
|
|
302732
302738
|
await this.setProperties({
|
|
302733
302739
|
source: source2,
|
|
302734
|
-
changes: { [property]:
|
|
302740
|
+
changes: { [property]: info }
|
|
302735
302741
|
});
|
|
302736
302742
|
};
|
|
302737
302743
|
setProperties = async ({ source: source2, changes }) => {
|
|
@@ -302755,11 +302761,10 @@ var SourceTracker = class {
|
|
|
302755
302761
|
if (!openingTag.isJSXOpeningElement()) {
|
|
302756
302762
|
throw new Error(`Element ${source2.id} is not a JSXOpeningElement`);
|
|
302757
302763
|
}
|
|
302758
|
-
for (const [key2,
|
|
302759
|
-
const
|
|
302760
|
-
|
|
302761
|
-
|
|
302762
|
-
const requiredImports = REQUIRED_IMPORTS_BY_PROPERTY_TYPE[type2];
|
|
302764
|
+
for (const [key2, info] of Object.entries(changes)) {
|
|
302765
|
+
const jsxAttribute = this.setAttribute(openingTag, key2, info);
|
|
302766
|
+
if (info.type in REQUIRED_IMPORTS_BY_PROPERTY_TYPE) {
|
|
302767
|
+
const requiredImports = REQUIRED_IMPORTS_BY_PROPERTY_TYPE[info.type];
|
|
302763
302768
|
if (requiredImports) {
|
|
302764
302769
|
for (const { importName, importPath } of requiredImports) {
|
|
302765
302770
|
if (!this.fileToMeta[fileName].imports[importName]) {
|
|
@@ -302775,7 +302780,7 @@ var SourceTracker = class {
|
|
|
302775
302780
|
}
|
|
302776
302781
|
}
|
|
302777
302782
|
}
|
|
302778
|
-
if (
|
|
302783
|
+
if (info.type === "EVENT" && jsxAttribute) {
|
|
302779
302784
|
const referencedGlobalFunctions = getVariableReferences(jsxAttribute, GLOBAL_LIBRARY_NAMES);
|
|
302780
302785
|
referencedGlobalFunctions.forEach((funcName) => {
|
|
302781
302786
|
if (!this.fileToMeta[fileName].imports[funcName]) {
|
|
@@ -302790,7 +302795,7 @@ var SourceTracker = class {
|
|
|
302790
302795
|
}
|
|
302791
302796
|
});
|
|
302792
302797
|
}
|
|
302793
|
-
if (ATTRIBUTE_TYPES_WITH_STATE_ACCESS.includes(
|
|
302798
|
+
if (ATTRIBUTE_TYPES_WITH_STATE_ACCESS.includes(info.type) && jsxAttribute) {
|
|
302794
302799
|
const elementLocation = this.getElementToLocation(source2.id);
|
|
302795
302800
|
const scopeImports = this.sbScopeManager.getAndUpdateScopeImportsForCodeSnippet({
|
|
302796
302801
|
jsxAttribute,
|
|
@@ -303574,13 +303579,12 @@ export default registerPage(Page, { name: "${name17}" });
|
|
|
303574
303579
|
}
|
|
303575
303580
|
};
|
|
303576
303581
|
handleSetProperty = async (payload, writeFile8 = true) => {
|
|
303577
|
-
const { element: { source: source2 }, property, value:
|
|
303582
|
+
const { element: { source: source2 }, property, value: value2, transaction } = payload;
|
|
303578
303583
|
this.trackTransaction(transaction?.id);
|
|
303579
303584
|
await this.sourceTracker?.setProperty({
|
|
303580
303585
|
source: source2,
|
|
303581
303586
|
property,
|
|
303582
|
-
|
|
303583
|
-
type: type2
|
|
303587
|
+
info: value2
|
|
303584
303588
|
});
|
|
303585
303589
|
if (writeFile8) {
|
|
303586
303590
|
const changes = await this.sourceTracker?.getAndFlushChanges() ?? [];
|
|
@@ -308607,7 +308611,7 @@ async function startVite({ app, httpServer: httpServer2, root: root2, mode, port
|
|
|
308607
308611
|
};
|
|
308608
308612
|
const isCustomBuildEnabled2 = await isCustomComponentsEnabled();
|
|
308609
308613
|
const customFolder = path21.join(root2, "custom");
|
|
308610
|
-
const cdnUrl = "https://assets-cdn.superblocks.com/library/2.0.0-next.
|
|
308614
|
+
const cdnUrl = "https://assets-cdn.superblocks.com/library/2.0.0-next.7";
|
|
308611
308615
|
const env3 = loadEnv(mode, root2, "");
|
|
308612
308616
|
const hmrPort = await getFreePort();
|
|
308613
308617
|
const hmrOptions = {
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/cli",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Official Superblocks CLI",
|
|
6
6
|
"homepage": "https://www.superblocks.com",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@eslint/js": "^9.16.0",
|
|
44
44
|
"@oclif/test": "^4.1.11",
|
|
45
|
-
"@superblocksteam/sdk": "2.0.0-next.
|
|
45
|
+
"@superblocksteam/sdk": "2.0.0-next.7",
|
|
46
46
|
"@superblocksteam/shared": "0.9122.0",
|
|
47
|
-
"@superblocksteam/util": "2.0.0-next.
|
|
47
|
+
"@superblocksteam/util": "2.0.0-next.7",
|
|
48
48
|
"@types/babel__core": "^7.20.0",
|
|
49
49
|
"@types/chai": "^4",
|
|
50
50
|
"@types/fs-extra": "^11.0.1",
|