@wix/react-component-schema 1.0.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.
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import { describe, expect, it } from 'vitest'
4
+
5
+ describe('react-component-schema dist', () => {
6
+ it('dist/index.js matches snapshot', () => {
7
+ const content = readFileSync(resolve(__dirname, '../dist/index.js'), 'utf-8')
8
+ expect(content).toMatchSnapshot()
9
+ })
10
+
11
+ it('dist/index.d.ts matches snapshot', () => {
12
+ const content = readFileSync(resolve(__dirname, '../dist/index.d.ts'), 'utf-8')
13
+ expect(content).toMatchSnapshot()
14
+ })
15
+ })
package/src/index.ts ADDED
@@ -0,0 +1,86 @@
1
+ export {
2
+ DATA,
3
+ MEDIA,
4
+ ELEMENTS,
5
+ CSS_PROPERTIES,
6
+ ACTIONS,
7
+ LAYOUT,
8
+ DISPLAY_GROUPS,
9
+ INTERACTIONS,
10
+ ARCHETYPE,
11
+ CONTAINER_TYPE,
12
+ NATIVE_STATE_TYPE,
13
+ ACTION_NAME,
14
+ OverrideType,
15
+ } from '@wix/component-protocol/schema'
16
+
17
+ export type {
18
+ EditorReactComponent,
19
+ Behaviors,
20
+ StyleItem,
21
+ CssProperties,
22
+ CssPropertiesOverrides,
23
+ CssCustomProperties,
24
+ CssPropertyItem,
25
+ CssPropertyItemDefinitionOverrides,
26
+ Data,
27
+ DataOverrides,
28
+ DataItems,
29
+ DataItem,
30
+ DataItemsMap,
31
+ Presets,
32
+ PresetItem,
33
+ Elements,
34
+ ElementsDefaults,
35
+ ElementItem,
36
+ EditorElement,
37
+ EditorElementLayout,
38
+ InlineElement,
39
+ RefElement,
40
+ States,
41
+ Actions,
42
+ CustomActions,
43
+ Action,
44
+ DashboardAction,
45
+ Execution,
46
+ DataAction,
47
+ EventAction,
48
+ PanelAction,
49
+ ForwardAction,
50
+ DisplayFilters,
51
+ DisplayFilter,
52
+ DisplayGroups,
53
+ DisplayGroupItem,
54
+ VisibleState,
55
+ HelpArticle,
56
+ ComponentInitialSize,
57
+ CssCustomPropertyItem,
58
+ Filter,
59
+ BackdropFilter,
60
+ Display,
61
+ WritingMode,
62
+ Background,
63
+ CustomPropertyEnum,
64
+ CustomPropertyEnumOption,
65
+ CssNumber,
66
+ Text,
67
+ TextEnum,
68
+ DataNumber,
69
+ A11y,
70
+ Link,
71
+ ArrayItems,
72
+ Image,
73
+ Video,
74
+ VectorArt,
75
+ ShorthandGroupBackground,
76
+ Coordinates,
77
+ ShorthandGroupBorder,
78
+ Corners,
79
+ Font,
80
+ TextDecoration,
81
+ Gap,
82
+ ItemsGroup,
83
+ TextGroup,
84
+ DataGroupsArrayItems,
85
+ ListItem,
86
+ } from '@wix/component-protocol/schema'
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": ["ES2020"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "declaration": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,64 @@
1
+ import { resolve } from 'node:path'
2
+ import type { Plugin } from 'vite'
3
+ import { defineConfig } from 'vite'
4
+ import dts from 'vite-plugin-dts'
5
+
6
+ /**
7
+ * Adds /*#__PURE__*\/ annotations to TypeScript enum IIFEs.
8
+ *
9
+ * TypeScript compiles enums to:
10
+ * export var Exposure;
11
+ * (function(Exposure) { ... })(Exposure || (Exposure = {}));
12
+ *
13
+ * Without annotations Rollup conservatively keeps every IIFE, even for unused
14
+ * enums. The PURE marker tells Rollup these IIFEs are side-effect-free so it
15
+ * can drop any enum that isn't actually imported.
16
+ *
17
+ * Applied to @wix/component-protocol and its bundled ambassador chunk so that
18
+ * the ~300 unused ambassador enums are eliminated from our output.
19
+ */
20
+ function pureEnumAnnotationsPlugin(): Plugin {
21
+ return {
22
+ name: 'pure-enum-annotations',
23
+ transform(code, id) {
24
+ if (!id.includes('@wix/component-protocol')) return null
25
+ return code.replace(/\(function\s*\(/g, '/*#__PURE__*/(function(')
26
+ },
27
+ // Strip the annotations from the final output so that downstream bundlers
28
+ // don't incorrectly tree-shake the enum IIFE bodies (which mutate the enum
29
+ // objects). The annotations are only needed during this build's own
30
+ // tree-shaking pass to eliminate the ~300 unused ambassador enums.
31
+ renderChunk(code) {
32
+ return code.replace(/\/\*#__PURE__\*\//g, '')
33
+ },
34
+ }
35
+ }
36
+
37
+ export default defineConfig({
38
+ plugins: [
39
+ pureEnumAnnotationsPlugin(),
40
+ dts({
41
+ include: ['src/**/*.ts'],
42
+ exclude: ['**/*.test.ts'],
43
+ rollupTypes: true,
44
+ bundledPackages: [
45
+ '@wix/component-protocol',
46
+ '@wix/ambassador-devcenter-v1-component-type-data',
47
+ '@wix/ambassador-devcenter-components-overrides-v1-components-override',
48
+ ],
49
+ }),
50
+ ],
51
+ build: {
52
+ lib: {
53
+ entry: resolve(__dirname, 'src/index.ts'),
54
+ formats: ['es'],
55
+ fileName: 'index',
56
+ },
57
+ rollupOptions: {
58
+ // No externals — inline everything for a zero-dep bundle
59
+ external: [],
60
+ },
61
+ minify: false,
62
+ outDir: 'dist',
63
+ },
64
+ })