@forge/react 10.2.0 → 10.3.0-next.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/CHANGELOG.md +12 -0
- package/out/__test__/hostConfig.test.js +6 -1
- package/out/__test__/reconciler.test.js +3 -2
- package/out/__test__/reconcilerTestRenderer.js +2 -0
- package/out/__test__/testUtils.js +6 -0
- package/out/components/index.d.ts +8 -0
- package/out/components/index.d.ts.map +1 -1
- package/out/components/index.js +8 -0
- package/out/components/uikit2-components.d.ts +8 -1
- package/out/components/uikit2-components.d.ts.map +1 -1
- package/out/components/uikit2-components.js +10 -1
- package/out/hooks/__test__/confluenceEntity.test.js +3 -1
- package/out/hooks/__test__/jiraEntity.test.js +2 -1
- package/out/hooks/__test__/mockPropertyHook.d.ts +3 -0
- package/out/hooks/__test__/mockPropertyHook.d.ts.map +1 -1
- package/out/hooks/__test__/mockPropertyHook.js +5 -0
- package/out/hooks/__test__/useConfig.test.js +4 -1
- package/out/hooks/__test__/useEntityProperty.test.js +3 -3
- package/out/hooks/__test__/useProductContext.test.js +3 -1
- package/out/hooks/confluenceEntity.d.ts +4 -0
- package/out/hooks/confluenceEntity.d.ts.map +1 -1
- package/out/hooks/confluenceEntity.js +9 -0
- package/out/hooks/jiraEntity.d.ts +4 -0
- package/out/hooks/jiraEntity.d.ts.map +1 -1
- package/out/hooks/jiraEntity.js +9 -0
- package/out/hooks/useContentProperty.d.ts +9 -0
- package/out/hooks/useContentProperty.d.ts.map +1 -1
- package/out/hooks/useContentProperty.js +9 -0
- package/out/hooks/useEntityProperty.js +7 -1
- package/out/hooks/useForm.js +23 -1
- package/out/hooks/useIssueProperty.d.ts +9 -0
- package/out/hooks/useIssueProperty.d.ts.map +1 -1
- package/out/hooks/useIssueProperty.js +10 -1
- package/out/hooks/useSpaceProperty.d.ts +9 -0
- package/out/hooks/useSpaceProperty.d.ts.map +1 -1
- package/out/hooks/useSpaceProperty.js +9 -0
- package/out/hooks/utils/apiRequestUtils.js +2 -0
- package/out/hooks/utils/valueUtils.js +2 -0
- package/out/reconciler.d.ts +13 -0
- package/out/reconciler.d.ts.map +1 -1
- package/out/reconciler.js +35 -0
- package/out/types/effect.d.ts +3 -0
- package/out/types/effect.d.ts.map +1 -1
- package/out/types/extension.d.ts +4 -0
- package/out/types/extension.d.ts.map +1 -1
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
package/out/hooks/useForm.js
CHANGED
|
@@ -6,18 +6,32 @@ const react_1 = require("react");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
8
8
|
function useForm(props = {}) {
|
|
9
|
+
// Generate an id to prevent clashes with other forms on the page
|
|
9
10
|
const id = (0, react_1.useId)();
|
|
10
11
|
const getFieldId = (fieldName) => {
|
|
11
12
|
return `form-${id}-${fieldName}`;
|
|
12
13
|
};
|
|
13
|
-
const { register, formState,
|
|
14
|
+
const { register, formState,
|
|
15
|
+
// watch, disabling for the time being as can be expensive for performance
|
|
16
|
+
handleSubmit, setValue, getValues, trigger, clearErrors
|
|
17
|
+
// Only allow for defaultValues in props for the timebeing
|
|
18
|
+
} = (0, react_hook_form_1.useForm)({
|
|
14
19
|
defaultValues: props.defaultValues,
|
|
15
20
|
mode: 'onBlur',
|
|
16
21
|
reValidateMode: 'onChange'
|
|
17
22
|
});
|
|
18
23
|
const defaultValues = props?.defaultValues;
|
|
19
24
|
const forgeFormRegister = (fieldName, options) => {
|
|
25
|
+
/**
|
|
26
|
+
* Removed:
|
|
27
|
+
* - ref cannot be serialised and passed through the run time
|
|
28
|
+
* - removed required to stop the default browser validation pop up
|
|
29
|
+
* - UI Kit 2 components take `isDisabled` instead of `disabled`
|
|
30
|
+
* - `onChange` is modified to handle our controlled components as refs cannot be used
|
|
31
|
+
*/
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
33
|
const { onChange, ref, required, disabled, onBlur, ...rest } = register(fieldName, {
|
|
34
|
+
// Only permitting the below as they've been tested and confirmed working
|
|
21
35
|
required: options?.required,
|
|
22
36
|
disabled: options?.disabled,
|
|
23
37
|
maxLength: options?.maxLength,
|
|
@@ -29,6 +43,8 @@ function useForm(props = {}) {
|
|
|
29
43
|
});
|
|
30
44
|
const additionalProps = {};
|
|
31
45
|
if (defaultValues) {
|
|
46
|
+
// only checkbox and toggle have boolean vals.
|
|
47
|
+
// Typically this is handled by the ref obj but we need to manage the default values ourselves here
|
|
32
48
|
if (typeof (0, get_1.default)(defaultValues, fieldName) === 'boolean') {
|
|
33
49
|
additionalProps.defaultChecked = (0, get_1.default)(defaultValues, fieldName);
|
|
34
50
|
}
|
|
@@ -39,11 +55,14 @@ function useForm(props = {}) {
|
|
|
39
55
|
const isError = !!(0, get_1.default)(formState, `errors["${fieldName}"]`);
|
|
40
56
|
const onChangeOptions = {
|
|
41
57
|
shouldDirty: true,
|
|
58
|
+
// revalidate on change if the field has been touched(blurred) or if the form has been submitted previously
|
|
42
59
|
shouldValidate: formState.submitCount > 0 || !!(0, get_1.default)(formState, `touchedFields["${fieldName}"]`)
|
|
43
60
|
};
|
|
44
61
|
return {
|
|
45
62
|
...rest,
|
|
46
63
|
onChange: (event) => {
|
|
64
|
+
// onChange is modified here to handle our controlled components as refs cannot be used
|
|
65
|
+
// handles Checkbox and Toggle
|
|
47
66
|
if (event?.target?.type === 'checkbox') {
|
|
48
67
|
return Promise.resolve(setValue(fieldName, event.target.checked, onChangeOptions));
|
|
49
68
|
}
|
|
@@ -51,9 +70,12 @@ function useForm(props = {}) {
|
|
|
51
70
|
return Promise.resolve(setValue(fieldName, event.target.value, onChangeOptions));
|
|
52
71
|
}
|
|
53
72
|
else {
|
|
73
|
+
// handles onChange arguments where the value is passed instead of an event object
|
|
54
74
|
return Promise.resolve(setValue(fieldName, event, onChangeOptions));
|
|
55
75
|
}
|
|
56
76
|
},
|
|
77
|
+
// The onBlur event from `register` is unintentionally setting the value to `undefined` when the field is blurred.
|
|
78
|
+
// Replacing the onBlur event here to prevent this behaviour.
|
|
57
79
|
onBlur: () => {
|
|
58
80
|
return Promise.resolve(trigger(fieldName));
|
|
59
81
|
},
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function manages the properties of a Jira issue where the app is installed
|
|
3
|
+
* @param propertyKey Name (key) of the property
|
|
4
|
+
* @param initValue Default value if it did not exist previously
|
|
5
|
+
* @returns An array with 3 items:
|
|
6
|
+
* 1. Current value of the property.
|
|
7
|
+
* 2. A function to update the property value (with another value or an updater function). If a <retryCount> is given and an initial update fails, it automatically tries to update for another <retryCount> times (default 0).
|
|
8
|
+
* 3. A function to delete the property.
|
|
9
|
+
*/
|
|
1
10
|
export declare const useIssueProperty: <PropValue>(propertyKey: string, initValue: PropValue) => readonly [any, (valueUpdate: any, retryCount?: number) => Promise<void>, () => Promise<void>];
|
|
2
11
|
//# sourceMappingURL=useIssueProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIssueProperty.d.ts","sourceRoot":"","sources":["../../src/hooks/useIssueProperty.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIssueProperty.d.ts","sourceRoot":"","sources":["../../src/hooks/useIssueProperty.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,2BAA4B,MAAM,wHAW9D,CAAC"}
|
|
@@ -4,12 +4,21 @@ exports.useIssueProperty = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const jiraEntity_1 = require("./jiraEntity");
|
|
6
6
|
const useEntityProperty_1 = require("./useEntityProperty");
|
|
7
|
+
/**
|
|
8
|
+
* This function manages the properties of a Jira issue where the app is installed
|
|
9
|
+
* @param propertyKey Name (key) of the property
|
|
10
|
+
* @param initValue Default value if it did not exist previously
|
|
11
|
+
* @returns An array with 3 items:
|
|
12
|
+
* 1. Current value of the property.
|
|
13
|
+
* 2. A function to update the property value (with another value or an updater function). If a <retryCount> is given and an initial update fails, it automatically tries to update for another <retryCount> times (default 0).
|
|
14
|
+
* 3. A function to delete the property.
|
|
15
|
+
*/
|
|
7
16
|
const useIssueProperty = (propertyKey, initValue) => {
|
|
8
17
|
const entityManager = (0, react_1.useMemo)(() => (0, jiraEntity_1.jiraIssuePropsManager)({
|
|
9
18
|
entityType: 'Issue',
|
|
10
19
|
origPropertyKey: propertyKey,
|
|
11
20
|
initValue
|
|
12
21
|
}), []);
|
|
13
|
-
return (0, useEntityProperty_1.useEntityProperty)({ entityManager, defaultRetryCount: 0 });
|
|
22
|
+
return (0, useEntityProperty_1.useEntityProperty)({ entityManager, defaultRetryCount: 0 }); // no update retries needed for issue properties
|
|
14
23
|
};
|
|
15
24
|
exports.useIssueProperty = useIssueProperty;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function manages the space properties of a Confluence space where the app is installed.
|
|
3
|
+
* @param propertyKey Name (key) of the property
|
|
4
|
+
* @param initValue Default value if it did not exist previously
|
|
5
|
+
* @returns An array with 3 items:
|
|
6
|
+
* 1. Current value of the property.
|
|
7
|
+
* 2. A function to update the property value (with another value or an updater function). If an initial update fails, it automatically tries to update for another <retryCount> times (default 2).
|
|
8
|
+
* 3. A function to delete the property.
|
|
9
|
+
*/
|
|
1
10
|
export declare const useSpaceProperty: <PropValue>(propertyKey: string, initValue: PropValue) => readonly [PropValue | undefined, (valueUpdate: import("./types/entityProps").ValueUpdate<PropValue>, retryCount?: number) => Promise<void>, () => Promise<void>];
|
|
2
11
|
//# sourceMappingURL=useSpaceProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpaceProperty.d.ts","sourceRoot":"","sources":["../../src/hooks/useSpaceProperty.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSpaceProperty.d.ts","sourceRoot":"","sources":["../../src/hooks/useSpaceProperty.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,2BAA4B,MAAM,2LAW9D,CAAC"}
|
|
@@ -4,6 +4,15 @@ exports.useSpaceProperty = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const confluenceEntity_1 = require("./confluenceEntity");
|
|
6
6
|
const useEntityProperty_1 = require("./useEntityProperty");
|
|
7
|
+
/**
|
|
8
|
+
* This function manages the space properties of a Confluence space where the app is installed.
|
|
9
|
+
* @param propertyKey Name (key) of the property
|
|
10
|
+
* @param initValue Default value if it did not exist previously
|
|
11
|
+
* @returns An array with 3 items:
|
|
12
|
+
* 1. Current value of the property.
|
|
13
|
+
* 2. A function to update the property value (with another value or an updater function). If an initial update fails, it automatically tries to update for another <retryCount> times (default 2).
|
|
14
|
+
* 3. A function to delete the property.
|
|
15
|
+
*/
|
|
7
16
|
const useSpaceProperty = (propertyKey, initValue) => {
|
|
8
17
|
const entityManager = (0, react_1.useMemo)(() => (0, confluenceEntity_1.confluenceEntity)({
|
|
9
18
|
entityType: 'Space',
|
|
@@ -7,6 +7,7 @@ exports.FETCH_HEADERS = {
|
|
|
7
7
|
Accept: 'application/json',
|
|
8
8
|
'Content-Type': 'application/json'
|
|
9
9
|
};
|
|
10
|
+
// loads productContext and passes data to support API calls for GET, UPDATE, DELETE operations
|
|
10
11
|
const withContext = ({ originalOperation, apiEndpoints, entityType, origPropertyKey }) => async (...args) => {
|
|
11
12
|
const context = await bridge_1.view.getContext();
|
|
12
13
|
const propertyKey = entityType === 'Content' ? `forge-${context.localId}-${origPropertyKey}` : `forge-${origPropertyKey}`;
|
|
@@ -43,6 +44,7 @@ const getJSONData = async (response) => {
|
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
exports.getJSONData = getJSONData;
|
|
47
|
+
// checks if a response from the API is successful and throw error if not
|
|
46
48
|
const assertSuccessfulResponse = ({ entityType, propertyKey, operation, response }) => {
|
|
47
49
|
if (!response.ok) {
|
|
48
50
|
throw new types_1.EntityPropertyRequestFailedError({ entityType, propertyKey, operation, status: response.status });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveValue = void 0;
|
|
4
|
+
// copied over from @forge/ui
|
|
5
|
+
// helper function that resolves a value from a promise or returns the original value
|
|
4
6
|
const resolveValue = async (defaultValue) => {
|
|
5
7
|
const value = defaultValue instanceof Function ? defaultValue() : defaultValue;
|
|
6
8
|
return await value;
|
package/out/reconciler.d.ts
CHANGED
|
@@ -21,6 +21,19 @@ declare type CreateElement = (args: {
|
|
|
21
21
|
export declare const createElement: CreateElement;
|
|
22
22
|
export declare const appendChild: (parent: ForgeDoc, child: ForgeDoc) => void;
|
|
23
23
|
export declare const insertBefore: (parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Performs a shallow comparison of the old and new props for a component, but doesn't
|
|
26
|
+
* compare the "children" prop. This works because the custom reconciler extracts the
|
|
27
|
+
* "children" prop from the ForgeDoc and includes it separately.
|
|
28
|
+
*
|
|
29
|
+
* This function is used in prepareUpdate to determine whether or not to increment the
|
|
30
|
+
* reconciliationCount for the component - the reconciliationCount should only be incremented
|
|
31
|
+
* if the props have changed.
|
|
32
|
+
*
|
|
33
|
+
* @param newProps The new props being passed to the component
|
|
34
|
+
* @param oldProps The old props the component previously had
|
|
35
|
+
* @returns True if the props are equal and false otherwise
|
|
36
|
+
*/
|
|
24
37
|
export declare const nonChildPropsAreEqual: (oldProps: InstanceProps, newProps: InstanceProps) => boolean;
|
|
25
38
|
declare type HostConfigType = string;
|
|
26
39
|
declare type InstanceProps = Record<string, any>;
|
package/out/reconciler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../src/reconciler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAA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AC,CAAC;AAEpB,eAAO,MAAM,UAAU,EAAE,UAAU,CACjC,cAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,aAAa,EACb,SAAS,CA+IV,CAAC;AAIF,eAAO,MAAM,eAAe;sBACR,YAAY;yBAiBT,YAAY;CAiBlC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/out/reconciler.js
CHANGED
|
@@ -5,8 +5,12 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_reconciler_1 = tslib_1.__importDefault(require("react-reconciler"));
|
|
6
6
|
const constants_1 = require("react-reconciler/constants");
|
|
7
7
|
const uuid_1 = require("uuid");
|
|
8
|
+
// Only taking the first 5 characters of the uuid to keep the id shorter in the DOM to readability.
|
|
9
|
+
// The chances of clashing with 5 characters is still 1 in 1 million.
|
|
8
10
|
const idPropsPrefixAppUUID = (0, uuid_1.v4)().slice(0, 5);
|
|
9
11
|
const idPropsPrefix = `forge-app-${idPropsPrefixAppUUID}`;
|
|
12
|
+
// Checks the props of the component to see if it has an id prop. If so prefixes the value with the idPropsPrefix\
|
|
13
|
+
// This is done to avoid id conflicts with components in host product and other forge apps in the same page
|
|
10
14
|
const newPropsWithIdPrefix = (props) => {
|
|
11
15
|
const idProps = ['id', 'labelFor', 'inputId'];
|
|
12
16
|
const newProps = idProps.reduce((acc, idProp) => {
|
|
@@ -30,10 +34,13 @@ const attachFunctionPropId = (props) => {
|
|
|
30
34
|
return props;
|
|
31
35
|
};
|
|
32
36
|
const callBridge = function (cmd, data) {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
33
39
|
self?.__bridge?.callBridge(cmd, data);
|
|
34
40
|
};
|
|
35
41
|
exports.callBridge = callBridge;
|
|
36
42
|
const createElement = ({ type, props = {}, forgeReactMajorVersion }) => {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
44
|
const { children, ...restProps } = props;
|
|
38
45
|
const newProps = newPropsWithIdPrefix(attachFunctionPropId(restProps));
|
|
39
46
|
const element = {
|
|
@@ -65,6 +72,19 @@ const insertBefore = (parent, child, beforeChild) => {
|
|
|
65
72
|
parent.children.splice(insertIndex, 0, child);
|
|
66
73
|
};
|
|
67
74
|
exports.insertBefore = insertBefore;
|
|
75
|
+
/**
|
|
76
|
+
* Performs a shallow comparison of the old and new props for a component, but doesn't
|
|
77
|
+
* compare the "children" prop. This works because the custom reconciler extracts the
|
|
78
|
+
* "children" prop from the ForgeDoc and includes it separately.
|
|
79
|
+
*
|
|
80
|
+
* This function is used in prepareUpdate to determine whether or not to increment the
|
|
81
|
+
* reconciliationCount for the component - the reconciliationCount should only be incremented
|
|
82
|
+
* if the props have changed.
|
|
83
|
+
*
|
|
84
|
+
* @param newProps The new props being passed to the component
|
|
85
|
+
* @param oldProps The old props the component previously had
|
|
86
|
+
* @returns True if the props are equal and false otherwise
|
|
87
|
+
*/
|
|
68
88
|
const nonChildPropsAreEqual = (oldProps, newProps) => {
|
|
69
89
|
const newPropsKey = Object.keys(newProps).filter((key) => key !== 'children');
|
|
70
90
|
const oldPropsKey = Object.keys(oldProps).filter((key) => key !== 'children');
|
|
@@ -127,6 +147,7 @@ exports.hostConfig = {
|
|
|
127
147
|
prepareForCommit() {
|
|
128
148
|
return null;
|
|
129
149
|
},
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
130
151
|
preparePortalMount() { },
|
|
131
152
|
scheduleTimeout(fn, delay) {
|
|
132
153
|
return setTimeout(fn, delay);
|
|
@@ -148,17 +169,26 @@ exports.hostConfig = {
|
|
|
148
169
|
const removeIndex = container.children.indexOf(child);
|
|
149
170
|
container.children.splice(removeIndex, 1);
|
|
150
171
|
},
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
151
173
|
resetTextContent() { },
|
|
152
174
|
commitTextUpdate(textInstance, oldText, newText) {
|
|
153
175
|
textInstance.props.text = newText;
|
|
154
176
|
},
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
155
178
|
commitMount() { },
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
156
180
|
commitUpdate() { },
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
157
182
|
hideInstance() { },
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
158
184
|
hideTextInstance() { },
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
159
186
|
unhideInstance() { },
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
160
188
|
unhideTextInstance() { },
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
161
190
|
clearContainer() { },
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
162
192
|
detachDeletedInstance() { },
|
|
163
193
|
getCurrentEventPriority() {
|
|
164
194
|
return constants_1.DefaultEventPriority;
|
|
@@ -166,8 +196,11 @@ exports.hostConfig = {
|
|
|
166
196
|
getInstanceFromNode() {
|
|
167
197
|
return null;
|
|
168
198
|
},
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
169
200
|
beforeActiveInstanceBlur() { },
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
170
202
|
afterActiveInstanceBlur() { },
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
171
204
|
prepareScopeUpdate() { },
|
|
172
205
|
getInstanceFromScope() {
|
|
173
206
|
return null;
|
|
@@ -178,6 +211,7 @@ exports.ForgeReconciler = {
|
|
|
178
211
|
render: (element) => {
|
|
179
212
|
const rootElement = (0, exports.createElement)({ type: 'Root', props: {}, forgeReactMajorVersion: 10 });
|
|
180
213
|
const container = reconciler.createContainer(rootElement, 0, null, false, null, 'root', (err) => {
|
|
214
|
+
// eslint-disable-next-line no-console
|
|
181
215
|
console.log(err);
|
|
182
216
|
}, null);
|
|
183
217
|
reconciler.updateContainer(element, container, null, null);
|
|
@@ -185,6 +219,7 @@ exports.ForgeReconciler = {
|
|
|
185
219
|
addConfig: (element) => {
|
|
186
220
|
const macroConfigElement = (0, exports.createElement)({ type: 'MacroConfig', props: {}, forgeReactMajorVersion: 10 });
|
|
187
221
|
const container = reconciler.createContainer(macroConfigElement, 0, null, false, null, 'macroConfig', (err) => {
|
|
222
|
+
// eslint-disable-next-line no-console
|
|
188
223
|
console.log(err);
|
|
189
224
|
}, null);
|
|
190
225
|
reconciler.updateContainer(element, container, null, null);
|
package/out/types/effect.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/types/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,oBAAY,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAEjD,oBAAY,gBAAgB,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAEpD,MAAM,WAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/types/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,oBAAY,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAEjD,oBAAY,gBA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AAC;AACxC,oBAAY,MAAM,GAAG,aAAa,GAAG,YAAY,CAAC;AAElD,eAAO,MAAM,aAAa,WAAY,MAAM,0BAE3C,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,MAAM,2BAE5C,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,MAAM,2BAE5C,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,MAAM,2BAE5C,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,aAAa,CAIvE"}
|
package/out/types/extension.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/types/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE;QACV,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/types/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE;QACV,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE;QACR;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,GAAG,cAAc,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/react",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0-next.1",
|
|
4
4
|
"description": "Forge React reconciler",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"pack": "./build/bundle-types.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@atlaskit/forge-react-types": "^0.22.2",
|
|
16
17
|
"@forge/bridge": "^3.4.0",
|
|
17
|
-
"@atlaskit/forge-react-types": "^0.5.2",
|
|
18
18
|
"@types/react-reconciler": "^0.28.8",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
20
|
"react": "^18.2.0",
|