@wix/react-component-schema 1.4.0 → 1.6.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/dist/editor-react-types.d.ts +408 -0
- package/dist/index.d.ts +230 -0
- package/package.json +7 -2
- package/src/__snapshots__/index.test.ts.snap +642 -0
- package/src/editor-react-types.ts +20 -0
- package/src/index.test.ts +5 -0
- package/src/index.ts +1 -0
- package/vite.config.ts +38 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Blacklisted types are excluded by omitting them from the explicit list below.
|
|
2
|
+
export type {
|
|
3
|
+
A11y,
|
|
4
|
+
Audio,
|
|
5
|
+
Direction,
|
|
6
|
+
Image,
|
|
7
|
+
Link,
|
|
8
|
+
LocalDate,
|
|
9
|
+
LocalTime,
|
|
10
|
+
MenuItems,
|
|
11
|
+
RichText,
|
|
12
|
+
VectorArt,
|
|
13
|
+
Video,
|
|
14
|
+
WebUrl,
|
|
15
|
+
// TODO: Not supported by auto panels
|
|
16
|
+
// Email,
|
|
17
|
+
// LocalDateTime,
|
|
18
|
+
// Phone,
|
|
19
|
+
// Regex,
|
|
20
|
+
} from '@wix/editor-react-types'
|
package/src/index.test.ts
CHANGED
|
@@ -12,4 +12,9 @@ describe('react-component-schema dist', () => {
|
|
|
12
12
|
const content = readFileSync(resolve(__dirname, '../dist/index.d.ts'), 'utf-8')
|
|
13
13
|
expect(content).toMatchSnapshot()
|
|
14
14
|
})
|
|
15
|
+
|
|
16
|
+
it('dist/editor-react-types.d.ts matches snapshot', () => {
|
|
17
|
+
const content = readFileSync(resolve(__dirname, '../dist/editor-react-types.d.ts'), 'utf-8')
|
|
18
|
+
expect(content).toMatchSnapshot()
|
|
19
|
+
})
|
|
15
20
|
})
|
package/src/index.ts
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
1
2
|
import { resolve } from 'node:path'
|
|
2
3
|
import type { Plugin } from 'vite'
|
|
3
4
|
import { defineConfig } from 'vite'
|
|
@@ -34,9 +35,40 @@ function pureEnumAnnotationsPlugin(): Plugin {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Wraps the generated editor-react-types.d.ts in a `declare module` block.
|
|
40
|
+
*
|
|
41
|
+
* vite-plugin-dts (with rollupTypes) inlines all bundled types. This plugin
|
|
42
|
+
* then wraps the inlined output so that consumers get a self-contained ambient
|
|
43
|
+
* module declaration for '@wix/editor-react-types' instead of a flat re-export.
|
|
44
|
+
*/
|
|
45
|
+
function wrapEditorReactTypesDeclarationPlugin(): Plugin {
|
|
46
|
+
return {
|
|
47
|
+
name: 'wrap-editor-react-types-declaration',
|
|
48
|
+
generateBundle(_options, bundle) {
|
|
49
|
+
// biome-ignore lint: ignore prohibition of delete
|
|
50
|
+
delete bundle['editor-react-types.js']
|
|
51
|
+
},
|
|
52
|
+
closeBundle() {
|
|
53
|
+
const declarationFilePath = resolve(__dirname, 'dist/editor-react-types.d.ts')
|
|
54
|
+
if (!existsSync(declarationFilePath)) return
|
|
55
|
+
const content = readFileSync(declarationFilePath, 'utf-8')
|
|
56
|
+
if (content.startsWith("declare module '@wix/editor-react-types'")) return
|
|
57
|
+
// Inside `declare module` every declaration is already ambient — strip
|
|
58
|
+
// the redundant `declare` keyword (bare or after `export`) to avoid TS2842.
|
|
59
|
+
const ambientContent = content.replace(
|
|
60
|
+
/^(export )?declare (type|interface|class|const|function|var|enum|namespace|abstract class)\b/gm,
|
|
61
|
+
'$1$2',
|
|
62
|
+
)
|
|
63
|
+
writeFileSync(declarationFilePath, `declare module '@wix/editor-react-types' {\n${ambientContent}}\n`)
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
37
68
|
export default defineConfig({
|
|
38
69
|
plugins: [
|
|
39
70
|
pureEnumAnnotationsPlugin(),
|
|
71
|
+
wrapEditorReactTypesDeclarationPlugin(),
|
|
40
72
|
dts({
|
|
41
73
|
include: ['src/**/*.ts'],
|
|
42
74
|
exclude: ['**/*.test.ts'],
|
|
@@ -45,14 +77,18 @@ export default defineConfig({
|
|
|
45
77
|
'@wix/component-protocol',
|
|
46
78
|
'@wix/ambassador-devcenter-v1-component-type-data',
|
|
47
79
|
'@wix/ambassador-devcenter-components-overrides-v1-components-override',
|
|
80
|
+
'@wix/editor-react-types',
|
|
48
81
|
],
|
|
49
82
|
}),
|
|
50
83
|
],
|
|
51
84
|
build: {
|
|
52
85
|
lib: {
|
|
53
|
-
entry:
|
|
86
|
+
entry: {
|
|
87
|
+
index: resolve(__dirname, 'src/index.ts'),
|
|
88
|
+
'editor-react-types': resolve(__dirname, 'src/editor-react-types.ts'),
|
|
89
|
+
},
|
|
54
90
|
formats: ['es'],
|
|
55
|
-
fileName:
|
|
91
|
+
fileName: (format, entryName) => `${entryName}.js`,
|
|
56
92
|
},
|
|
57
93
|
rollupOptions: {
|
|
58
94
|
// No externals — inline everything for a zero-dep bundle
|