@builder.io/mitosis 0.0.56-98 → 0.0.57
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__/data/blocks/content-slot-jsx.raw.jsx +4 -1
- package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +5 -1
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +3 -3
- package/dist/src/__tests__/data/jsx-json.spec.d.ts +2 -0
- package/dist/src/__tests__/data/jsx-json.spec.js +10226 -0
- package/dist/src/__tests__/shared.d.ts +7 -2
- package/dist/src/__tests__/shared.js +66 -9
- package/dist/src/constants/method-literal-prefix.d.ts +0 -1
- package/dist/src/constants/method-literal-prefix.js +0 -3
- package/dist/src/generators/angular.d.ts +2 -2
- package/dist/src/generators/angular.js +5 -3
- package/dist/src/generators/builder.d.ts +4 -11
- package/dist/src/generators/builder.js +3 -2
- package/dist/src/generators/context/svelte.d.ts +3 -0
- package/dist/src/generators/context/svelte.js +3 -0
- package/dist/src/generators/helpers/functions.d.ts +2 -0
- package/dist/src/generators/helpers/functions.js +28 -0
- package/dist/src/generators/html.d.ts +3 -3
- package/dist/src/generators/html.js +9 -7
- package/dist/src/generators/liquid.d.ts +2 -2
- package/dist/src/generators/liquid.js +4 -4
- package/dist/src/generators/lit/generate.d.ts +2 -2
- package/dist/src/generators/lit/generate.js +14 -6
- package/dist/src/generators/marko/generate.d.ts +2 -2
- package/dist/src/generators/marko/generate.js +10 -8
- package/dist/src/generators/mitosis.d.ts +3 -4
- package/dist/src/generators/mitosis.js +3 -2
- package/dist/src/generators/qwik/component-generator.d.ts +2 -2
- package/dist/src/generators/qwik/component-generator.js +49 -55
- package/dist/src/generators/qwik/component.d.ts +0 -1
- package/dist/src/generators/qwik/component.js +22 -19
- package/dist/src/generators/qwik/directives.d.ts +1 -0
- package/dist/src/generators/qwik/directives.js +11 -14
- package/dist/src/generators/qwik/jsx.d.ts +1 -1
- package/dist/src/generators/qwik/jsx.js +9 -5
- package/dist/src/generators/qwik/src-generator.js +9 -3
- package/dist/src/generators/qwik/stable-serialize.d.ts +6 -0
- package/dist/src/generators/qwik/stable-serialize.js +51 -0
- package/dist/src/generators/react/generator.d.ts +6 -0
- package/dist/src/generators/{react.js → react/generator.js} +58 -150
- package/dist/src/generators/react/helpers.d.ts +2 -0
- package/dist/src/generators/react/helpers.js +14 -0
- package/dist/src/generators/react/index.d.ts +2 -0
- package/dist/src/generators/react/index.js +18 -0
- package/dist/src/generators/react/state.d.ts +9 -0
- package/dist/src/generators/react/state.js +107 -0
- package/dist/src/generators/react/types.d.ts +10 -0
- package/dist/src/{types/string-map.js → generators/react/types.js} +0 -0
- package/dist/src/generators/react-native.d.ts +2 -2
- package/dist/src/generators/solid/index.d.ts +3 -0
- package/dist/src/generators/{solid.js → solid/index.js} +80 -40
- package/dist/src/generators/solid/state.d.ts +19 -0
- package/dist/src/generators/solid/state.js +144 -0
- package/dist/src/generators/solid/types.d.ts +6 -0
- package/dist/src/generators/solid/types.js +2 -0
- package/dist/src/generators/stencil/generate.d.ts +2 -2
- package/dist/src/generators/stencil/generate.js +5 -2
- package/dist/src/generators/svelte.d.ts +6 -7
- package/dist/src/generators/svelte.js +43 -40
- package/dist/src/generators/swift-ui.d.ts +3 -5
- package/dist/src/generators/swift-ui.js +3 -2
- package/dist/src/generators/template.d.ts +2 -2
- package/dist/src/generators/template.js +3 -2
- package/dist/src/generators/vue.d.ts +5 -3
- package/dist/src/generators/vue.js +256 -113
- package/dist/src/helpers/babel-transform.d.ts +3 -1
- package/dist/src/helpers/babel-transform.js +52 -56
- package/dist/src/helpers/get-bindings.js +3 -5
- package/dist/src/helpers/get-props.js +14 -1
- package/dist/src/helpers/get-state-object-string.js +24 -21
- package/dist/src/helpers/getters-to-functions.js +1 -11
- package/dist/src/helpers/map-refs.js +25 -25
- package/dist/src/helpers/nodes/for.d.ts +4 -0
- package/dist/src/helpers/nodes/for.js +13 -0
- package/dist/src/helpers/nullable.d.ts +2 -0
- package/dist/src/helpers/nullable.js +7 -0
- package/dist/src/helpers/patterns.d.ts +2 -0
- package/dist/src/helpers/patterns.js +5 -1
- package/dist/src/helpers/render-imports.js +3 -3
- package/dist/src/helpers/replace-identifiers.d.ts +5 -0
- package/dist/src/helpers/{replace-idenifiers.js → replace-identifiers.js} +2 -1
- package/dist/src/helpers/slots.d.ts +2 -0
- package/dist/src/helpers/slots.js +15 -1
- package/dist/src/helpers/state.d.ts +0 -2
- package/dist/src/helpers/state.js +1 -10
- package/dist/src/helpers/strip-state-and-props-refs.d.ts +1 -1
- package/dist/src/helpers/strip-state-and-props-refs.js +43 -31
- package/dist/src/helpers/styles/helpers.d.ts +1 -0
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -2
- package/dist/src/parsers/angular.js +2 -2
- package/dist/src/parsers/builder.d.ts +2 -2
- package/dist/src/parsers/builder.js +61 -43
- package/dist/src/parsers/constants/outdated-prefixes.d.ts +10 -0
- package/dist/src/parsers/constants/outdated-prefixes.js +13 -0
- package/dist/src/parsers/context.js +2 -2
- package/dist/src/parsers/helpers/state.d.ts +3 -0
- package/dist/src/parsers/helpers/state.js +30 -0
- package/dist/src/parsers/jsx/component-types.d.ts +1 -1
- package/dist/src/parsers/jsx/component-types.js +15 -2
- package/dist/src/parsers/jsx/context.js +1 -1
- package/dist/src/parsers/jsx/element-parser.d.ts +6 -0
- package/dist/src/parsers/jsx/element-parser.js +243 -0
- package/dist/src/parsers/jsx/exports.d.ts +3 -0
- package/dist/src/parsers/jsx/exports.js +78 -0
- package/dist/src/parsers/jsx/function-parser.d.ts +7 -0
- package/dist/src/parsers/jsx/function-parser.js +291 -0
- package/dist/src/parsers/jsx/helpers.d.ts +2 -0
- package/dist/src/parsers/jsx/helpers.js +30 -1
- package/dist/src/parsers/jsx/imports.d.ts +7 -0
- package/dist/src/parsers/jsx/imports.js +65 -0
- package/dist/src/parsers/jsx/index.d.ts +1 -1
- package/dist/src/parsers/jsx/index.js +1 -2
- package/dist/src/parsers/jsx/jsx.js +29 -516
- package/dist/src/parsers/jsx/state.d.ts +2 -3
- package/dist/src/parsers/jsx/state.js +15 -22
- package/dist/src/plugins/compile-away-builder-components.js +6 -0
- package/dist/src/symbols/symbol-processor.js +3 -0
- package/dist/src/targets.d.ts +21 -28
- package/dist/src/targets.js +2 -2
- package/dist/src/types/config.d.ts +11 -1
- package/dist/src/types/mitosis-component.d.ts +12 -6
- package/dist/src/types/mitosis-component.js +11 -0
- package/dist/src/types/mitosis-context.d.ts +2 -2
- package/dist/src/types/mitosis-node.d.ts +14 -5
- package/dist/src/types/mitosis-node.js +3 -0
- package/dist/src/types/transpiler.d.ts +6 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/dist/src/__tests__/angular.test.d.ts +0 -1
- package/dist/src/__tests__/angular.test.js +0 -10
- package/dist/src/__tests__/builder.test.d.ts +0 -1
- package/dist/src/__tests__/builder.test.js +0 -235
- package/dist/src/__tests__/context.test.d.ts +0 -1
- package/dist/src/__tests__/context.test.js +0 -35
- package/dist/src/__tests__/data/blocks/builder-render-block.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/builder-render-block.raw.jsx +0 -90
- package/dist/src/__tests__/data/blocks/builder-render-content.raw.d.ts +0 -10
- package/dist/src/__tests__/data/blocks/builder-render-content.raw.jsx +0 -69
- package/dist/src/__tests__/hash-code.test.d.ts +0 -1
- package/dist/src/__tests__/hash-code.test.js +0 -11
- package/dist/src/__tests__/html.test.d.ts +0 -1
- package/dist/src/__tests__/html.test.js +0 -7
- package/dist/src/__tests__/liquid.test.d.ts +0 -1
- package/dist/src/__tests__/liquid.test.js +0 -7
- package/dist/src/__tests__/lit.test.d.ts +0 -1
- package/dist/src/__tests__/lit.test.js +0 -7
- package/dist/src/__tests__/marko.test.d.ts +0 -1
- package/dist/src/__tests__/marko.test.js +0 -14
- package/dist/src/__tests__/parse-jsx.test.d.ts +0 -1
- package/dist/src/__tests__/parse-jsx.test.js +0 -37
- package/dist/src/__tests__/qwik/convert-method-to-function.test.d.ts +0 -1
- package/dist/src/__tests__/qwik/convert-method-to-function.test.js +0 -37
- package/dist/src/__tests__/qwik/src-generator.test.d.ts +0 -1
- package/dist/src/__tests__/qwik/src-generator.test.js +0 -65
- package/dist/src/__tests__/qwik.directive.test.d.ts +0 -1
- package/dist/src/__tests__/qwik.directive.test.js +0 -108
- package/dist/src/__tests__/qwik.test.d.ts +0 -1
- package/dist/src/__tests__/qwik.test.js +0 -465
- package/dist/src/__tests__/react-native.test.d.ts +0 -1
- package/dist/src/__tests__/react-native.test.js +0 -7
- package/dist/src/__tests__/react.test.d.ts +0 -1
- package/dist/src/__tests__/react.test.js +0 -20
- package/dist/src/__tests__/solid.test.d.ts +0 -1
- package/dist/src/__tests__/solid.test.js +0 -10
- package/dist/src/__tests__/stencil.test.d.ts +0 -1
- package/dist/src/__tests__/stencil.test.js +0 -7
- package/dist/src/__tests__/styles.test.d.ts +0 -1
- package/dist/src/__tests__/styles.test.js +0 -23
- package/dist/src/__tests__/svelte.test.d.ts +0 -1
- package/dist/src/__tests__/svelte.test.js +0 -7
- package/dist/src/__tests__/vue.test.d.ts +0 -1
- package/dist/src/__tests__/vue.test.js +0 -7
- package/dist/src/__tests__/webcomponent.test.d.ts +0 -1
- package/dist/src/__tests__/webcomponent.test.js +0 -15
- package/dist/src/constants/function-literal-prefix.d.ts +0 -1
- package/dist/src/constants/function-literal-prefix.js +0 -4
- package/dist/src/generators/qwik/convertMethodToFunction.d.ts +0 -1
- package/dist/src/generators/qwik/convertMethodToFunction.js +0 -161
- package/dist/src/generators/react.d.ts +0 -14
- package/dist/src/generators/solid.d.ts +0 -5
- package/dist/src/helpers/babel-transform.test.d.ts +0 -1
- package/dist/src/helpers/babel-transform.test.js +0 -7
- package/dist/src/helpers/generic-format.test.d.ts +0 -1
- package/dist/src/helpers/generic-format.test.js +0 -8
- package/dist/src/helpers/map-to-attributes.d.ts +0 -2
- package/dist/src/helpers/map-to-attributes.js +0 -19
- package/dist/src/helpers/map-to-css.d.ts +0 -2
- package/dist/src/helpers/map-to-css.js +0 -16
- package/dist/src/helpers/parse-reactive-script.d.ts +0 -7
- package/dist/src/helpers/parse-reactive-script.js +0 -87
- package/dist/src/helpers/remove-surrounding-block.test.d.ts +0 -1
- package/dist/src/helpers/remove-surrounding-block.test.js +0 -9
- package/dist/src/helpers/render-imports.test.d.ts +0 -1
- package/dist/src/helpers/render-imports.test.js +0 -33
- package/dist/src/helpers/replace-idenifiers.d.ts +0 -1
- package/dist/src/helpers/styles/collect-css.test.d.ts +0 -1
- package/dist/src/helpers/styles/collect-css.test.js +0 -18
- package/dist/src/parsers/html.d.ts +0 -0
- package/dist/src/parsers/html.js +0 -2
- package/dist/src/parsers/liquid.d.ts +0 -70
- package/dist/src/parsers/liquid.js +0 -2538
- package/dist/src/types/string-map.d.ts +0 -3
- package/dist/test/qwik/Accordion/high.jsx +0 -0
- package/dist/test/qwik/Accordion/low.jsx +0 -240
- package/dist/test/qwik/Accordion/med.jsx +0 -4
- package/dist/test/qwik/For/high.jsx +0 -0
- package/dist/test/qwik/For/low.jsx +0 -52
- package/dist/test/qwik/For/med.jsx +0 -4
- package/dist/test/qwik/Image/high.js +0 -9
- package/dist/test/qwik/Image/low.js +0 -0
- package/dist/test/qwik/Image/med.js +0 -155
- package/dist/test/qwik/Image.slow/high.js +0 -9
- package/dist/test/qwik/Image.slow/low.js +0 -0
- package/dist/test/qwik/Image.slow/med.js +0 -155
- package/dist/test/qwik/bindings/high.cjs +0 -0
- package/dist/test/qwik/bindings/low.cjs +0 -45
- package/dist/test/qwik/bindings/med.cjs +0 -3
- package/dist/test/qwik/button/high.js +0 -3
- package/dist/test/qwik/button/low.js +0 -25
- package/dist/test/qwik/button/med.js +0 -31
- package/dist/test/qwik/component/bindings/high.jsx +0 -0
- package/dist/test/qwik/component/bindings/low.jsx +0 -104
- package/dist/test/qwik/component/bindings/med.jsx +0 -7
- package/dist/test/qwik/component/component/inputs/high.cjsx +0 -9
- package/dist/test/qwik/component/component/inputs/low.cjsx +0 -0
- package/dist/test/qwik/component/component/inputs/med.cjsx +0 -68
- package/dist/test/qwik/for-loop.bindings/high.cjs +0 -0
- package/dist/test/qwik/for-loop.bindings/low.cjs +0 -56
- package/dist/test/qwik/for-loop.bindings/med.cjs +0 -5
- package/dist/test/qwik/hello_world/stylesheet/high.jsx +0 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +0 -26
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +0 -4
- package/dist/test/qwik/mount/high.cjs +0 -0
- package/dist/test/qwik/mount/low.cjs +0 -47
- package/dist/test/qwik/mount/med.cjs +0 -3
- package/dist/test/qwik/page-with-symbol/high.js +0 -0
- package/dist/test/qwik/page-with-symbol/low.js +0 -33
- package/dist/test/qwik/page-with-symbol/med.js +0 -4
- package/dist/test/qwik/show-hide/high.jsx +0 -9
- package/dist/test/qwik/show-hide/low.jsx +0 -0
- package/dist/test/qwik/show-hide/med.jsx +0 -181
- package/dist/test/qwik/svg/high.js +0 -0
- package/dist/test/qwik/svg/low.js +0 -30
- package/dist/test/qwik/svg/med.js +0 -4
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +0 -19
- package/dist/test/qwik/todo/Todo.cjs/low.cjs +0 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +0 -51
- package/dist/test/qwik/todo/Todo.js/high.js +0 -19
- package/dist/test/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +0 -47
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +0 -19
- package/dist/test/qwik/todo/Todo.tsx/low.tsx +0 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +0 -43
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +0 -7
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +0 -32
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +0 -4
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var jsx_1 = require("../parsers/jsx");
|
|
4
|
-
var buttonWithMetadata = require('./data/blocks/button-with-metadata.raw');
|
|
5
|
-
var image = require('./data/blocks/image.raw');
|
|
6
|
-
var basicOnUpdateReturn = require('./data/basic-onUpdate-return.raw');
|
|
7
|
-
var basicMitosis = require('./data/basic-custom-mitosis-package.raw');
|
|
8
|
-
var basicRef = require('./data/basic-ref.raw');
|
|
9
|
-
var basicPropsRaw = require('./data/basic-props.raw');
|
|
10
|
-
var basicPropsDestructureRaw = require('./data/basic-props-destructure.raw');
|
|
11
|
-
describe('Parse JSX', function () {
|
|
12
|
-
test('metadata', function () {
|
|
13
|
-
var json = (0, jsx_1.parseJsx)(buttonWithMetadata);
|
|
14
|
-
expect(json).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
test('Image', function () {
|
|
17
|
-
var json = (0, jsx_1.parseJsx)(image);
|
|
18
|
-
expect(json).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
test('onUpdate return', function () {
|
|
21
|
-
var json = (0, jsx_1.parseJsx)(basicOnUpdateReturn);
|
|
22
|
-
expect(json).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
test('useRef', function () {
|
|
25
|
-
var json = (0, jsx_1.parseJsx)(basicRef);
|
|
26
|
-
expect(json).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
test('custom mitosis package', function () {
|
|
29
|
-
var json = (0, jsx_1.parseJsx)(basicMitosis, {
|
|
30
|
-
compileAwayPackages: ['@dummy/custom-mitosis'],
|
|
31
|
-
});
|
|
32
|
-
expect(json).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
test('custom mitosis package', function () {
|
|
35
|
-
expect((0, jsx_1.parseJsx)(basicPropsRaw)).toEqual((0, jsx_1.parseJsx)(basicPropsDestructureRaw));
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var convert_method_to_function_1 = require("../../generators/qwik/convert-method-to-function");
|
|
4
|
-
describe('convertMethodToFunction', function () {
|
|
5
|
-
var methodMap = {
|
|
6
|
-
methodA: 'method',
|
|
7
|
-
getterB: 'getter',
|
|
8
|
-
getCssFromFont: 'method',
|
|
9
|
-
};
|
|
10
|
-
var lexicalArgs = ['props', 'state'];
|
|
11
|
-
describe('rewrite', function () {
|
|
12
|
-
test('method', function () {
|
|
13
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)('this.methodA(123)', methodMap, lexicalArgs)).toEqual('methodA(props,state,123)');
|
|
14
|
-
});
|
|
15
|
-
test('getter', function () {
|
|
16
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)('this.getterB', methodMap, lexicalArgs)).toEqual('getterB(props,state)');
|
|
17
|
-
});
|
|
18
|
-
test('method binding', function () {
|
|
19
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)('this.methodA', methodMap, lexicalArgs)).toEqual('methodA.bind(null,props,state)');
|
|
20
|
-
});
|
|
21
|
-
test('handle comments', function () {
|
|
22
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)('//\nreturn this.getterB;', methodMap, lexicalArgs)).toEqual('//\nreturn getterB(props,state);');
|
|
23
|
-
});
|
|
24
|
-
test('braces', function () {
|
|
25
|
-
var code = 'getFontCss({}: {}) { this.getCssFromFont(font) }';
|
|
26
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)(code, methodMap, lexicalArgs)).toEqual('getFontCss({}: {}) { getCssFromFont(props,state,font) }');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('string', function () {
|
|
30
|
-
test('should not rewrite string', function () {
|
|
31
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)('"this.getterB"', methodMap, lexicalArgs)).toEqual('"this.getterB"');
|
|
32
|
-
});
|
|
33
|
-
test('should rewrite template string', function () {
|
|
34
|
-
expect((0, convert_method_to_function_1.convertMethodToFunction)('`${this.getterB}this.getterB`', methodMap, lexicalArgs)).toEqual('`${getterB(props,state)}this.getterB`');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var src_generator_1 = require("../../generators/qwik/src-generator");
|
|
4
|
-
describe('src-generator', function () {
|
|
5
|
-
describe('isStatement', function () {
|
|
6
|
-
test('is an expression', function () {
|
|
7
|
-
expect((0, src_generator_1.isStatement)('a.b')).toBe(false);
|
|
8
|
-
expect((0, src_generator_1.isStatement)('1?2:"bar"')).toBe(false);
|
|
9
|
-
expect((0, src_generator_1.isStatement)('"var x; return foo + \'\\"\';"')).toBe(false);
|
|
10
|
-
expect((0, src_generator_1.isStatement)('"foo" + `bar\nbaz`')).toBe(false);
|
|
11
|
-
expect((0, src_generator_1.isStatement)('(...)()')).toBe(false);
|
|
12
|
-
});
|
|
13
|
-
test('regression', function () {
|
|
14
|
-
expect((0, src_generator_1.isStatement)('props.attributes?.class || props.attributes?.className')).toBe(false);
|
|
15
|
-
});
|
|
16
|
-
test('is a statement', function () {
|
|
17
|
-
expect((0, src_generator_1.isStatement)('var x; return x;')).toBe(true);
|
|
18
|
-
expect((0, src_generator_1.isStatement)('var x')).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('import', function () {
|
|
22
|
-
var options;
|
|
23
|
-
var src;
|
|
24
|
-
describe('module', function () {
|
|
25
|
-
beforeEach(function () {
|
|
26
|
-
options = {
|
|
27
|
-
isJSX: true,
|
|
28
|
-
isPretty: false,
|
|
29
|
-
isTypeScript: false,
|
|
30
|
-
isModule: true,
|
|
31
|
-
isBuilder: false,
|
|
32
|
-
};
|
|
33
|
-
src = new src_generator_1.SrcBuilder(new src_generator_1.File('test', options, '', ''), options);
|
|
34
|
-
});
|
|
35
|
-
test('import to string', function () {
|
|
36
|
-
src.import('module', [new src_generator_1.Symbol('importName', 'asLocalName')]);
|
|
37
|
-
expect(src.toString()).toEqual('import{importName as asLocalName}from"module";');
|
|
38
|
-
});
|
|
39
|
-
test('import from default', function () {
|
|
40
|
-
src.import('module', [new src_generator_1.Symbol('default', 'asLocalName')]);
|
|
41
|
-
expect(src.toString()).toEqual('import asLocalName from"module";');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('require', function () {
|
|
45
|
-
beforeEach(function () {
|
|
46
|
-
options = {
|
|
47
|
-
isJSX: true,
|
|
48
|
-
isPretty: false,
|
|
49
|
-
isTypeScript: false,
|
|
50
|
-
isModule: false,
|
|
51
|
-
isBuilder: false,
|
|
52
|
-
};
|
|
53
|
-
src = new src_generator_1.SrcBuilder(new src_generator_1.File('test', options, '', ''), options);
|
|
54
|
-
});
|
|
55
|
-
test('import to string', function () {
|
|
56
|
-
src.import('module', [new src_generator_1.Symbol('importName', 'asLocalName')]);
|
|
57
|
-
expect(src.toString()).toEqual('const asLocalName=require("module").importName;');
|
|
58
|
-
});
|
|
59
|
-
test('import from default', function () {
|
|
60
|
-
src.import('module', [new src_generator_1.Symbol('default', 'asLocalName')]);
|
|
61
|
-
expect(src.toString()).toEqual('const asLocalName=require("module");');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var directives_1 = require("../generators/qwik/directives");
|
|
4
|
-
describe('qwik directives', function () {
|
|
5
|
-
var partial = expect.objectContaining;
|
|
6
|
-
beforeEach(function () {
|
|
7
|
-
global.h = mockH;
|
|
8
|
-
});
|
|
9
|
-
afterEach(function () { return (global.h = undefined); });
|
|
10
|
-
describe('Image', function () {
|
|
11
|
-
test('altText', function () {
|
|
12
|
-
expect((0, directives_1.Image)({ altText: 'foo', image: 'http://some.url' }).children[0][0]).toEqual(partial({
|
|
13
|
-
tag: 'img',
|
|
14
|
-
props: partial({ src: 'http://some.url', alt: 'foo' }),
|
|
15
|
-
}));
|
|
16
|
-
expect((0, directives_1.Image)({ image: 'http://some.url' }).children[0][0]).toEqual(partial({
|
|
17
|
-
tag: 'img',
|
|
18
|
-
props: partial({ src: 'http://some.url', role: 'presentation' }),
|
|
19
|
-
}));
|
|
20
|
-
});
|
|
21
|
-
test('builder-pixel is eager', function () {
|
|
22
|
-
expect((0, directives_1.Image)({
|
|
23
|
-
builderBlock: { id: 'builder-pixel-foo' },
|
|
24
|
-
image: 'http://some.url',
|
|
25
|
-
}).children[0][0]).toEqual(partial({
|
|
26
|
-
tag: 'img',
|
|
27
|
-
props: partial({ loading: 'eager' }),
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
|
-
test('images are lazy loaded', function () {
|
|
31
|
-
expect((0, directives_1.Image)({
|
|
32
|
-
image: 'http://some.url',
|
|
33
|
-
}).children[0][0]).toEqual(partial({
|
|
34
|
-
tag: 'img',
|
|
35
|
-
props: partial({ loading: 'lazy' }),
|
|
36
|
-
}));
|
|
37
|
-
});
|
|
38
|
-
test('builder.io URLs are served using webp', function () {
|
|
39
|
-
expect(find('source', (0, directives_1.Image)({
|
|
40
|
-
image: 'http://foo.builder.io/foo',
|
|
41
|
-
}))).toEqual(partial({
|
|
42
|
-
tag: 'source',
|
|
43
|
-
props: partial({
|
|
44
|
-
srcset: srcSet('http://foo.builder.io/foo?format=webp'),
|
|
45
|
-
type: 'image/webp',
|
|
46
|
-
}),
|
|
47
|
-
}));
|
|
48
|
-
});
|
|
49
|
-
test('maxWidth is added to the srcs', function () {
|
|
50
|
-
expect(find('source', (0, directives_1.Image)({
|
|
51
|
-
image: 'http://foo.builder.io/foo',
|
|
52
|
-
srcsetSizes: '1234 456',
|
|
53
|
-
}))).toEqual(partial({
|
|
54
|
-
tag: 'source',
|
|
55
|
-
props: partial({
|
|
56
|
-
srcset: srcSet('http://foo.builder.io/foo?format=webp', '1234 456'),
|
|
57
|
-
type: 'image/webp',
|
|
58
|
-
}),
|
|
59
|
-
}));
|
|
60
|
-
});
|
|
61
|
-
test('anchor should wrap in <a>', function () {
|
|
62
|
-
expect(find('a', (0, directives_1.Image)({
|
|
63
|
-
image: 'http://some.url',
|
|
64
|
-
href: 'my-url',
|
|
65
|
-
}))).toEqual(partial({
|
|
66
|
-
tag: 'a',
|
|
67
|
-
props: partial({ href: 'my-url' }),
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
function find(tag, jsx) {
|
|
73
|
-
if (tag == jsx.tag)
|
|
74
|
-
return jsx;
|
|
75
|
-
return findInChildren(tag, jsx.children);
|
|
76
|
-
function findInChildren(tag, jsxs) {
|
|
77
|
-
var value = undefined;
|
|
78
|
-
for (var i = 0; i < jsxs.length; i++) {
|
|
79
|
-
var jsx_1 = jsxs[i];
|
|
80
|
-
if (Array.isArray(jsx_1)) {
|
|
81
|
-
value = findInChildren(tag, jsx_1);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
value = find(tag, jsx_1);
|
|
85
|
-
}
|
|
86
|
-
if (value)
|
|
87
|
-
return value;
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
var mockH = function (tag, props, children) { return ({
|
|
93
|
-
tag: tag,
|
|
94
|
-
props: props,
|
|
95
|
-
children: children,
|
|
96
|
-
}); };
|
|
97
|
-
function srcSet(url, additionalSizes) {
|
|
98
|
-
if (additionalSizes === void 0) { additionalSizes = ''; }
|
|
99
|
-
return ['100', '200', '400', '800', '1200', '1600', '2000']
|
|
100
|
-
.concat(additionalSizes ? additionalSizes.split(' ') : [])
|
|
101
|
-
.map(function (size) {
|
|
102
|
-
var parsedUrl = new URL(url);
|
|
103
|
-
parsedUrl.searchParams.set('width', size);
|
|
104
|
-
return "".concat(parsedUrl, " ").concat(size, "w");
|
|
105
|
-
})
|
|
106
|
-
.concat([url.replace('?format=webp', '')])
|
|
107
|
-
.join(', ');
|
|
108
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|