diff --git a/sdk/web/docs/README.md b/sdk/web/docs/README.md index 0307278..d3df61f 100644 --- a/sdk/web/docs/README.md +++ b/sdk/web/docs/README.md @@ -1,3 +1,3 @@ -radiant-sdk / [Exports](modules.md) +radiant-sdk / [Modules](modules.md) # Radiant Web SDK diff --git a/sdk/web/docs/classes/controller.RadiantController.md b/sdk/web/docs/classes/controller.RadiantController.md new file mode 100644 index 0000000..ba9ca5d --- /dev/null +++ b/sdk/web/docs/classes/controller.RadiantController.md @@ -0,0 +1,155 @@ +[radiant-sdk](../README.md) / [Modules](../modules.md) / [controller](../modules/controller.md) / RadiantController + +# Class: RadiantController + +[controller](../modules/controller.md).RadiantController + +## Table of contents + +### Constructors + +- [constructor](controller.RadiantController.md#constructor) + +### Properties + +- [\_controller](controller.RadiantController.md#_controller) + +### Methods + +- [activateTool](controller.RadiantController.md#activatetool) +- [setFillColor](controller.RadiantController.md#setfillcolor) +- [setStrokeColor](controller.RadiantController.md#setstrokecolor) +- [setTransform](controller.RadiantController.md#settransform) +- [createController](controller.RadiantController.md#createcontroller) + +## Constructors + +### constructor + +• **new RadiantController**(`controller`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `controller` | `RadiantAppController` | + +#### Defined in + +[controller/index.ts:6](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L6) + +## Properties + +### \_controller + +• **\_controller**: `RadiantAppController` + +#### Defined in + +[controller/index.ts:4](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L4) + +## Methods + +### activateTool + +▸ **activateTool**(`tool`): `void` + +Activates the provided tool. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `tool` | `string` | the tool to activate. | + +#### Returns + +`void` + +#### Defined in + +[controller/index.ts:19](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L19) + +___ + +### setFillColor + +▸ **setFillColor**(`nodeId`, `color`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodeId` | `number` | +| `color` | `number`[] | + +#### Returns + +`void` + +#### Defined in + +[controller/index.ts:35](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L35) + +___ + +### setStrokeColor + +▸ **setStrokeColor**(`nodeId`, `color`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodeId` | `number` | +| `color` | `number`[] | + +#### Returns + +`void` + +#### Defined in + +[controller/index.ts:44](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L44) + +___ + +### setTransform + +▸ **setTransform**(`nodeId`, `position`, `scale`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodeId` | `number` | +| `position` | `number`[] | +| `scale` | `number`[] | + +#### Returns + +`void` + +#### Defined in + +[controller/index.ts:25](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L25) + +___ + +### createController + +▸ `Static` **createController**(`f`): `Promise`<[`RadiantController`](controller.RadiantController.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `f` | `Function` | + +#### Returns + +`Promise`<[`RadiantController`](controller.RadiantController.md)\> + +#### Defined in + +[controller/index.ts:10](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/controller/index.ts#L10) diff --git a/sdk/web/docs/interfaces/context.RadiantState.md b/sdk/web/docs/interfaces/context.RadiantState.md new file mode 100644 index 0000000..814f83e --- /dev/null +++ b/sdk/web/docs/interfaces/context.RadiantState.md @@ -0,0 +1,32 @@ +[radiant-sdk](../README.md) / [Modules](../modules.md) / [context](../modules/context.md) / RadiantState + +# Interface: RadiantState + +[context](../modules/context.md).RadiantState + +## Table of contents + +### Properties + +- [controller](context.RadiantState.md#controller) +- [response](context.RadiantState.md#response) + +## Properties + +### controller + +• **controller**: ``null`` \| [`RadiantController`](../classes/controller.RadiantController.md) + +#### Defined in + +[context/index.tsx:6](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/context/index.tsx#L6) + +___ + +### response + +• **response**: `any` + +#### Defined in + +[context/index.tsx:7](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/context/index.tsx#L7) diff --git a/sdk/web/docs/modules.md b/sdk/web/docs/modules.md index 9f5c60e..14ca5fe 100644 --- a/sdk/web/docs/modules.md +++ b/sdk/web/docs/modules.md @@ -1,67 +1,10 @@ -[radiant-sdk](README.md) / Exports +[radiant-sdk](README.md) / Modules # radiant-sdk ## Table of contents -### Functions +### Modules -- [RadiantCanvas](modules.md#radiantcanvas) -- [RadiantProvider](modules.md#radiantprovider) -- [useCurrentController](modules.md#usecurrentcontroller) - -## Functions - -### RadiantCanvas - -▸ **RadiantCanvas**(`props`): ``null`` \| `ReactElement`<`any`, `string` \| `JSXElementConstructor`<`any`\>\> - -**NOTE**: Exotic components are not callable. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `props` | `RefAttributes`<`unknown`\> | - -#### Returns - -``null`` \| `ReactElement`<`any`, `string` \| `JSXElementConstructor`<`any`\>\> - -#### Defined in - -node_modules/@types/react/ts5.0/index.d.ts:396 - -___ - -### RadiantProvider - -▸ **RadiantProvider**(`«destructured»`): `Element` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `«destructured»` | `any` | - -#### Returns - -`Element` - -#### Defined in - -[sdk/web/src/context/index.tsx:15](https://github.com/radiant-labs/radiant/blob/e0d39ae/sdk/web/src/context/index.tsx#L15) - -___ - -### useCurrentController - -▸ **useCurrentController**(): `RadiantState` - -#### Returns - -`RadiantState` - -#### Defined in - -[sdk/web/src/context/index.tsx:55](https://github.com/radiant-labs/radiant/blob/e0d39ae/sdk/web/src/context/index.tsx#L55) +- [context](modules/context.md) +- [controller](modules/controller.md) diff --git a/sdk/web/docs/modules/context.md b/sdk/web/docs/modules/context.md new file mode 100644 index 0000000..43f012d --- /dev/null +++ b/sdk/web/docs/modules/context.md @@ -0,0 +1,48 @@ +[radiant-sdk](../README.md) / [Modules](../modules.md) / context + +# Module: context + +## Table of contents + +### Interfaces + +- [RadiantState](../interfaces/context.RadiantState.md) + +### Functions + +- [RadiantProvider](context.md#radiantprovider) +- [useCurrentController](context.md#usecurrentcontroller) + +## Functions + +### RadiantProvider + +▸ **RadiantProvider**(`«destructured»`): `Element` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | `any` | + +#### Returns + +`Element` + +#### Defined in + +[context/index.tsx:15](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/context/index.tsx#L15) + +___ + +### useCurrentController + +▸ **useCurrentController**(): [`RadiantState`](../interfaces/context.RadiantState.md) + +#### Returns + +[`RadiantState`](../interfaces/context.RadiantState.md) + +#### Defined in + +[context/index.tsx:55](https://github.com/radiant-labs/radiant/blob/11e8e99/sdk/web/src/context/index.tsx#L55) diff --git a/sdk/web/docs/modules/controller.md b/sdk/web/docs/modules/controller.md new file mode 100644 index 0000000..71bf71f --- /dev/null +++ b/sdk/web/docs/modules/controller.md @@ -0,0 +1,9 @@ +[radiant-sdk](../README.md) / [Modules](../modules.md) / controller + +# Module: controller + +## Table of contents + +### Classes + +- [RadiantController](../classes/controller.RadiantController.md) diff --git a/sdk/web/lib/cjs/components/RadiantCanvas/index.js b/sdk/web/lib/cjs/components/RadiantCanvas/index.js index 0c8796b..61c1e5a 100644 --- a/sdk/web/lib/cjs/components/RadiantCanvas/index.js +++ b/sdk/web/lib/cjs/components/RadiantCanvas/index.js @@ -1,8 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.RadiantCanvas = void 0; const tslib_1 = require("tslib"); const react_1 = tslib_1.__importStar(require("react")); -const RadiantCanvas = (0, react_1.forwardRef)(({}, ref) => { +exports.RadiantCanvas = (0, react_1.forwardRef)(({}, ref) => { return (react_1.default.createElement("div", { id: "canvas-container", style: { position: 'absolute', zIndex: 0, @@ -13,5 +14,4 @@ const RadiantCanvas = (0, react_1.forwardRef)(({}, ref) => { width: '100%', } })); }); -exports.default = RadiantCanvas; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/web/lib/cjs/components/RadiantCanvas/index.js.map b/sdk/web/lib/cjs/components/RadiantCanvas/index.js.map index 2ed7685..d1eb207 100644 --- a/sdk/web/lib/cjs/components/RadiantCanvas/index.js.map +++ b/sdk/web/lib/cjs/components/RadiantCanvas/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/RadiantCanvas/index.tsx"],"names":[],"mappings":";;;AAAA,uDAA0C;AAE1C,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IACzC,OAAO,CACH,uCACI,EAAE,EAAC,kBAAkB,EACrB,KAAK,EAAE;YACH,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,MAAM;YACd,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,MAAM;SAChB,GACH,CACL,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\n\nconst RadiantCanvas = forwardRef(({}, ref) => {\n return (\n \n );\n});\n\nexport default RadiantCanvas;"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/RadiantCanvas/index.tsx"],"names":[],"mappings":";;;;AAAA,uDAA0C;AAE7B,QAAA,aAAa,GAAG,IAAA,kBAAU,EAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IAChD,OAAO,CACH,uCACI,EAAE,EAAC,kBAAkB,EACrB,KAAK,EAAE;YACH,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,MAAM;YACd,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,MAAM;SAChB,GACH,CACL,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\n\nexport const RadiantCanvas = forwardRef(({}, ref) => {\n return (\n \n );\n});\n"]} \ No newline at end of file diff --git a/sdk/web/lib/cjs/context/index.js b/sdk/web/lib/cjs/context/index.js index d511989..0298db8 100644 --- a/sdk/web/lib/cjs/context/index.js +++ b/sdk/web/lib/cjs/context/index.js @@ -4,7 +4,7 @@ exports.useCurrentController = exports.RadiantProvider = void 0; const tslib_1 = require("tslib"); const react_1 = tslib_1.__importStar(require("react")); const radiant_wasm_1 = tslib_1.__importDefault(require("radiant-wasm")); -const controller_1 = tslib_1.__importDefault(require("../controller")); +const controller_1 = require("../controller"); const RadiantContext = (0, react_1.createContext)({ controller: null, response: {}, @@ -16,7 +16,7 @@ function RadiantProvider({ children }) { console.log("Initializing wasm"); try { yield (0, radiant_wasm_1.default)(); - let controller = yield controller_1.default.createController((message) => { + let controller = yield controller_1.RadiantController.createController((message) => { console.log(message); setResponse(message); }); diff --git a/sdk/web/lib/cjs/context/index.js.map b/sdk/web/lib/cjs/context/index.js.map index 09a4967..facd2bb 100644 --- a/sdk/web/lib/cjs/context/index.js.map +++ b/sdk/web/lib/cjs/context/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.tsx"],"names":[],"mappings":";;;;AAAA,uDAAsF;AACtF,wEAAgC;AAChC,oEAA2C;AAO3C,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAe;IAC/C,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,EAAE,QAAQ,EAAO;IACtC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAA2B,IAAI,CAAC,CAAC;IAC7E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAM,EAAE,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAG,GAAS,EAAE;QAC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"radiant-wasm\";\nimport RadiantController from \"controller\";\n\ninterface RadiantState {\n controller: RadiantController | null;\n response: any;\n}\n\nconst RadiantContext = createContext({\n controller: null,\n response: {},\n});\n\nfunction RadiantProvider({ children }: any) {\n const [controller, setController] = useState(null);\n const [response, setResponse] = useState({});\n\n const initWasm = async () => {\n console.log(\"Initializing wasm\");\n try {\n await init();\n let controller = await RadiantController.createController((message: any) => {\n console.log(message);\n setResponse(message);\n });\n setController(controller);\n } catch (error) {\n console.log(error);\n }\n };\n\n const [, setTimesRun] = useState(0);\n const counter = useRef(0);\n const effectCalled = useRef(false);\n\n useEffect(() => {\n if (effectCalled.current) return;\n counter.current += 1;\n setTimesRun(counter.current);\n effectCalled.current = true;\n initWasm();\n }, []);\n\n return (\n \n {children}\n \n )\n}\n\nconst useCurrentController = () => {\n return useContext(RadiantContext);\n}\n\nexport { RadiantProvider, useCurrentController };\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.tsx"],"names":[],"mappings":";;;;AAAA,uDAAsF;AACtF,wEAAgC;AAChC,2CAA+C;AAO/C,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAe;IAC/C,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,EAAE,QAAQ,EAAO;IACtC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAA2B,IAAI,CAAC,CAAC;IAC7E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAM,EAAE,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAG,GAAS,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI;YACA,MAAM,IAAA,sBAAI,GAAE,CAAC;YACb,IAAI,UAAU,GAAG,MAAM,8BAAiB,CAAC,gBAAgB,CAAC,CAAC,OAAY,EAAE,EAAE;gBACvE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACrB,WAAW,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YACH,aAAa,CAAC,UAAU,CAAC,CAAC;SAC7B;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SACtB;IACL,CAAC,CAAA,CAAC;IAEF,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,IAAA,cAAM,EAAS,CAAC,CAAC,CAAC;IAClC,MAAM,YAAY,GAAG,IAAA,cAAM,EAAU,KAAK,CAAC,CAAC;IAE5C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,YAAY,CAAC,OAAO;YAAE,OAAO;QACjC,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACrB,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7B,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,8BAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC5B,UAAU;YACV,QAAQ;SACX,IACI,QAAQ,CACa,CAC7B,CAAA;AACL,CAAC;AAMQ,0CAAe;AAJxB,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,OAAO,IAAA,kBAAU,EAAC,cAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAEyB,oDAAoB","sourcesContent":["import React, { useState, createContext, useEffect, useRef, useContext } from \"react\";\nimport init from \"radiant-wasm\";\nimport { RadiantController } from \"controller\";\n\nexport interface RadiantState {\n controller: RadiantController | null;\n response: any;\n}\n\nconst RadiantContext = createContext({\n controller: null,\n response: {},\n});\n\nfunction RadiantProvider({ children }: any) {\n const [controller, setController] = useState(null);\n const [response, setResponse] = useState({});\n\n const initWasm = async () => {\n console.log(\"Initializing wasm\");\n try {\n await init();\n let controller = await RadiantController.createController((message: any) => {\n console.log(message);\n setResponse(message);\n });\n setController(controller);\n } catch (error) {\n console.log(error);\n }\n };\n\n const [, setTimesRun] = useState(0);\n const counter = useRef(0);\n const effectCalled = useRef(false);\n\n useEffect(() => {\n if (effectCalled.current) return;\n counter.current += 1;\n setTimesRun(counter.current);\n effectCalled.current = true;\n initWasm();\n }, []);\n\n return (\n \n {children}\n \n )\n}\n\nconst useCurrentController = () => {\n return useContext(RadiantContext);\n}\n\nexport { RadiantProvider, useCurrentController };\n"]} \ No newline at end of file diff --git a/sdk/web/lib/cjs/controller/index.js b/sdk/web/lib/cjs/controller/index.js index 415ca12..6f659ed 100644 --- a/sdk/web/lib/cjs/controller/index.js +++ b/sdk/web/lib/cjs/controller/index.js @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.RadiantController = void 0; const tslib_1 = require("tslib"); const radiant_wasm_1 = require("radiant-wasm"); class RadiantController { @@ -11,6 +12,11 @@ class RadiantController { return new RadiantController(yield new radiant_wasm_1.RadiantAppController(f)); }); } + /** + * Activates the provided tool. + * + * @param tool the tool to activate. + */ activateTool(tool) { this._controller.handleMessage({ SelectTool: tool @@ -42,5 +48,5 @@ class RadiantController { }); } } -exports.default = RadiantController; +exports.RadiantController = RadiantController; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/web/lib/cjs/controller/index.js.map b/sdk/web/lib/cjs/controller/index.js.map index 45545f0..a517205 100644 --- a/sdk/web/lib/cjs/controller/index.js.map +++ b/sdk/web/lib/cjs/controller/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/index.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AAEpD,MAAqB,iBAAiB;IAGlC,YAAY,UAAgC;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,MAAM,CAAO,gBAAgB,CAAC,CAAW;;YACrC,OAAO,IAAI,iBAAiB,CAAC,MAAM,IAAI,mCAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC;KAAA;IAED,YAAY,CAAC,IAAY;QACrB,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,QAAkB,EAAE,KAAe;QAC5D,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,QAAQ;gBACR,KAAK;aACR;SACJ,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,KAAe;QACxC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,UAAU,EAAE,KAAK;aACpB;SACJ,CAAC,CAAC;IACP,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,KAAe;QAC1C,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,cAAc,EAAE;gBACZ,EAAE,EAAE,MAAM;gBACV,YAAY,EAAE,KAAK;aACtB;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AA5CD,oCA4CC","sourcesContent":["import { RadiantAppController } from \"radiant-wasm\";\n\nexport default class RadiantController {\n _controller: RadiantAppController;\n\n constructor(controller: RadiantAppController) {\n this._controller = controller;\n }\n\n static async createController(f: Function): Promise {\n return new RadiantController(await new RadiantAppController(f)); \n }\n\n activateTool(tool: string) {\n this._controller.handleMessage({\n SelectTool: tool\n });\n }\n\n setTransform(nodeId: number, position: number[], scale: number[]) {\n this._controller.handleMessage({\n SetTransform: {\n id: nodeId,\n position,\n scale,\n },\n });\n }\n\n setFillColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetFillColor: {\n id: nodeId,\n fill_color: color,\n },\n });\n }\n\n setStrokeColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetStrokeColor: {\n id: nodeId,\n stroke_color: color,\n },\n });\n }\n}"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/index.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AAEpD,MAAa,iBAAiB;IAG1B,YAAY,UAAgC;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,MAAM,CAAO,gBAAgB,CAAC,CAAW;;YACrC,OAAO,IAAI,iBAAiB,CAAC,MAAM,IAAI,mCAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC;KAAA;IAED;;;;OAIG;IACH,YAAY,CAAC,IAAY;QACrB,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,QAAkB,EAAE,KAAe;QAC5D,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,QAAQ;gBACR,KAAK;aACR;SACJ,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,KAAe;QACxC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,UAAU,EAAE,KAAK;aACpB;SACJ,CAAC,CAAC;IACP,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,KAAe;QAC1C,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,cAAc,EAAE;gBACZ,EAAE,EAAE,MAAM;gBACV,YAAY,EAAE,KAAK;aACtB;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AAjDD,8CAiDC","sourcesContent":["import { RadiantAppController } from \"radiant-wasm\";\n\nexport class RadiantController {\n _controller: RadiantAppController;\n\n constructor(controller: RadiantAppController) {\n this._controller = controller;\n }\n\n static async createController(f: Function): Promise {\n return new RadiantController(await new RadiantAppController(f)); \n }\n\n /**\n * Activates the provided tool.\n *\n * @param tool the tool to activate.\n */\n activateTool(tool: string) {\n this._controller.handleMessage({\n SelectTool: tool\n });\n }\n\n setTransform(nodeId: number, position: number[], scale: number[]) {\n this._controller.handleMessage({\n SetTransform: {\n id: nodeId,\n position,\n scale,\n },\n });\n }\n\n setFillColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetFillColor: {\n id: nodeId,\n fill_color: color,\n },\n });\n }\n\n setStrokeColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetStrokeColor: {\n id: nodeId,\n stroke_color: color,\n },\n });\n }\n}"]} \ No newline at end of file diff --git a/sdk/web/lib/cjs/index.js b/sdk/web/lib/cjs/index.js index 7238eca..ae4ee6f 100644 --- a/sdk/web/lib/cjs/index.js +++ b/sdk/web/lib/cjs/index.js @@ -1,9 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.RadiantCanvas = void 0; const tslib_1 = require("tslib"); tslib_1.__exportStar(require("./context"), exports); tslib_1.__exportStar(require("./controller"), exports); -const RadiantCanvas_1 = tslib_1.__importDefault(require("./components/RadiantCanvas")); -exports.RadiantCanvas = RadiantCanvas_1.default; +tslib_1.__exportStar(require("./components/RadiantCanvas"), exports); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/web/lib/cjs/index.js.map b/sdk/web/lib/cjs/index.js.map index 0336f11..4611aae 100644 --- a/sdk/web/lib/cjs/index.js.map +++ b/sdk/web/lib/cjs/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,oDAA0B;AAC1B,uDAA6B;AAE7B,uFAAuD;AAC9C,wBADF,uBAAa,CACE","sourcesContent":["export * from \"./context\";\nexport * from \"./controller\";\n\nimport RadiantCanvas from \"./components/RadiantCanvas\";\nexport { RadiantCanvas };\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,uDAA6B;AAE7B,qEAA2C","sourcesContent":["export * from \"./context\";\nexport * from \"./controller\";\n\nexport * from \"./components/RadiantCanvas\";\n"]} \ No newline at end of file diff --git a/sdk/web/lib/esm/components/RadiantCanvas/index.js b/sdk/web/lib/esm/components/RadiantCanvas/index.js index 9b882ad..fcd31e4 100644 --- a/sdk/web/lib/esm/components/RadiantCanvas/index.js +++ b/sdk/web/lib/esm/components/RadiantCanvas/index.js @@ -1,5 +1,5 @@ import React, { forwardRef } from "react"; -const RadiantCanvas = forwardRef(({}, ref) => { +export const RadiantCanvas = forwardRef(({}, ref) => { return (React.createElement("div", { id: "canvas-container", style: { position: 'absolute', zIndex: 0, @@ -10,5 +10,4 @@ const RadiantCanvas = forwardRef(({}, ref) => { width: '100%', } })); }); -export default RadiantCanvas; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/web/lib/esm/components/RadiantCanvas/index.js.map b/sdk/web/lib/esm/components/RadiantCanvas/index.js.map index b5efcc6..eb254fe 100644 --- a/sdk/web/lib/esm/components/RadiantCanvas/index.js.map +++ b/sdk/web/lib/esm/components/RadiantCanvas/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/RadiantCanvas/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IACzC,OAAO,CACH,6BACI,EAAE,EAAC,kBAAkB,EACrB,KAAK,EAAE;YACH,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,MAAM;YACd,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,MAAM;SAChB,GACH,CACL,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\n\nconst RadiantCanvas = forwardRef(({}, ref) => {\n return (\n \n );\n});\n\nexport default RadiantCanvas;"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/RadiantCanvas/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IAChD,OAAO,CACH,6BACI,EAAE,EAAC,kBAAkB,EACrB,KAAK,EAAE;YACH,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,MAAM;YACd,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,MAAM;SAChB,GACH,CACL,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\n\nexport const RadiantCanvas = forwardRef(({}, ref) => {\n return (\n \n );\n});\n"]} \ No newline at end of file diff --git a/sdk/web/lib/esm/context/index.js b/sdk/web/lib/esm/context/index.js index 8ad42fa..ac3bb9a 100644 --- a/sdk/web/lib/esm/context/index.js +++ b/sdk/web/lib/esm/context/index.js @@ -1,6 +1,6 @@ import React, { useState, createContext, useEffect, useRef, useContext } from "react"; import init from "radiant-wasm"; -import RadiantController from "../controller"; +import { RadiantController } from "../controller"; const RadiantContext = createContext({ controller: null, response: {}, diff --git a/sdk/web/lib/esm/context/index.js.map b/sdk/web/lib/esm/context/index.js.map index a6833f9..039d06c 100644 --- a/sdk/web/lib/esm/context/index.js.map +++ b/sdk/web/lib/esm/context/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index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;QACjC,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACrB,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7B,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC5B,UAAU;YACV,QAAQ;SACX,IACI,QAAQ,CACa,CAC7B,CAAA;AACL,CAAC;AAED,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import React, { useState, createContext, useEffect, useRef, useContext } from \"react\";\nimport init from \"radiant-wasm\";\nimport RadiantController from \"controller\";\n\ninterface RadiantState {\n controller: RadiantController | null;\n response: any;\n}\n\nconst RadiantContext = createContext({\n controller: null,\n response: {},\n});\n\nfunction RadiantProvider({ children }: any) {\n const [controller, setController] = useState(null);\n const [response, setResponse] = useState({});\n\n const initWasm = async () => {\n console.log(\"Initializing wasm\");\n try {\n await init();\n let controller = await RadiantController.createController((message: any) => {\n console.log(message);\n setResponse(message);\n });\n setController(controller);\n } catch (error) {\n console.log(error);\n }\n };\n\n const [, setTimesRun] = useState(0);\n const counter = useRef(0);\n const effectCalled = useRef(false);\n\n useEffect(() => {\n if (effectCalled.current) return;\n counter.current += 1;\n setTimesRun(counter.current);\n effectCalled.current = true;\n initWasm();\n }, []);\n\n return (\n \n {children}\n \n )\n}\n\nconst useCurrentController = () => {\n return useContext(RadiantContext);\n}\n\nexport { RadiantProvider, useCurrentController };\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,M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O,CAAC,CAAC;QAC7B,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC5B,UAAU;YACV,QAAQ;SACX,IACI,QAAQ,CACa,CAC7B,CAAA;AACL,CAAC;AAED,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import React, { useState, createContext, useEffect, useRef, useContext } from \"react\";\nimport init from \"radiant-wasm\";\nimport { RadiantController } from \"controller\";\n\nexport interface RadiantState {\n controller: RadiantController | null;\n response: any;\n}\n\nconst RadiantContext = createContext({\n controller: null,\n response: {},\n});\n\nfunction RadiantProvider({ children }: any) {\n const [controller, setController] = useState(null);\n const [response, setResponse] = useState({});\n\n const initWasm = async () => {\n console.log(\"Initializing wasm\");\n try {\n await init();\n let controller = await RadiantController.createController((message: any) => {\n console.log(message);\n setResponse(message);\n });\n setController(controller);\n } catch (error) {\n console.log(error);\n }\n };\n\n const [, setTimesRun] = useState(0);\n const counter = useRef(0);\n const effectCalled = useRef(false);\n\n useEffect(() => {\n if (effectCalled.current) return;\n counter.current += 1;\n setTimesRun(counter.current);\n effectCalled.current = true;\n initWasm();\n }, []);\n\n return (\n \n {children}\n \n )\n}\n\nconst useCurrentController = () => {\n return useContext(RadiantContext);\n}\n\nexport { RadiantProvider, useCurrentController };\n"]} \ No newline at end of file diff --git a/sdk/web/lib/esm/controller/index.js b/sdk/web/lib/esm/controller/index.js index f94262a..48a84b8 100644 --- a/sdk/web/lib/esm/controller/index.js +++ b/sdk/web/lib/esm/controller/index.js @@ -1,11 +1,16 @@ import { RadiantAppController } from "radiant-wasm"; -export default class RadiantController { +export class RadiantController { constructor(controller) { this._controller = controller; } static async createController(f) { return new RadiantController(await new RadiantAppController(f)); } + /** + * Activates the provided tool. + * + * @param tool the tool to activate. + */ activateTool(tool) { this._controller.handleMessage({ SelectTool: tool diff --git a/sdk/web/lib/esm/controller/index.js.map b/sdk/web/lib/esm/controller/index.js.map index a48da51..0e758ab 100644 --- a/sdk/web/lib/esm/controller/index.js.map +++ b/sdk/web/lib/esm/controller/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAGlC,YAAY,UAAgC;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAW;QACrC,OAAO,IAAI,iBAAiB,CAAC,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,YAAY,CAAC,IAAY;QACrB,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,QAAkB,EAAE,KAAe;QAC5D,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,QAAQ;gBACR,KAAK;aACR;SACJ,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,KAAe;QACxC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,UAAU,EAAE,KAAK;aACpB;SACJ,CAAC,CAAC;IACP,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,KAAe;QAC1C,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,cAAc,EAAE;gBACZ,EAAE,EAAE,MAAM;gBACV,YAAY,EAAE,KAAK;aACtB;SACJ,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { RadiantAppController } from \"radiant-wasm\";\n\nexport default class RadiantController {\n _controller: RadiantAppController;\n\n constructor(controller: RadiantAppController) {\n this._controller = controller;\n }\n\n static async createController(f: Function): Promise {\n return new RadiantController(await new RadiantAppController(f)); \n }\n\n activateTool(tool: string) {\n this._controller.handleMessage({\n SelectTool: tool\n });\n }\n\n setTransform(nodeId: number, position: number[], scale: number[]) {\n this._controller.handleMessage({\n SetTransform: {\n id: nodeId,\n position,\n scale,\n },\n });\n }\n\n setFillColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetFillColor: {\n id: nodeId,\n fill_color: color,\n },\n });\n }\n\n setStrokeColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetStrokeColor: {\n id: nodeId,\n stroke_color: color,\n },\n });\n }\n}"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,OAAO,iBAAiB;IAG1B,YAAY,UAAgC;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAW;QACrC,OAAO,IAAI,iBAAiB,CAAC,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,IAAY;QACrB,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,QAAkB,EAAE,KAAe;QAC5D,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,QAAQ;gBACR,KAAK;aACR;SACJ,CAAC,CAAC;IACP,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,KAAe;QACxC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,YAAY,EAAE;gBACV,EAAE,EAAE,MAAM;gBACV,UAAU,EAAE,KAAK;aACpB;SACJ,CAAC,CAAC;IACP,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,KAAe;QAC1C,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;YAC3B,cAAc,EAAE;gBACZ,EAAE,EAAE,MAAM;gBACV,YAAY,EAAE,KAAK;aACtB;SACJ,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { RadiantAppController } from \"radiant-wasm\";\n\nexport class RadiantController {\n _controller: RadiantAppController;\n\n constructor(controller: RadiantAppController) {\n this._controller = controller;\n }\n\n static async createController(f: Function): Promise {\n return new RadiantController(await new RadiantAppController(f)); \n }\n\n /**\n * Activates the provided tool.\n *\n * @param tool the tool to activate.\n */\n activateTool(tool: string) {\n this._controller.handleMessage({\n SelectTool: tool\n });\n }\n\n setTransform(nodeId: number, position: number[], scale: number[]) {\n this._controller.handleMessage({\n SetTransform: {\n id: nodeId,\n position,\n scale,\n },\n });\n }\n\n setFillColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetFillColor: {\n id: nodeId,\n fill_color: color,\n },\n });\n }\n\n setStrokeColor(nodeId: number, color: number[]) {\n this._controller.handleMessage({\n SetStrokeColor: {\n id: nodeId,\n stroke_color: color,\n },\n });\n }\n}"]} \ No newline at end of file diff --git a/sdk/web/lib/esm/index.js b/sdk/web/lib/esm/index.js index 58585a5..3a22a17 100644 --- a/sdk/web/lib/esm/index.js +++ b/sdk/web/lib/esm/index.js @@ -1,5 +1,4 @@ export * from "./context"; export * from "./controller"; -import RadiantCanvas from "./components/RadiantCanvas"; -export { RadiantCanvas }; +export * from "./components/RadiantCanvas"; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/web/lib/esm/index.js.map b/sdk/web/lib/esm/index.js.map index 00b6401..2a2cb99 100644 --- a/sdk/web/lib/esm/index.js.map +++ b/sdk/web/lib/esm/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["export * from \"./context\";\nexport * from \"./controller\";\n\nimport RadiantCanvas from \"./components/RadiantCanvas\";\nexport { RadiantCanvas };\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,cAAc,4BAA4B,CAAC","sourcesContent":["export * from \"./context\";\nexport * from \"./controller\";\n\nexport * from \"./components/RadiantCanvas\";\n"]} \ No newline at end of file diff --git a/sdk/web/lib/types/components/RadiantCanvas/index.d.ts b/sdk/web/lib/types/components/RadiantCanvas/index.d.ts index f4ebd76..4fd260d 100644 --- a/sdk/web/lib/types/components/RadiantCanvas/index.d.ts +++ b/sdk/web/lib/types/components/RadiantCanvas/index.d.ts @@ -1,4 +1,3 @@ import React from "react"; -declare const RadiantCanvas: React.ForwardRefExoticComponent>; -export default RadiantCanvas; +export declare const RadiantCanvas: React.ForwardRefExoticComponent>; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/sdk/web/lib/types/components/RadiantCanvas/index.d.ts.map b/sdk/web/lib/types/components/RadiantCanvas/index.d.ts.map index c295818..02864bc 100644 --- a/sdk/web/lib/types/components/RadiantCanvas/index.d.ts.map +++ b/sdk/web/lib/types/components/RadiantCanvas/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/RadiantCanvas/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,QAAA,MAAM,aAAa,+DAejB,CAAC;AAEH,eAAe,aAAa,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/RadiantCanvas/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,eAAO,MAAM,aAAa,+DAexB,CAAC"} \ No newline at end of file diff --git a/sdk/web/lib/types/context/index.d.ts b/sdk/web/lib/types/context/index.d.ts index 0a9c1bf..7eab713 100644 --- a/sdk/web/lib/types/context/index.d.ts +++ b/sdk/web/lib/types/context/index.d.ts @@ -1,6 +1,6 @@ import React from "react"; -import RadiantController from "../controller"; -interface RadiantState { +import { RadiantController } from "../controller"; +export interface RadiantState { controller: RadiantController | null; response: any; } diff --git a/sdk/web/lib/types/context/index.d.ts.map b/sdk/web/lib/types/context/index.d.ts.map index 99b5278..6d4f215 100644 --- a/sdk/web/lib/types/context/index.d.ts.map +++ b/sdk/web/lib/types/context/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAEtF,OAAO,iBAAiB,MAAM,YAAY,CAAC;AAE3C,UAAU,YAAY;IAClB,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC;CACjB;AAOD,iBAAS,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,qBAsCzC;AAED,QAAA,MAAM,oBAAoB,oBAEzB,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC;CACjB;AAOD,iBAAS,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,qBAsCzC;AAED,QAAA,MAAM,oBAAoB,oBAEzB,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC"} \ No newline at end of file diff --git a/sdk/web/lib/types/controller/index.d.ts b/sdk/web/lib/types/controller/index.d.ts index a3f54a6..b6c69f5 100644 --- a/sdk/web/lib/types/controller/index.d.ts +++ b/sdk/web/lib/types/controller/index.d.ts @@ -1,8 +1,13 @@ import { RadiantAppController } from "radiant-wasm"; -export default class RadiantController { +export declare class RadiantController { _controller: RadiantAppController; constructor(controller: RadiantAppController); static createController(f: Function): Promise; + /** + * Activates the provided tool. + * + * @param tool the tool to activate. + */ activateTool(tool: string): void; setTransform(nodeId: number, position: number[], scale: number[]): void; setFillColor(nodeId: number, color: number[]): void; diff --git a/sdk/web/lib/types/controller/index.d.ts.map b/sdk/web/lib/types/controller/index.d.ts.map index b8f1155..5000d5e 100644 --- a/sdk/web/lib/types/controller/index.d.ts.map +++ b/sdk/web/lib/types/controller/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAClC,WAAW,EAAE,oBAAoB,CAAC;gBAEtB,UAAU,EAAE,oBAAoB;WAI/B,gBAAgB,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAItE,YAAY,CAAC,IAAI,EAAE,MAAM;IAMzB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;IAUhE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAS5C,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;CAQjD"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,qBAAa,iBAAiB;IAC1B,WAAW,EAAE,oBAAoB,CAAC;gBAEtB,UAAU,EAAE,oBAAoB;WAI/B,gBAAgB,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAItE;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM;IAMzB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;IAUhE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAS5C,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;CAQjD"} \ No newline at end of file diff --git a/sdk/web/lib/types/index.d.ts b/sdk/web/lib/types/index.d.ts index dc21ce0..df5bdb4 100644 --- a/sdk/web/lib/types/index.d.ts +++ b/sdk/web/lib/types/index.d.ts @@ -1,5 +1,4 @@ export * from "./context"; export * from "./controller"; -import RadiantCanvas from "./components/RadiantCanvas"; -export { RadiantCanvas }; +export * from "./components/RadiantCanvas"; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/sdk/web/lib/types/index.d.ts.map b/sdk/web/lib/types/index.d.ts.map index d6403a2..e753b5e 100644 --- a/sdk/web/lib/types/index.d.ts.map +++ b/sdk/web/lib/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,cAAc,4BAA4B,CAAC"} \ No newline at end of file diff --git a/sdk/web/package.json b/sdk/web/package.json index ea8e05d..0ac3c1f 100644 --- a/sdk/web/package.json +++ b/sdk/web/package.json @@ -22,7 +22,7 @@ "token:generate": "ts-node examples/generate-token.ts", "test": "jest", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "docs": "rm -rf docs && typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts" + "docs": "rm -rf docs && typedoc --plugin typedoc-plugin-markdown --out docs src/**/*.ts src/**/*.tsx" }, "keywords": [], "author": "", diff --git a/sdk/web/src/components/RadiantCanvas/index.tsx b/sdk/web/src/components/RadiantCanvas/index.tsx index 90e516c..ead50df 100644 --- a/sdk/web/src/components/RadiantCanvas/index.tsx +++ b/sdk/web/src/components/RadiantCanvas/index.tsx @@ -1,6 +1,6 @@ import React, { forwardRef } from "react"; -const RadiantCanvas = forwardRef(({}, ref) => { +export const RadiantCanvas = forwardRef(({}, ref) => { return (
{ /> ); }); - -export default RadiantCanvas; \ No newline at end of file diff --git a/sdk/web/src/context/index.tsx b/sdk/web/src/context/index.tsx index d33de77..2fd8b4b 100644 --- a/sdk/web/src/context/index.tsx +++ b/sdk/web/src/context/index.tsx @@ -1,8 +1,8 @@ import React, { useState, createContext, useEffect, useRef, useContext } from "react"; import init from "radiant-wasm"; -import RadiantController from "controller"; +import { RadiantController } from "controller"; -interface RadiantState { +export interface RadiantState { controller: RadiantController | null; response: any; } diff --git a/sdk/web/src/controller/index.ts b/sdk/web/src/controller/index.ts index d11cdef..dbca2b2 100644 --- a/sdk/web/src/controller/index.ts +++ b/sdk/web/src/controller/index.ts @@ -1,6 +1,6 @@ import { RadiantAppController } from "radiant-wasm"; -export default class RadiantController { +export class RadiantController { _controller: RadiantAppController; constructor(controller: RadiantAppController) { diff --git a/sdk/web/src/index.ts b/sdk/web/src/index.ts index 3b641fe..3159a0a 100644 --- a/sdk/web/src/index.ts +++ b/sdk/web/src/index.ts @@ -1,5 +1,4 @@ export * from "./context"; export * from "./controller"; -import RadiantCanvas from "./components/RadiantCanvas"; -export { RadiantCanvas }; +export * from "./components/RadiantCanvas";