@builder.io/mitosis 0.0.56-18 → 0.0.56-20
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/src/__tests__/shared.js +8 -0
- package/dist/src/__tests__/svelte.test.js +3 -78
- package/dist/src/generators/svelte.d.ts +1 -1
- package/dist/src/generators/svelte.js +59 -8
- package/dist/src/helpers/get-state-object-string.d.ts +4 -3
- package/dist/src/helpers/get-state-object-string.js +23 -20
- package/dist/src/helpers/styles/helpers.d.ts +3 -2
- package/dist/src/jsx-types.d.ts +7 -4
- package/dist/src/jsx-types.js +8 -0
- package/dist/src/targets.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jsx-runtime.d.ts +1 -0
- package/package.json +5 -3
|
@@ -152,6 +152,14 @@ var TESTS_FOR_TARGET = {
|
|
|
152
152
|
FORM_BLOCK_TESTS,
|
|
153
153
|
FOR_SHOW_TESTS,
|
|
154
154
|
],
|
|
155
|
+
svelte: [
|
|
156
|
+
BASIC_TESTS,
|
|
157
|
+
ROOT_SHOW_TESTS,
|
|
158
|
+
FORWARD_REF_TESTS,
|
|
159
|
+
MULTI_ON_UPDATE_TESTS,
|
|
160
|
+
FORM_BLOCK_TESTS,
|
|
161
|
+
FOR_SHOW_TESTS,
|
|
162
|
+
],
|
|
155
163
|
html: [
|
|
156
164
|
BASIC_TESTS,
|
|
157
165
|
ROOT_SHOW_TESTS,
|
|
@@ -1,82 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var svelte_1 = require("../generators/
|
|
4
|
-
var
|
|
5
|
-
var svelte_2 = require("../generators/svelte");
|
|
6
|
-
var jsx_1 = require("../parsers/jsx");
|
|
7
|
-
var basicOnChange = require('./data/basic-onChange.raw');
|
|
8
|
-
var onUpdate = require('./data/blocks/onUpdate.raw');
|
|
9
|
-
var multipleOUpdate = require('./data/blocks/multiple-onUpdate.raw');
|
|
10
|
-
var selfReferencingComponent = require('./data/blocks/self-referencing-component.raw');
|
|
11
|
-
var selfReferencingComponentWithChildren = require('./data/blocks/self-referencing-component-with-children.raw');
|
|
12
|
-
var builderRenderBlock = require('./data/blocks/builder-render-block.raw');
|
|
13
|
-
var rootShow = require('./data/blocks/rootShow.raw');
|
|
14
|
-
var simpleExample = require('./data/context/simple.context.lite');
|
|
15
|
-
var componentWithContext = require('./data/context/component-with-context.lite');
|
|
16
|
-
var renderBlock = require('./data/blocks/builder-render-block.raw');
|
|
17
|
-
var text = require('./data/blocks/text.raw');
|
|
3
|
+
var svelte_1 = require("../generators/svelte");
|
|
4
|
+
var shared_1 = require("./shared");
|
|
18
5
|
describe('Svelte', function () {
|
|
19
|
-
|
|
20
|
-
var component = (0, jsx_1.parseJsx)(basicOnChange);
|
|
21
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
22
|
-
expect(output).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
test('onUpdate', function () {
|
|
25
|
-
var component = (0, jsx_1.parseJsx)(onUpdate);
|
|
26
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
27
|
-
expect(output).toMatchSnapshot();
|
|
28
|
-
});
|
|
29
|
-
test('multipleOnUpdate', function () {
|
|
30
|
-
var component = (0, jsx_1.parseJsx)(multipleOUpdate);
|
|
31
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
32
|
-
expect(output).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
test('selfReferencingComponent', function () {
|
|
35
|
-
var component = (0, jsx_1.parseJsx)(selfReferencingComponent);
|
|
36
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
37
|
-
expect(output).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
test('selfReferencingComponentWithChildren', function () {
|
|
40
|
-
var component = (0, jsx_1.parseJsx)(selfReferencingComponentWithChildren);
|
|
41
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
42
|
-
expect(output).toMatchSnapshot();
|
|
43
|
-
});
|
|
44
|
-
test('BuilderRenderBlock', function () {
|
|
45
|
-
var component = (0, jsx_1.parseJsx)(builderRenderBlock);
|
|
46
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
47
|
-
expect(output).toMatchSnapshot();
|
|
48
|
-
});
|
|
49
|
-
test('rootShow', function () {
|
|
50
|
-
var component = (0, jsx_1.parseJsx)(rootShow);
|
|
51
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
52
|
-
expect(output).toMatchSnapshot();
|
|
53
|
-
});
|
|
54
|
-
describe('Context', function () {
|
|
55
|
-
test('Parse context', function () {
|
|
56
|
-
var component = (0, context_1.parseContext)(simpleExample, { name: 'SimpleExample' });
|
|
57
|
-
if (!component) {
|
|
58
|
-
throw new Error('No parseable context found for simple.context.lite.ts');
|
|
59
|
-
}
|
|
60
|
-
expect(component).toMatchSnapshot();
|
|
61
|
-
var context = (0, svelte_1.contextToSvelte)()({ context: component });
|
|
62
|
-
expect(context).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
test('Use and set context in components', function () {
|
|
65
|
-
var component = (0, jsx_1.parseJsx)(componentWithContext);
|
|
66
|
-
expect(component).toMatchSnapshot();
|
|
67
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
68
|
-
expect(output).toMatchSnapshot();
|
|
69
|
-
});
|
|
70
|
-
test('Use and set context in complex components', function () {
|
|
71
|
-
var component = (0, jsx_1.parseJsx)(renderBlock);
|
|
72
|
-
expect(component).toMatchSnapshot();
|
|
73
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
74
|
-
expect(output).toMatchSnapshot();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
test('Text', function () {
|
|
78
|
-
var component = (0, jsx_1.parseJsx)(text);
|
|
79
|
-
var output = (0, svelte_2.componentToSvelte)()({ component: component });
|
|
80
|
-
expect(output).toMatchSnapshot();
|
|
81
|
-
});
|
|
6
|
+
(0, shared_1.runTestsForTarget)('svelte', (0, svelte_1.componentToSvelte)());
|
|
82
7
|
});
|
|
@@ -11,5 +11,5 @@ interface BlockToSvelteProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare type BlockToSvelte = (props: BlockToSvelteProps) => string;
|
|
13
13
|
export declare const blockToSvelte: BlockToSvelte;
|
|
14
|
-
export declare const componentToSvelte: (options?: ToSvelteOptions) => Transpiler;
|
|
14
|
+
export declare const componentToSvelte: ({ plugins, ...options }?: ToSvelteOptions) => Transpiler;
|
|
15
15
|
export {};
|
|
@@ -14,6 +14,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
};
|
|
15
15
|
return __assign.apply(this, arguments);
|
|
16
16
|
};
|
|
17
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
+
t[p[i]] = s[p[i]];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
17
37
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
39
|
};
|
|
@@ -40,6 +60,10 @@ var babel_transform_1 = require("../helpers/babel-transform");
|
|
|
40
60
|
var function_1 = require("fp-ts/lib/function");
|
|
41
61
|
var context_1 = require("./helpers/context");
|
|
42
62
|
var html_tags_1 = require("../constants/html_tags");
|
|
63
|
+
var lodash_1 = require("lodash");
|
|
64
|
+
var function_literal_prefix_1 = require("../constants/function-literal-prefix");
|
|
65
|
+
var method_literal_prefix_1 = require("../constants/method-literal-prefix");
|
|
66
|
+
var patterns_1 = require("../helpers/patterns");
|
|
43
67
|
var mappers = {
|
|
44
68
|
Fragment: function (_a) {
|
|
45
69
|
var _b;
|
|
@@ -231,12 +255,29 @@ var useBindValue = function (json, options) {
|
|
|
231
255
|
var stripThisRefs = function (str) {
|
|
232
256
|
return str.replace(/this\.([a-zA-Z_\$0-9]+)/g, '$1');
|
|
233
257
|
};
|
|
234
|
-
var
|
|
235
|
-
|
|
258
|
+
var FUNCTION_HACK_PLUGIN = function () { return ({
|
|
259
|
+
json: {
|
|
260
|
+
pre: function (json) {
|
|
261
|
+
for (var key in json.state) {
|
|
262
|
+
var value = json.state[key];
|
|
263
|
+
if (typeof value === 'string' && value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
|
|
264
|
+
var strippedValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
|
|
265
|
+
if (!Boolean(strippedValue.match(patterns_1.GETTER))) {
|
|
266
|
+
var newValue = "".concat(function_literal_prefix_1.functionLiteralPrefix, " function ").concat(strippedValue);
|
|
267
|
+
json.state[key] = newValue;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
}); };
|
|
274
|
+
var componentToSvelte = function (_a) {
|
|
275
|
+
if (_a === void 0) { _a = {}; }
|
|
276
|
+
var _b = _a.plugins, plugins = _b === void 0 ? [] : _b, options = __rest(_a, ["plugins"]);
|
|
236
277
|
return function (_a) {
|
|
237
278
|
var _b, _c, _d, _e, _f, _g;
|
|
238
279
|
var component = _a.component;
|
|
239
|
-
var useOptions = __assign(
|
|
280
|
+
var useOptions = __assign({ stateType: 'variables', prettier: true, plugins: __spreadArray([FUNCTION_HACK_PLUGIN], plugins, true) }, options);
|
|
240
281
|
// Make a copy we can safely mutate, similar to babel's toolchain
|
|
241
282
|
var json = (0, fast_clone_1.fastClone)(component);
|
|
242
283
|
if (useOptions.plugins) {
|
|
@@ -279,7 +320,7 @@ var componentToSvelte = function (options) {
|
|
|
279
320
|
getters: false,
|
|
280
321
|
functions: true,
|
|
281
322
|
format: 'variables',
|
|
282
|
-
keyPrefix: '
|
|
323
|
+
keyPrefix: 'const ',
|
|
283
324
|
valueMapper: function (code) {
|
|
284
325
|
return (0, function_1.pipe)((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, {
|
|
285
326
|
includeState: useOptions.stateType === 'variables',
|
|
@@ -293,8 +334,7 @@ var componentToSvelte = function (options) {
|
|
|
293
334
|
includeState: useOptions.stateType === 'variables',
|
|
294
335
|
}), babel_transform_1.babelTransformCode);
|
|
295
336
|
};
|
|
296
|
-
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <script>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), !((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? '' : "import { onMount } from 'svelte'", !((_c = json.hooks.onUpdate) === null || _c === void 0 ? void 0 : _c.length) ? '' : "import { afterUpdate } from 'svelte'", !((_d = json.hooks.onUnMount) === null || _d === void 0 ? void 0 : _d.code) ? '' : "import { onDestroy } from 'svelte'", (0, render_imports_1.renderPreComponent)({ component: json, target: 'svelte' }), (0, context_1.hasContext)(component) ? 'import { getContext, setContext } from "svelte";' : '', !hasData || useOptions.stateType === 'variables' ? '' : "import onChange from 'on-change'", refs
|
|
297
|
-
.concat(props)
|
|
337
|
+
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <script>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), !((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? '' : "import { onMount } from 'svelte'", !((_c = json.hooks.onUpdate) === null || _c === void 0 ? void 0 : _c.length) ? '' : "import { afterUpdate } from 'svelte'", !((_d = json.hooks.onUnMount) === null || _d === void 0 ? void 0 : _d.code) ? '' : "import { onDestroy } from 'svelte'", (0, render_imports_1.renderPreComponent)({ component: json, target: 'svelte' }), (0, context_1.hasContext)(component) ? 'import { getContext, setContext } from "svelte";' : '', !hasData || useOptions.stateType === 'variables' ? '' : "import onChange from 'on-change'", (0, lodash_1.uniq)(refs.map(function (ref) { return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(ref); }).concat(props))
|
|
298
338
|
.map(function (name) {
|
|
299
339
|
if (name === 'children') {
|
|
300
340
|
return '';
|
|
@@ -310,7 +350,17 @@ var componentToSvelte = function (options) {
|
|
|
310
350
|
: "onMount(() => { ".concat(transformHookCode(json.hooks.onMount.code), " });"), !((_f = json.hooks.onUpdate) === null || _f === void 0 ? void 0 : _f.length)
|
|
311
351
|
? ''
|
|
312
352
|
: json.hooks.onUpdate
|
|
313
|
-
.map(function (
|
|
353
|
+
.map(function (_a, index) {
|
|
354
|
+
var code = _a.code, deps = _a.deps;
|
|
355
|
+
var hookCode = transformHookCode(code);
|
|
356
|
+
if (deps) {
|
|
357
|
+
var fnName = "onUpdateFn_".concat(index);
|
|
358
|
+
return "\n function ".concat(fnName, "() {\n ").concat(hookCode, "\n }\n $: ").concat(fnName, "(...").concat(deps, ")\n ");
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
return "afterUpdate(() => { ".concat(hookCode, " })");
|
|
362
|
+
}
|
|
363
|
+
})
|
|
314
364
|
.join(';'), !((_g = json.hooks.onUnMount) === null || _g === void 0 ? void 0 : _g.code)
|
|
315
365
|
? ''
|
|
316
366
|
: "onDestroy(() => { ".concat(transformHookCode(json.hooks.onUnMount.code), " });"), json.children
|
|
@@ -342,7 +392,8 @@ var componentToSvelte = function (options) {
|
|
|
342
392
|
});
|
|
343
393
|
}
|
|
344
394
|
catch (err) {
|
|
345
|
-
console.warn('Could not prettify'
|
|
395
|
+
console.warn('Could not prettify');
|
|
396
|
+
console.warn({ string: str }, err);
|
|
346
397
|
}
|
|
347
398
|
}
|
|
348
399
|
if (useOptions.plugins) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { JSONObject } from '../types/json';
|
|
2
2
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
3
|
-
|
|
3
|
+
interface GetStateObjectStringOptions {
|
|
4
4
|
data?: boolean;
|
|
5
5
|
functions?: boolean;
|
|
6
6
|
getters?: boolean;
|
|
7
7
|
valueMapper?: (code: string, type: 'data' | 'function' | 'getter') => string;
|
|
8
8
|
format?: 'object' | 'class' | 'variables';
|
|
9
9
|
keyPrefix?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const getMemberObjectString: (object: JSONObject,
|
|
10
|
+
}
|
|
11
|
+
export declare const getMemberObjectString: (object: JSONObject, userOptions?: GetStateObjectStringOptions) => string;
|
|
12
12
|
export declare const getStateObjectStringFromComponent: (component: MitosisComponent, options?: GetStateObjectStringOptions) => string;
|
|
13
|
+
export {};
|
|
@@ -19,15 +19,22 @@ var json5_1 = __importDefault(require("json5"));
|
|
|
19
19
|
var function_literal_prefix_1 = require("../constants/function-literal-prefix");
|
|
20
20
|
var method_literal_prefix_1 = require("../constants/method-literal-prefix");
|
|
21
21
|
var patterns_1 = require("./patterns");
|
|
22
|
-
var
|
|
22
|
+
var DEFAULT_OPTIONS = {
|
|
23
|
+
format: 'object',
|
|
24
|
+
keyPrefix: '',
|
|
25
|
+
valueMapper: function (val) { return val; },
|
|
26
|
+
data: true,
|
|
27
|
+
functions: true,
|
|
28
|
+
getters: true,
|
|
29
|
+
};
|
|
30
|
+
var convertStateMemberToString = function (_a) {
|
|
31
|
+
var data = _a.data, format = _a.format, functions = _a.functions, getters = _a.getters, keyPrefix = _a.keyPrefix, valueMapper = _a.valueMapper;
|
|
23
32
|
return function (_a) {
|
|
24
33
|
var key = _a[0], value = _a[1];
|
|
25
|
-
var
|
|
26
|
-
var keyValueDelimiter = options.format === 'object' ? ':' : '=';
|
|
27
|
-
var keyPrefix = options.keyPrefix || '';
|
|
34
|
+
var keyValueDelimiter = format === 'object' ? ':' : '=';
|
|
28
35
|
if (typeof value === 'string') {
|
|
29
36
|
if (value.startsWith(function_literal_prefix_1.functionLiteralPrefix)) {
|
|
30
|
-
if (
|
|
37
|
+
if (functions === false) {
|
|
31
38
|
return undefined;
|
|
32
39
|
}
|
|
33
40
|
var functionValue = value.replace(function_literal_prefix_1.functionLiteralPrefix, '');
|
|
@@ -36,31 +43,31 @@ var convertStateMemberToString = function (options) {
|
|
|
36
43
|
else if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
|
|
37
44
|
var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
|
|
38
45
|
var isGet = Boolean(methodValue.match(patterns_1.GETTER));
|
|
39
|
-
if (isGet &&
|
|
46
|
+
if (isGet && getters === false) {
|
|
40
47
|
return undefined;
|
|
41
48
|
}
|
|
42
|
-
if (!isGet &&
|
|
49
|
+
if (!isGet && functions === false) {
|
|
43
50
|
return undefined;
|
|
44
51
|
}
|
|
45
52
|
return "".concat(keyPrefix, " ").concat(valueMapper(methodValue, isGet ? 'getter' : 'function'));
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
|
-
if (
|
|
55
|
+
if (data === false) {
|
|
49
56
|
return undefined;
|
|
50
57
|
}
|
|
51
58
|
return "".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data'));
|
|
52
59
|
};
|
|
53
60
|
};
|
|
54
|
-
var getMemberObjectString = function (object,
|
|
55
|
-
if (
|
|
56
|
-
var
|
|
57
|
-
var lineItemDelimiter = format === 'object' ? ',' : '\n';
|
|
61
|
+
var getMemberObjectString = function (object, userOptions) {
|
|
62
|
+
if (userOptions === void 0) { userOptions = {}; }
|
|
63
|
+
var options = __assign(__assign({}, DEFAULT_OPTIONS), userOptions);
|
|
64
|
+
var lineItemDelimiter = options.format === 'object' ? ',' : '\n';
|
|
58
65
|
var stringifiedProperties = Object.entries(object)
|
|
59
|
-
.map(convertStateMemberToString(
|
|
66
|
+
.map(convertStateMemberToString(options))
|
|
60
67
|
.filter(function (x) { return x !== undefined; })
|
|
61
68
|
.join(lineItemDelimiter);
|
|
62
|
-
var prefix = format === 'object' ? '{' : '';
|
|
63
|
-
var suffix = format === 'object' ? '}' : '';
|
|
69
|
+
var prefix = options.format === 'object' ? '{' : '';
|
|
70
|
+
var suffix = options.format === 'object' ? '}' : '';
|
|
64
71
|
// NOTE: we add a `lineItemDelimiter` at the very end because other functions will sometimes append more properties.
|
|
65
72
|
// If the delimiter is a comma and the format is `object`, then we need to make sure we have an extra comma at the end,
|
|
66
73
|
// or the object will become invalid JS.
|
|
@@ -69,9 +76,5 @@ var getMemberObjectString = function (object, options) {
|
|
|
69
76
|
return "".concat(prefix).concat(stringifiedProperties).concat(extraDelimiter).concat(suffix);
|
|
70
77
|
};
|
|
71
78
|
exports.getMemberObjectString = getMemberObjectString;
|
|
72
|
-
var getStateObjectStringFromComponent = function (component, options) {
|
|
73
|
-
if (options === void 0) { options = {}; }
|
|
74
|
-
var stateObjectStr = (0, exports.getMemberObjectString)(component.state, options);
|
|
75
|
-
return stateObjectStr;
|
|
76
|
-
};
|
|
79
|
+
var getStateObjectStringFromComponent = function (component, options) { return (0, exports.getMemberObjectString)(component.state, options); };
|
|
77
80
|
exports.getStateObjectStringFromComponent = getStateObjectStringFromComponent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
1
2
|
import * as CSS from 'csstype';
|
|
2
3
|
import { MitosisNode } from '../../types/mitosis-node';
|
|
3
4
|
import { MitosisComponent } from '../../types/mitosis-component';
|
|
@@ -17,8 +18,8 @@ export declare const hasStyles: (component: MitosisComponent) => boolean;
|
|
|
17
18
|
export declare type StyleMap = {
|
|
18
19
|
[className: string]: CSS.Properties | StyleMap;
|
|
19
20
|
};
|
|
20
|
-
export declare const getNestedSelectors: (map: StyleMap) => import("lodash").Dictionary<
|
|
21
|
-
export declare const getStylesOnly: (map: StyleMap) => import("lodash").Dictionary<
|
|
21
|
+
export declare const getNestedSelectors: (map: StyleMap) => import("lodash").Dictionary<CSS.Properties<0 | (string & {}), string & {}> | StyleMap>;
|
|
22
|
+
export declare const getStylesOnly: (map: StyleMap) => import("lodash").Dictionary<CSS.Properties<0 | (string & {}), string & {}> | StyleMap>;
|
|
22
23
|
/**
|
|
23
24
|
* { 'my-class': { display: 'block', '&.foo': { display: 'none' } }}
|
|
24
25
|
*/
|
package/dist/src/jsx-types.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
declare type CSS = Partial<CSSStyleDeclaration> & {
|
|
2
|
-
[key: string]: Partial<CSSStyleDeclaration> | string;
|
|
3
|
-
};
|
|
4
1
|
/**
|
|
5
2
|
* Based on JSX types for Solid, Inferno, Surplus, and React
|
|
6
3
|
*
|
|
@@ -10,6 +7,9 @@ declare type CSS = Partial<CSSStyleDeclaration> & {
|
|
|
10
7
|
* https://github.com/adamhaile/surplus/blob/master/index.d.ts
|
|
11
8
|
*/
|
|
12
9
|
export declare namespace JSX {
|
|
10
|
+
type CSS = Partial<CSSStyleDeclaration> & {
|
|
11
|
+
[key: string]: Partial<CSSStyleDeclaration> | string;
|
|
12
|
+
};
|
|
13
13
|
type Element = Node | ArrayElement | FunctionElement | string | number | boolean | null | undefined;
|
|
14
14
|
interface ArrayElement extends Array<Element> {
|
|
15
15
|
}
|
|
@@ -38,6 +38,7 @@ export declare namespace JSX {
|
|
|
38
38
|
}
|
|
39
39
|
type EventHandlerUnion<T, E extends Event> = EventHandler<T, E> | BoundEventHandler<T, E>;
|
|
40
40
|
interface IntrinsicAttributes {
|
|
41
|
+
key?: string | number;
|
|
41
42
|
ref?: HTMLElement | ((e: HTMLElement) => void);
|
|
42
43
|
}
|
|
43
44
|
interface CustomAttributes<T> {
|
|
@@ -56,7 +57,7 @@ export declare namespace JSX {
|
|
|
56
57
|
$id?: string;
|
|
57
58
|
}
|
|
58
59
|
interface DOMAttributes<T> extends CustomAttributes<T> {
|
|
59
|
-
children?: Element;
|
|
60
|
+
children?: Element | Element[] | string | undefined | false;
|
|
60
61
|
innerHTML?: string;
|
|
61
62
|
innerText?: string;
|
|
62
63
|
textContent?: string;
|
|
@@ -311,6 +312,8 @@ export declare namespace JSX {
|
|
|
311
312
|
referrerPolicy?: HTMLReferrerPolicy;
|
|
312
313
|
}
|
|
313
314
|
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
315
|
+
loading?: string;
|
|
316
|
+
role?: string;
|
|
314
317
|
alt?: string;
|
|
315
318
|
crossorigin?: HTMLCrossorigin;
|
|
316
319
|
decoding?: 'sync' | 'async' | 'auto';
|
package/dist/src/jsx-types.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Based on JSX types for Solid, Inferno, Surplus, and React
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/ryansolid/solid/blob/master/packages/solid/src/rendering/jsx.ts
|
|
6
|
+
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
|
|
7
|
+
* https://github.com/infernojs/inferno/blob/master/packages/inferno/src/core/types.ts
|
|
8
|
+
* https://github.com/adamhaile/surplus/blob/master/index.d.ts
|
|
9
|
+
*/
|
|
2
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/src/targets.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const targets: {
|
|
|
15
15
|
react: (reactOptions?: import("./generators/react").ToReactOptions) => import(".").Transpiler;
|
|
16
16
|
reactNative: (options?: import("./generators/react-native").ToReactNativeOptions) => import(".").Transpiler;
|
|
17
17
|
solid: (options?: import("./generators/solid").ToSolidOptions) => import(".").Transpiler;
|
|
18
|
-
svelte: (options?: import("./generators/svelte").ToSvelteOptions) => import(".").Transpiler;
|
|
18
|
+
svelte: ({ plugins, ...options }?: import("./generators/svelte").ToSvelteOptions) => import(".").Transpiler;
|
|
19
19
|
swift: (options?: import("./generators/swift-ui").ToSwiftOptions) => import(".").Transpiler;
|
|
20
20
|
template: (options?: import("./generators/template").ToTemplateOptions) => import(".").Transpiler;
|
|
21
21
|
webcomponent: (options?: import("./generators/html").ToHtmlOptions) => import(".").Transpiler;
|