playroom 0.28.0 → 0.28.1
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/.github/workflows/preview-site.yml +4 -4
- package/.github/workflows/release.yml +5 -5
- package/.github/workflows/snapshot.yml +31 -0
- package/.github/workflows/validate.yml +4 -4
- package/README.md +2 -0
- package/cypress/integration/smoke.js +8 -4
- package/cypress/support/utils.js +8 -3
- package/lib/makeWebpackConfig.js +27 -0
- package/package.json +13 -10
- package/src/Playroom/CodeEditor/CodeEditor.tsx +8 -20
- package/src/Playroom/CodeEditor/CodeMirror2.tsx +748 -0
- package/src/Playroom/Frame.tsx +3 -3
- package/src/Playroom/FramesPanel/FramesPanel.tsx +1 -1
- package/src/Playroom/Playroom.tsx +1 -2
- package/src/Playroom/Preview.tsx +9 -7
- package/src/Playroom/SplashScreen/SplashScreen.tsx +1 -0
- package/src/Playroom/WindowPortal/index.tsx +58 -63
- package/src/frame.js +2 -2
- package/src/index.js +6 -6
- package/src/preview.js +2 -2
- package/src/render.js +19 -0
- package/src/utils/componentsToHints.ts +1 -1
|
@@ -13,12 +13,12 @@ jobs:
|
|
|
13
13
|
CI: true
|
|
14
14
|
steps:
|
|
15
15
|
- name: Checkout Repo
|
|
16
|
-
uses: actions/checkout@
|
|
16
|
+
uses: actions/checkout@v3
|
|
17
17
|
|
|
18
|
-
- name:
|
|
19
|
-
uses: actions/setup-node@
|
|
18
|
+
- name: Set up Node.js
|
|
19
|
+
uses: actions/setup-node@v3
|
|
20
20
|
with:
|
|
21
|
-
node-version:
|
|
21
|
+
node-version-file: 'package.json'
|
|
22
22
|
|
|
23
23
|
- name: Install Dependencies
|
|
24
24
|
run: yarn --frozen-lockfile
|
|
@@ -13,16 +13,16 @@ jobs:
|
|
|
13
13
|
CI: true
|
|
14
14
|
steps:
|
|
15
15
|
- name: Checkout Repo
|
|
16
|
-
uses: actions/checkout@
|
|
16
|
+
uses: actions/checkout@v3
|
|
17
17
|
with:
|
|
18
18
|
# This makes Actions fetch all Git history for semantic-release
|
|
19
19
|
fetch-depth: 0
|
|
20
20
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
21
21
|
|
|
22
|
-
- name:
|
|
23
|
-
uses: actions/setup-node@
|
|
22
|
+
- name: Set up Node.js
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
24
|
with:
|
|
25
|
-
node-version:
|
|
25
|
+
node-version-file: 'package.json'
|
|
26
26
|
|
|
27
27
|
- name: Install Dependencies
|
|
28
28
|
run: yarn --frozen-lockfile
|
|
@@ -31,4 +31,4 @@ jobs:
|
|
|
31
31
|
run: yarn semantic-release
|
|
32
32
|
env:
|
|
33
33
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
-
NPM_TOKEN: ${{ secrets.
|
|
34
|
+
NPM_TOKEN: ${{ secrets.SEEK_OSS_CI_NPM_TOKEN }}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Snapshot
|
|
2
|
+
|
|
3
|
+
on: workflow_dispatch
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
release:
|
|
7
|
+
name: Publish snapshot version
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
env:
|
|
10
|
+
CI: true
|
|
11
|
+
steps:
|
|
12
|
+
- name: Check out repo
|
|
13
|
+
uses: actions/checkout@v3
|
|
14
|
+
with:
|
|
15
|
+
# This makes Actions fetch all Git history for semantic-release
|
|
16
|
+
fetch-depth: 0
|
|
17
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
18
|
+
|
|
19
|
+
- name: Set up Node.js
|
|
20
|
+
uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version-file: 'package.json'
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: yarn --frozen-lockfile
|
|
26
|
+
|
|
27
|
+
- name: Publish
|
|
28
|
+
uses: seek-oss/changesets-snapshot@v0
|
|
29
|
+
env:
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
NPM_TOKEN: ${{ secrets.SEEK_OSS_CI_NPM_TOKEN }}
|
|
@@ -10,12 +10,12 @@ jobs:
|
|
|
10
10
|
CI: true
|
|
11
11
|
steps:
|
|
12
12
|
- name: Checkout Repo
|
|
13
|
-
uses: actions/checkout@
|
|
13
|
+
uses: actions/checkout@v3
|
|
14
14
|
|
|
15
|
-
- name:
|
|
16
|
-
uses: actions/setup-node@
|
|
15
|
+
- name: Set up Node.js
|
|
16
|
+
uses: actions/setup-node@v3
|
|
17
17
|
with:
|
|
18
|
-
node-version:
|
|
18
|
+
node-version-file: 'package.json'
|
|
19
19
|
|
|
20
20
|
- name: Install Dependencies
|
|
21
21
|
run: yarn --frozen-lockfile
|
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ Playroom allows you to create a zero-install code-oriented design environment, b
|
|
|
30
30
|
|
|
31
31
|
[Mística Design System](https://mistica-web.vercel.app/playroom) (Themed)
|
|
32
32
|
|
|
33
|
+
[Shopify Polaris](https://polaris.shopify.com/sandbox?code=N4Igxg9gJgpiBcIA8BhAhgJygHQHYAJ8BnGSXKTATwDEIIAXGDAQTHoEsJciBeYAbWBlGuevHwByACLsiAW1lEJAXwC6yvIQAOGdnKq0GTVhy58hXEWMkBRAB5aIGevgBKMR85UbcAPk34qJhQAHQAEjBosBj4aGyc3HyC%2BMIwouISACoMaAA2%2BADKeTBK%2BGrK%2BBz0uTA82CBFNUT1-gSEgQAKEI4AbkwB7bHxfXwAZnkkPoOEcRw9aPROfAPTSABCAK70iwRQsmC5EEQbGDD4Wrlo7H4r0-gAauwwAO6Fxc1td0gA9JvbXK07lNplwUIcSHwABQASnwPF8%2BGAymBhEBqxMCQAMrIXOxGHJeAILKI0tYJABxDBHIhvJoqAA0iNS6UkADkYC5GiUVOp8N80YQfl1ekw0T90FhwpFomKJaECqRTDdPoFMjA7PQUJYrrhRbd8ABNCAbFJoAgbEjEd74U6eeg0xbEGBna6jJz6JWxABGxpclGNMTAFsWciYREAmAT6pzRGletAkKD4LgpXSMXRoYgbMAAC1iNKI1ogfRiHFDjK9lBS2bNutyjKc%2BAr%2BqI9DQo1GIRWPzVGq1oh1era4uCIQV8QBASCkrHnqqNTqIGyrfyXJpa1OaAA1lAIM9cC0u%2B4iAGwDBsS39adjydT6y0KHzERrgBzDaXDAZAs1CSMi4nPKfu83j6niMAEkk%2BqEMAkHtF%2BJQZAA8lgYY-jBMxyMaLISAAqgUUgACQAAwhIRhGoSqdwnLkGS2k49rfNGKH0jByjMRR7TQexgxwUQGTuPQJzcORdyDPemFkgAtLhBEAEwAKzEaRwkiYQVE0R4dFEN8pwCRgQlsSprH6uol5pNEACS%2BJQqBciwvCiIwWQLaIjxjJiRsoiMlRFQ8PgNkANwwTpgn4JCaGBEeJ5njiISWWB4WqRguR8N5CVDKeRBPl67C5HilCYmgXowMlwAAAaPC8tIlPgboxPhwA8copUoip%2BACq1SAFK2YCbu1rWBF1cSbrF%2BI1TluS%2BA17zKD8g09SNYF9R1c3DXFciTe5ogzd8K0LetaWzd1vXhT8kU3tFLZ7UthDQoF7HIvq-KTt8cqjoqCSyiOM4JJUeLzvUUiRMMCwwImtHOM0ICZl6UAbKD7VIOe9BLYjMVrb4HRoP6WxED8SNXfqqOXejS55FVa6Vig1a4LWeNo-iCPfEjYovV970TkOr3fcmc61PUrJGAeKpID2mratcg53Jk2ZnDxNoaRDsSnLE8w5YVNRJrguSVuwoz4NjMQtk4Lo0jzMuFNm3S65Q%2BoXGaSYxNm7DPjLGCdsL3yi32rYSxgLNc%2BzyrDlgvggPSID0DLoZEAg-AgIcYDFPAaQgKo4fPOwUCRzH8D8OoQA)
|
|
34
|
+
|
|
33
35
|
Send us a PR if you'd like to be in this list!
|
|
34
36
|
|
|
35
37
|
## Getting Started
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
assertPreviewContains,
|
|
3
|
+
getFirstFrame,
|
|
4
|
+
loadPlayroom,
|
|
5
|
+
} from '../support/utils';
|
|
2
6
|
|
|
3
7
|
describe('Smoke', () => {
|
|
4
8
|
it('frames are interactive', () => {
|
|
@@ -9,8 +13,8 @@ describe('Smoke', () => {
|
|
|
9
13
|
it('preview mode loads correctly', () => {
|
|
10
14
|
cy.visit(
|
|
11
15
|
'http://localhost:9000/preview#?code=N4Igxg9gJgpiBcIA8AxCEB8r1YEIEMAnAei2LUyXJxAF8g'
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
assertPreviewContains('Foo\nFoo\nBar');
|
|
15
19
|
});
|
|
16
20
|
});
|
package/cypress/support/utils.js
CHANGED
|
@@ -114,9 +114,14 @@ export const assertFramesMatch = (matches) =>
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
export const assertPreviewContains = (text) =>
|
|
117
|
-
cy
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
cy
|
|
118
|
+
.then(() => {
|
|
119
|
+
cy.get('[data-testid="splashscreen"]').should('not.be.visible');
|
|
120
|
+
})
|
|
121
|
+
.get('body')
|
|
122
|
+
.then((el) => {
|
|
123
|
+
expect(el.get(0).innerText).to.eq(text);
|
|
124
|
+
});
|
|
120
125
|
|
|
121
126
|
export const loadPlayroom = () =>
|
|
122
127
|
cy
|
package/lib/makeWebpackConfig.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const webpack = require('webpack');
|
|
3
4
|
const { merge } = require('webpack-merge');
|
|
@@ -18,6 +19,22 @@ module.exports = async (playroomConfig, options) => {
|
|
|
18
19
|
const relativeResolve = (requirePath) =>
|
|
19
20
|
require.resolve(requirePath, { paths: [playroomConfig.cwd] });
|
|
20
21
|
|
|
22
|
+
let isLegacyReact = true;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
// eslint-disable-next-line no-sync
|
|
26
|
+
const pkgContents = fs.readFileSync(
|
|
27
|
+
relativeResolve('react-dom/package.json'),
|
|
28
|
+
{
|
|
29
|
+
encoding: 'utf-8',
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
const { version } = JSON.parse(pkgContents);
|
|
33
|
+
isLegacyReact = !(version.startsWith('18') || version.startsWith('0.0.0'));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw new Error('Unable to read `react-dom` package json');
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
const staticTypes = await getStaticTypes(playroomConfig);
|
|
22
39
|
|
|
23
40
|
const ourConfig = {
|
|
@@ -158,6 +175,16 @@ module.exports = async (playroomConfig, options) => {
|
|
|
158
175
|
new VanillaExtractPlugin(),
|
|
159
176
|
new MiniCssExtractPlugin({ ignoreOrder: true }),
|
|
160
177
|
...(options.production ? [] : [new FriendlyErrorsWebpackPlugin()]),
|
|
178
|
+
// If using a version of React earlier than 18, ignore the
|
|
179
|
+
// react-dom/client import. This hack can be removed when
|
|
180
|
+
// support for older versions of React is removed.
|
|
181
|
+
...(isLegacyReact
|
|
182
|
+
? [
|
|
183
|
+
new webpack.IgnorePlugin({
|
|
184
|
+
resourceRegExp: /react-dom\/client$/,
|
|
185
|
+
}),
|
|
186
|
+
]
|
|
187
|
+
: []),
|
|
161
188
|
],
|
|
162
189
|
devtool: !options.production && 'eval-source-map',
|
|
163
190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playroom",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "Design with code, powered by your own component library",
|
|
5
5
|
"main": "utils/index.js",
|
|
6
6
|
"types": "utils/index.d.ts",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"@types/lodash": "^4.14.168",
|
|
76
76
|
"@types/lz-string": "^1.3.34",
|
|
77
77
|
"@types/prettier": "^2.2.3",
|
|
78
|
-
"@types/react": "^
|
|
79
|
-
"@types/react-dom": "^
|
|
78
|
+
"@types/react": "^18.0.9",
|
|
79
|
+
"@types/react-dom": "^18.0.4",
|
|
80
80
|
"@vanilla-extract/babel-plugin": "^1.1.5",
|
|
81
81
|
"@vanilla-extract/css": "^1.7.0",
|
|
82
82
|
"@vanilla-extract/css-utils": "^0.1.2",
|
|
@@ -108,10 +108,9 @@
|
|
|
108
108
|
"prettier": "^2.2.1",
|
|
109
109
|
"prop-types": "^15.7.2",
|
|
110
110
|
"query-string": "^6.14.1",
|
|
111
|
-
"re-resizable": "^6.9.
|
|
112
|
-
"react-codemirror2": "^7.2.1",
|
|
111
|
+
"re-resizable": "^6.9.6",
|
|
113
112
|
"react-docgen-typescript": "^2.1.0",
|
|
114
|
-
"react-use": "^17.
|
|
113
|
+
"react-use": "^17.4.0",
|
|
115
114
|
"read-pkg-up": "^7.0.1",
|
|
116
115
|
"scope-eval": "^1.0.0",
|
|
117
116
|
"typescript": "^4.3.2",
|
|
@@ -135,15 +134,19 @@
|
|
|
135
134
|
"husky": "^4.3.8",
|
|
136
135
|
"jest": "^26.6.3",
|
|
137
136
|
"lint-staged": "^10.5.4",
|
|
138
|
-
"react": "^
|
|
139
|
-
"react-dom": "^
|
|
137
|
+
"react": "^18.0.1",
|
|
138
|
+
"react-dom": "^18.0.1",
|
|
140
139
|
"semantic-release": "^17.4.2",
|
|
141
140
|
"serve": "^11.3.2",
|
|
142
141
|
"start-server-and-test": "^1.12.0",
|
|
143
142
|
"surge": "^0.22.1"
|
|
144
143
|
},
|
|
145
144
|
"peerDependencies": {
|
|
146
|
-
"react": "^16.8 || ^17
|
|
147
|
-
"react-dom": "^16.8 || ^17
|
|
145
|
+
"react": "^16.8 || ^17 || ^18",
|
|
146
|
+
"react-dom": "^16.8 || ^17 || ^18"
|
|
147
|
+
},
|
|
148
|
+
"volta": {
|
|
149
|
+
"node": "12.22.12",
|
|
150
|
+
"yarn": "1.22.19"
|
|
148
151
|
}
|
|
149
152
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useContext, useEffect, useCallback } from 'react';
|
|
2
2
|
import { useDebouncedCallback } from 'use-debounce';
|
|
3
|
-
import { Editor } from 'codemirror';
|
|
3
|
+
import CodeMirror, { Editor } from 'codemirror';
|
|
4
4
|
import 'codemirror/lib/codemirror.css';
|
|
5
5
|
import 'codemirror/theme/neo.css';
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ import { compileJsx } from '../../utils/compileJsx';
|
|
|
10
10
|
|
|
11
11
|
import * as styles from './CodeEditor.css';
|
|
12
12
|
|
|
13
|
-
import { UnControlled as ReactCodeMirror } from '
|
|
13
|
+
import { UnControlled as ReactCodeMirror } from './CodeMirror2';
|
|
14
14
|
import 'codemirror/mode/jsx/jsx';
|
|
15
15
|
import 'codemirror/addon/edit/closetag';
|
|
16
16
|
import 'codemirror/addon/edit/closebrackets';
|
|
@@ -21,36 +21,27 @@ import 'codemirror/addon/fold/foldcode';
|
|
|
21
21
|
import 'codemirror/addon/fold/foldgutter';
|
|
22
22
|
import 'codemirror/addon/fold/brace-fold';
|
|
23
23
|
|
|
24
|
-
const completeAfter = (cm: Editor, predicate
|
|
25
|
-
const CodeMirror = cm.constructor;
|
|
24
|
+
const completeAfter = (cm: Editor, predicate?: () => boolean) => {
|
|
26
25
|
if (!predicate || predicate()) {
|
|
27
26
|
setTimeout(() => {
|
|
28
27
|
if (!cm.state.completionActive) {
|
|
29
|
-
// @ts-ignore
|
|
30
28
|
cm.showHint({ completeSingle: false });
|
|
31
29
|
}
|
|
32
30
|
}, 100);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
// @ts-ignore
|
|
36
33
|
return CodeMirror.Pass;
|
|
37
34
|
};
|
|
38
35
|
|
|
39
|
-
const completeIfAfterLt = (cm: Editor) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return completeAfter(cm, () => {
|
|
36
|
+
const completeIfAfterLt = (cm: Editor) =>
|
|
37
|
+
completeAfter(cm, () => {
|
|
43
38
|
const cur = cm.getCursor();
|
|
44
|
-
// @ts-ignore
|
|
45
39
|
// eslint-disable-next-line new-cap
|
|
46
40
|
return cm.getRange(CodeMirror.Pos(cur.line, cur.ch - 1), cur) === '<';
|
|
47
41
|
});
|
|
48
|
-
};
|
|
49
42
|
|
|
50
|
-
const completeIfInTag = (cm: Editor) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return completeAfter(cm, () => {
|
|
43
|
+
const completeIfInTag = (cm: Editor) =>
|
|
44
|
+
completeAfter(cm, () => {
|
|
54
45
|
const tok = cm.getTokenAt(cm.getCursor());
|
|
55
46
|
if (
|
|
56
47
|
tok.type === 'string' &&
|
|
@@ -59,11 +50,9 @@ const completeIfInTag = (cm: Editor) => {
|
|
|
59
50
|
) {
|
|
60
51
|
return false;
|
|
61
52
|
}
|
|
62
|
-
// @ts-ignore
|
|
63
53
|
const inner = CodeMirror.innerMode(cm.getMode(), tok.state).state;
|
|
64
54
|
return inner.tagName;
|
|
65
55
|
});
|
|
66
|
-
};
|
|
67
56
|
|
|
68
57
|
const validateCode = (editorInstance: Editor, code: string) => {
|
|
69
58
|
editorInstance.clearGutter('errorGutter');
|
|
@@ -228,7 +217,6 @@ export const CodeEditor = ({ code, onChange, previewCode, hints }: Props) => {
|
|
|
228
217
|
}, [highlightLineNumber]);
|
|
229
218
|
|
|
230
219
|
return (
|
|
231
|
-
// @ts-ignore
|
|
232
220
|
<ReactCodeMirror
|
|
233
221
|
editorDidMount={(editorInstance) => {
|
|
234
222
|
editorInstanceRef.current = editorInstance;
|
|
@@ -259,6 +247,7 @@ export const CodeEditor = ({ code, onChange, previewCode, hints }: Props) => {
|
|
|
259
247
|
autoCloseBrackets: true,
|
|
260
248
|
theme: 'neo',
|
|
261
249
|
gutters: ['errorGutter', 'CodeMirror-linenumbers', styles.foldGutter],
|
|
250
|
+
// @ts-expect-error
|
|
262
251
|
hintOptions: { schemaInfo: hints },
|
|
263
252
|
viewportMargin: 50,
|
|
264
253
|
lineNumbers: true,
|
|
@@ -275,7 +264,6 @@ export const CodeEditor = ({ code, onChange, previewCode, hints }: Props) => {
|
|
|
275
264
|
extraKeys: {
|
|
276
265
|
Tab: (cm) => {
|
|
277
266
|
if (cm.somethingSelected()) {
|
|
278
|
-
// @ts-ignore
|
|
279
267
|
cm.indentSelection('add');
|
|
280
268
|
} else {
|
|
281
269
|
const indent = cm.getOption('indentUnit') as number;
|