@ray-js/code-sandbox 0.0.7-beta-7 → 0.0.7-beta-10

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.
@@ -5,6 +5,7 @@ export interface DecoderProps {
5
5
  loadingText?: string;
6
6
  grammarErrText?: string;
7
7
  refreshButtonText?: string;
8
+ channel?: string;
8
9
  }
9
10
  export declare const Decoder: React.FC<DecoderProps>;
10
11
  export default Decoder;
@@ -8,13 +8,15 @@ export const Decoder = _ref => {
8
8
  children,
9
9
  loadingText,
10
10
  grammarErrText,
11
- refreshButtonText
11
+ refreshButtonText,
12
+ channel
12
13
  } = _ref;
13
14
  return /*#__PURE__*/React.createElement(CatchError, {
14
15
  loadingText: loadingText,
15
16
  grammarErrText: grammarErrText,
16
17
  refreshButtonText: refreshButtonText
17
18
  }, /*#__PURE__*/React.createElement(Channel, {
19
+ channel: channel,
18
20
  binddata: event => {
19
21
  const code = Bases64.decode(event.detail);
20
22
  onCodeChange(code);
@@ -2,6 +2,7 @@
2
2
  import React from 'react';
3
3
 
4
4
  export interface ChannelProps {
5
+ channel?: string;
5
6
  binddata(event: { detail: string });
6
7
  }
7
8
 
@@ -1,5 +1,8 @@
1
1
  Component({
2
2
  properties: {
3
- instanceId: String
3
+ channel: {
4
+ type: String,
5
+ value: 'sandbox-jsrun'
6
+ }
4
7
  }
5
8
  });
@@ -1,7 +1,8 @@
1
1
  module.exports = {
2
2
  init(newVal, oldVal, ownerInstance) {
3
- ownerInstance.eventChannel.on('sandbox-jsrun', event => {
4
- console.log(`[sandbox] trigger `, event);
3
+ const eventName = newVal || 'sandbox-jsrun';
4
+ ownerInstance.eventChannel.on(eventName, event => {
5
+ console.log(`[sandbox] trigger `, eventName, event);
5
6
  ownerInstance.triggerEvent('data', event);
6
7
  });
7
8
  },
@@ -1,6 +1,6 @@
1
1
  <sjs src="./index.sjs" module="computed"></sjs>
2
2
 
3
3
  <view
4
- id="{{instanceId}}"
5
- change:id="{{computed.init}}"
4
+ channel="{{channel}}"
5
+ change:channel="{{computed.init}}"
6
6
  ></view>
@@ -63,7 +63,7 @@ export const CodeSandbox = _ref => {
63
63
  },
64
64
  show: show,
65
65
  title: title,
66
- fileName: "main.less",
66
+ fileName: `${txpCode || 'main'}.less`,
67
67
  code: cssCode,
68
68
  onChange: newCode => {
69
69
  postStyleCode(newCode);
@@ -73,6 +73,7 @@ export const CodeSandbox = _ref => {
73
73
  isZhLanguage: isZhLanguage,
74
74
  baseUri: baseUri,
75
75
  txpCode: txpCode,
76
+ fileName: `${txpCode || 'main'}.tsx`,
76
77
  height: "calc(90vh - 103px + 48px)",
77
78
  style: {
78
79
  width: '50%'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/code-sandbox",
3
- "version": "0.0.7-beta-7",
3
+ "version": "0.0.7-beta-10",
4
4
  "description": "小程序 CodeSandbox 容器",
5
5
  "main": "lib/index",
6
6
  "files": [