@scalar/workspace-store 0.19.0 → 0.21.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.
- package/CHANGELOG.md +44 -0
- package/README.md +2 -2
- package/dist/client.d.ts +40 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +58 -23
- package/dist/client.js.map +2 -2
- package/dist/events/bus.d.ts +13 -1
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +46 -10
- package/dist/events/bus.js.map +3 -3
- package/dist/events/definitions/auth.d.ts +20 -2
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/events/definitions/cookie.d.ts +20 -0
- package/dist/events/definitions/cookie.d.ts.map +1 -0
- package/dist/events/definitions/cookie.js +1 -0
- package/dist/events/definitions/cookie.js.map +7 -0
- package/dist/events/definitions/document.d.ts +11 -1
- package/dist/events/definitions/document.d.ts.map +1 -1
- package/dist/events/definitions/index.d.ts +4 -2
- package/dist/events/definitions/index.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +0 -13
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/server.d.ts +20 -28
- package/dist/events/definitions/server.d.ts.map +1 -1
- package/dist/events/definitions/tabs.d.ts +40 -0
- package/dist/events/definitions/tabs.d.ts.map +1 -0
- package/dist/events/definitions/tabs.js +1 -0
- package/dist/events/definitions/tabs.js.map +7 -0
- package/dist/events/definitions/ui.d.ts +39 -4
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/events/definitions/workspace.d.ts +18 -0
- package/dist/events/definitions/workspace.d.ts.map +1 -0
- package/dist/events/definitions/workspace.js +1 -0
- package/dist/events/definitions/workspace.js.map +7 -0
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js.map +2 -2
- package/dist/helpers/generate-unique-value.d.ts +19 -6
- package/dist/helpers/generate-unique-value.d.ts.map +1 -1
- package/dist/helpers/generate-unique-value.js +12 -7
- package/dist/helpers/generate-unique-value.js.map +2 -2
- package/dist/helpers/unpack-proxy.d.ts +14 -1
- package/dist/helpers/unpack-proxy.d.ts.map +1 -1
- package/dist/helpers/unpack-proxy.js +51 -1
- package/dist/helpers/unpack-proxy.js.map +3 -3
- package/dist/mutators/auth.d.ts +10 -73
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +47 -111
- package/dist/mutators/auth.js.map +2 -2
- package/dist/mutators/cookie.d.ts +21 -13
- package/dist/mutators/cookie.d.ts.map +1 -1
- package/dist/mutators/cookie.js +34 -26
- package/dist/mutators/cookie.js.map +3 -3
- package/dist/mutators/document.d.ts +13 -0
- package/dist/mutators/document.d.ts.map +1 -0
- package/dist/mutators/document.js +25 -0
- package/dist/mutators/document.js.map +7 -0
- package/dist/mutators/index.d.ts +13 -20
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +49 -8
- package/dist/mutators/index.js.map +3 -3
- package/dist/mutators/operation.d.ts +23 -101
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +132 -96
- package/dist/mutators/operation.js.map +2 -2
- package/dist/mutators/server.d.ts +43 -8
- package/dist/mutators/server.d.ts.map +1 -1
- package/dist/mutators/server.js +113 -20
- package/dist/mutators/server.js.map +2 -2
- package/dist/mutators/workspace.d.ts +6 -0
- package/dist/mutators/workspace.d.ts.map +1 -0
- package/dist/mutators/workspace.js +24 -0
- package/dist/mutators/workspace.js.map +7 -0
- package/dist/navigation/get-navigation-options.d.ts.map +1 -1
- package/dist/navigation/get-navigation-options.js +4 -4
- package/dist/navigation/get-navigation-options.js.map +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts +2 -0
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-document.js +18 -3
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/navigation/helpers/traverse-examples.js +2 -2
- package/dist/navigation/helpers/traverse-examples.js.map +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts +6 -3
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +4 -9
- package/dist/navigation/helpers/traverse-paths.js.map +2 -2
- package/dist/navigation/helpers/traverse-tags.d.ts +0 -1
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +57 -49
- package/dist/navigation/helpers/traverse-tags.js.map +3 -3
- package/dist/persistence/index.d.ts +6 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +18 -0
- package/dist/persistence/index.js.map +2 -2
- package/dist/persistence/indexdb.d.ts +1 -0
- package/dist/persistence/indexdb.d.ts.map +1 -1
- package/dist/persistence/indexdb.js +6 -1
- package/dist/persistence/indexdb.js.map +2 -2
- package/dist/plugins/client/persistence.d.ts +2 -1
- package/dist/plugins/client/persistence.d.ts.map +1 -1
- package/dist/plugins/client/persistence.js +17 -9
- package/dist/plugins/client/persistence.js.map +2 -2
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts +1 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +2 -2
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts +13 -0
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.js +8 -0
- package/dist/schemas/extensions/document/x-scalar-set-operation-security.js.map +7 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts +36 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts.map +1 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.js +15 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.js.map +7 -0
- package/dist/schemas/extensions/general/x-scalar-order.d.ts +12 -0
- package/dist/schemas/extensions/general/x-scalar-order.d.ts.map +1 -0
- package/dist/schemas/extensions/general/x-scalar-order.js +8 -0
- package/dist/schemas/extensions/general/x-scalar-order.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts +7 -7
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-scalar-selected-security.js +2 -2
- package/dist/schemas/extensions/security/x-scalar-selected-security.js.map +2 -2
- package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts +8 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts.map +1 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.js +8 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +7 -0
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts +10 -5
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -1
- package/dist/schemas/extensions/tag/x-tag-groups.js +15 -10
- package/dist/schemas/extensions/tag/x-tag-groups.js.map +2 -2
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts +18 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts.map +1 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +8 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +7 -0
- package/dist/schemas/extensions.d.ts +1 -1
- package/dist/schemas/extensions.js +1 -1
- package/dist/schemas/extensions.js.map +2 -2
- package/dist/schemas/inmemory-workspace.d.ts +59 -33
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/navigation.d.ts +9 -1
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +3 -1
- package/dist/schemas/navigation.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +29 -16
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +29 -16
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +2 -0
- package/dist/schemas/reference-config/settings.js.map +2 -2
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +992 -549
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +14 -6
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +3 -7
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +1 -5
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/tag.d.ts +4 -1
- package/dist/schemas/v3.1/strict/tag.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/tag.js +3 -1
- package/dist/schemas/v3.1/strict/tag.js.map +2 -2
- package/dist/schemas/v3.1/strict/type-guards.d.ts +6 -0
- package/dist/schemas/v3.1/strict/type-guards.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/type-guards.js +4 -0
- package/dist/schemas/v3.1/strict/type-guards.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +29 -16
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +30 -17
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +233 -130
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +8 -6
- package/dist/schemas/workspace.js.map +2 -2
- package/dist/server.d.ts +1 -1
- package/dist/workspace-plugin.d.ts +3 -0
- package/dist/workspace-plugin.d.ts.map +1 -1
- package/package.json +8 -7
- package/dist/helpers/debounce.d.ts +0 -28
- package/dist/helpers/debounce.d.ts.map +0 -1
- package/dist/helpers/debounce.js +0 -31
- package/dist/helpers/debounce.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts +0 -13
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts.map +0 -1
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js +0 -9
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js.map +0 -7
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts +0 -32
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts.map +0 -1
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js +0 -13
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js.map +0 -7
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { EnvironmentEvents } from '../../events/definitions/environment.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TabEvents } from '../../events/definitions/tabs.js';
|
|
3
|
+
import type { WorkspaceEvents } from '../../events/definitions/workspace.js';
|
|
3
4
|
import type { AnalyticsEvents } from './analytics.js';
|
|
4
5
|
import type { AuthEvents } from './auth.js';
|
|
6
|
+
import type { CookieEvents } from './cookie.js';
|
|
5
7
|
import type { DocumentEvents } from './document.js';
|
|
6
8
|
import type { MetaEvents } from './meta.js';
|
|
7
9
|
import type { OperationEvents } from './operation.js';
|
|
8
10
|
import type { ServerEvents } from './server.js';
|
|
9
11
|
import type { UIEvents } from './ui.js';
|
|
10
|
-
export type ApiReferenceEvents
|
|
12
|
+
export type ApiReferenceEvents = AuthEvents & AnalyticsEvents & CookieEvents & WorkspaceEvents & DocumentEvents & EnvironmentEvents & MetaEvents & OperationEvents & ServerEvents & TabEvents & UIEvents;
|
|
11
13
|
export type { CollectionType } from './common.js';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEpC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GACzC,eAAe,GACf,YAAY,GACZ,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,eAAe,GACf,YAAY,GACZ,SAAS,GACT,QAAQ,CAAA;AAEV,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -2,16 +2,6 @@ import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
|
2
2
|
import type { OperationExampleMeta, OperationMeta } from '../../mutators/index.js';
|
|
3
3
|
/** Event definitions for the operation */
|
|
4
4
|
export type OperationEvents = {
|
|
5
|
-
/**
|
|
6
|
-
* Update the selected example for the operation
|
|
7
|
-
*/
|
|
8
|
-
'update:selected-example': {
|
|
9
|
-
/** The name of the example to select */
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
/** ------------------------------------------------------------------------------------------------
|
|
13
|
-
* Operation Actions
|
|
14
|
-
* ------------------------------------------------------------------------------------------------ */
|
|
15
5
|
/**
|
|
16
6
|
* Fires when the user requests to send the operation (e.g., triggers "Try It" or sends a request).
|
|
17
7
|
* Contains the OperationExampleMeta, which identifies the operation and the example variant to use.
|
|
@@ -19,9 +9,6 @@ export type OperationEvents = {
|
|
|
19
9
|
'operation:send:request': {
|
|
20
10
|
meta: OperationExampleMeta;
|
|
21
11
|
};
|
|
22
|
-
/** ------------------------------------------------------------------------------------------------
|
|
23
|
-
* Operation Draft Mutators
|
|
24
|
-
* ------------------------------------------------------------------------------------------------ */
|
|
25
12
|
/**
|
|
26
13
|
* Update the summary for the operation.
|
|
27
14
|
* Triggers when the user edits the summary/description for an endpoint.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAErE,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAErE,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG;IAK5B;;;OAGG;IACH,wBAAwB,EAAE;QACxB,IAAI,EAAE,oBAAoB,CAAA;KAC3B,CAAA;IAMD;;;;OAIG;IACH,0BAA0B,EAAE;QAC1B,uDAAuD;QACvD,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAA;SAChB,CAAA;QACD,kFAAkF;QAClF,IAAI,EAAE,aAAa,CAAA;KACpB,CAAA;IAED;;;OAGG;IACH,yBAAyB,EAAE;QACzB,OAAO,EAAE;YACP,u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MAAM,CAAA;QACb,2CAA2C;QAC3C,WAAW,EAAE,MAAM,CAAA;QACnB,wFAAwF;QACxF,IAAI,EAAE,oBAAoB,CAAA;KAC3B,CAAA;CACF,CAAA"}
|
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import type { ServerObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
2
|
-
export type ServerEvents
|
|
2
|
+
export type ServerEvents = {
|
|
3
3
|
/**
|
|
4
|
-
* Add a new server to the document
|
|
4
|
+
* Add a new blank server to the document
|
|
5
5
|
*/
|
|
6
|
-
'add:server':
|
|
7
|
-
/** The new server payload to add */
|
|
8
|
-
server: ServerObject;
|
|
9
|
-
};
|
|
6
|
+
'server:add:server': undefined;
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
8
|
+
* Update the entire server object
|
|
12
9
|
*/
|
|
13
|
-
'
|
|
14
|
-
/** The
|
|
15
|
-
|
|
10
|
+
'server:update:server': {
|
|
11
|
+
/** The index of the server to update */
|
|
12
|
+
index: number;
|
|
13
|
+
/** The new server payload to update */
|
|
14
|
+
server: Partial<ServerObject>;
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Delete a server from the document
|
|
19
18
|
*/
|
|
20
|
-
'
|
|
21
|
-
/** The
|
|
22
|
-
|
|
19
|
+
'server:delete:server': {
|
|
20
|
+
/** The index of the server to delete */
|
|
21
|
+
index: number;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
24
|
* Update the selected server variable for the document
|
|
26
25
|
*/
|
|
27
|
-
'update:
|
|
26
|
+
'server:update:variables': {
|
|
27
|
+
/** The index of the server to update */
|
|
28
|
+
index: number;
|
|
28
29
|
/** The key of the variable to update */
|
|
29
30
|
key: string;
|
|
30
31
|
/** The new value of the variable */
|
|
31
32
|
value: string;
|
|
32
33
|
};
|
|
33
34
|
/**
|
|
34
|
-
* Update the selected server
|
|
35
|
+
* Update the selected server for the document
|
|
35
36
|
*/
|
|
36
|
-
'update:selected
|
|
37
|
-
/** The
|
|
38
|
-
|
|
39
|
-
/** The new value of the property */
|
|
40
|
-
value: ServerObject[T];
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Replace all servers in the document
|
|
44
|
-
*/
|
|
45
|
-
'update:all-servers': {
|
|
46
|
-
/** The new servers to replace the current servers with */
|
|
47
|
-
servers: ServerObject[];
|
|
37
|
+
'server:update:selected': {
|
|
38
|
+
/** The URL of the server to select */
|
|
39
|
+
url: string;
|
|
48
40
|
};
|
|
49
41
|
};
|
|
50
42
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,MAAM,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAA;IAC9B;;OAEG;IACH,sBAAsB,EAAE;QACtB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;QACb,uCAAuC;QACvC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;KAC9B,CAAA;IACD;;OAEG;IACH,sBAAsB,EAAE;QACtB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD;;OAEG;IACH,yBAAyB,EAAE;QACzB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;QACb,wCAAwC;QACxC,GAAG,EAAE,MAAM,CAAA;QACX,oCAAoC;QACpC,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD;;OAEG;IACH,wBAAwB,EAAE;QACxB,sCAAsC;QACtC,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;CACF,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Event definitions to control the tabs */
|
|
2
|
+
export type TabEvents = {
|
|
3
|
+
/**
|
|
4
|
+
* Add a new tab
|
|
5
|
+
*/
|
|
6
|
+
'tabs:add:tab': {
|
|
7
|
+
event: KeyboardEvent;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Closes the current tab
|
|
11
|
+
*/
|
|
12
|
+
'tabs:close:tab': {
|
|
13
|
+
event: KeyboardEvent;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Navigates to the previous tab
|
|
17
|
+
*/
|
|
18
|
+
'tabs:navigate:previous': {
|
|
19
|
+
event: KeyboardEvent;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Navigates to the next tab
|
|
23
|
+
*/
|
|
24
|
+
'tabs:navigate:next': {
|
|
25
|
+
event: KeyboardEvent;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Jumps to a specific tab, we can grab the number from the keyboard event
|
|
29
|
+
*/
|
|
30
|
+
'tabs:focus:tab': {
|
|
31
|
+
event: KeyboardEvent;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Focuses the last tab
|
|
35
|
+
*/
|
|
36
|
+
'tabs:focus:tab-last': {
|
|
37
|
+
event: KeyboardEvent;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/tabs.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,cAAc,EAAE;QACd,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,gBAAgB,EAAE;QAChB,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,wBAAwB,EAAE;QACxB,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,oBAAoB,EAAE;QACpB,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,gBAAgB,EAAE;QAChB,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,qBAAqB,EAAE;QACrB,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -4,23 +4,58 @@ export type UIEvents = {
|
|
|
4
4
|
/**
|
|
5
5
|
* Download the document from the store
|
|
6
6
|
*/
|
|
7
|
-
'download:document': {
|
|
7
|
+
'ui:download:document': {
|
|
8
8
|
/** Format to download the document in */
|
|
9
9
|
format: 'json' | 'yaml' | 'direct';
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Focus the address bar
|
|
13
|
+
*/
|
|
14
|
+
'ui:focus:address-bar': {
|
|
15
|
+
event: KeyboardEvent;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Focus the send button
|
|
19
|
+
*/
|
|
20
|
+
'ui:focus:send-button': {
|
|
21
|
+
event: KeyboardEvent;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Focus the search
|
|
25
|
+
*/
|
|
26
|
+
'ui:focus:search': {
|
|
27
|
+
event: KeyboardEvent;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Toggle the sidebar
|
|
31
|
+
*/
|
|
32
|
+
'ui:toggle:sidebar': {
|
|
33
|
+
event: KeyboardEvent;
|
|
34
|
+
};
|
|
11
35
|
/**
|
|
12
36
|
* Open the Api Client modal to a specific operation
|
|
13
37
|
*/
|
|
14
|
-
'open:client': {
|
|
38
|
+
'ui:open:client-modal': {
|
|
15
39
|
/** The HTTP method of the operation to load */
|
|
16
40
|
method: HttpMethod;
|
|
17
41
|
/** The path of the operation to load */
|
|
18
42
|
path: string;
|
|
43
|
+
/** The example name to load */
|
|
44
|
+
exampleName?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Close the client modal
|
|
48
|
+
*/
|
|
49
|
+
'ui:close:client-modal': {
|
|
50
|
+
event: KeyboardEvent;
|
|
19
51
|
};
|
|
20
52
|
/**
|
|
21
|
-
* Open
|
|
53
|
+
* Open the command palette
|
|
22
54
|
*/
|
|
23
|
-
'open:command-palette':
|
|
55
|
+
'ui:open:command-palette': {
|
|
56
|
+
action?: 'import' | 'addServer' | 'addCollection' | 'addTag' | 'addExample' | 'addOperation' | undefined;
|
|
57
|
+
event?: KeyboardEvent;
|
|
58
|
+
} | undefined;
|
|
24
59
|
/** Set a navigation item's (such as a tag or operation) expanded state */
|
|
25
60
|
'toggle:nav-item': {
|
|
26
61
|
/** The name of the nav item to toggle */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,0CAA0C;AAC1C,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,0CAA0C;AAC1C,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,sBAAsB,EAAE;QACtB,yCAAyC;QACzC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;KACnC,CAAA;IACD;;OAEG;IACH,sBAAsB,EAAE;QACtB,KAAK,EAAE,aAAa,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,sBAAsB,EAAE;QACtB,KAA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d,CAAA;CACF,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ThemeId } from '@scalar/themes';
|
|
2
|
+
import type { ColorMode } from '../../schemas/workspace.js';
|
|
3
|
+
/** Event definitions for the openapi document */
|
|
4
|
+
export type WorkspaceEvents = {
|
|
5
|
+
/**
|
|
6
|
+
* Update the active proxy
|
|
7
|
+
*/
|
|
8
|
+
'workspace:update:active-proxy': string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Update the color mode of the workspace
|
|
11
|
+
*/
|
|
12
|
+
'workspace:update:color-mode': ColorMode;
|
|
13
|
+
/**
|
|
14
|
+
* Update the theme of the workspace
|
|
15
|
+
*/
|
|
16
|
+
'workspace:update:theme': ThemeId;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9C;;OAEG;IACH,6BAA6B,EAAE,SAAS,CAAA;IACxC;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAA;CAClC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=workspace.js.map
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type WorkspaceEventBus, createWorkspaceEventBus } from './bus.js';
|
|
2
|
-
export type { CollectionType } from './definitions/index.js';
|
|
2
|
+
export type { ApiReferenceEvents, CollectionType } from './definitions/index.js';
|
|
3
3
|
export { onCustomEvent } from './listeners.js';
|
|
4
|
-
export {
|
|
4
|
+
export { emitCustomEvent } from './old-definitions.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/events/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/events/index.ts"],
|
|
4
|
-
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport type { CollectionType } from './definitions'\nexport { onCustomEvent } from './listeners'\nexport {
|
|
5
|
-
"mappings": "AACA,SAAiC,+BAA+B;AAEhE,SAAS,qBAAqB;AAC9B,
|
|
4
|
+
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport type { ApiReferenceEvents, CollectionType } from './definitions'\nexport { onCustomEvent } from './listeners'\nexport { emitCustomEvent } from './old-definitions'\n"],
|
|
5
|
+
"mappings": "AACA,SAAiC,+BAA+B;AAEhE,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,16 +25,29 @@ export declare function generateUniqueValue({ defaultValue,
|
|
|
25
25
|
/** Check function to verify the uniqueness of the value */
|
|
26
26
|
validation,
|
|
27
27
|
/** Transformation function to transform the default value (such as into a slug) */
|
|
28
|
-
transformation,
|
|
28
|
+
transformation,
|
|
29
|
+
/** The maximum number of attempts to create a unique value by incrementing. */
|
|
30
|
+
maxRetries, }: {
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
32
|
+
* The original value to base the unique generation upon.
|
|
33
|
+
* Example: "workspace", which may end up producing "workspace 2", "workspace 3", etc.
|
|
31
34
|
*/
|
|
32
35
|
defaultValue: string;
|
|
33
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Validation function that determines if a generated value is unique.
|
|
38
|
+
* Should return true if the value is unique; false if not.
|
|
39
|
+
* Can be asynchronous or synchronous.
|
|
40
|
+
*/
|
|
34
41
|
validation: (value: string) => Promise<boolean> | boolean;
|
|
35
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Optional function to transform the default value before attempting uniqueness.
|
|
44
|
+
* Example: Transform "Workspace A" into "workspace-a" to follow a slug schema.
|
|
45
|
+
*/
|
|
36
46
|
transformation?: (value: string) => string;
|
|
37
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The maximum number of attempts to create a unique value by incrementing.
|
|
49
|
+
* For example, if set to 5: "foo", "foo 1", "foo 2", "foo 3", "foo 4" will be attempted.
|
|
50
|
+
*/
|
|
38
51
|
maxRetries: number;
|
|
39
|
-
}): string | undefined
|
|
52
|
+
}): Promise<string | undefined>;
|
|
40
53
|
//# sourceMappingURL=generate-unique-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-unique-value.d.ts","sourceRoot":"","sources":["../../src/helpers/generate-unique-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,
|
|
1
|
+
{"version":3,"file":"generate-unique-value.d.ts","sourceRoot":"","sources":["../../src/helpers/generate-unique-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,YAAY;AACZ,2DAA2D;AAC3D,UAAU;AACV,mFAAmF;AACnF,cAAc;AACd,+EAA+E;AAC/E,UAAc,GACf,EAAE;IACD;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;;;OAIG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;IAEzD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAE1C;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,+BAaA"}
|
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
function generateUniqueValue({
|
|
1
|
+
async function generateUniqueValue({
|
|
2
2
|
defaultValue,
|
|
3
3
|
/** Check function to verify the uniqueness of the value */
|
|
4
4
|
validation,
|
|
5
5
|
/** Transformation function to transform the default value (such as into a slug) */
|
|
6
6
|
transformation,
|
|
7
|
+
/** The maximum number of attempts to create a unique value by incrementing. */
|
|
7
8
|
maxRetries = 5
|
|
8
9
|
}) {
|
|
9
10
|
const transformed = transformation?.(defaultValue) ?? defaultValue;
|
|
10
|
-
if (validation(transformed)) {
|
|
11
|
+
if (await validation(transformed)) {
|
|
11
12
|
return transformed;
|
|
12
13
|
}
|
|
13
14
|
return incrementValue({
|
|
14
15
|
value: [transformed, 1],
|
|
15
16
|
validation,
|
|
16
|
-
maxRetries
|
|
17
|
+
maxRetries,
|
|
18
|
+
transformation
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
|
-
function incrementValue({
|
|
21
|
+
async function incrementValue({
|
|
20
22
|
value,
|
|
21
23
|
validation,
|
|
22
24
|
maxRetries,
|
|
23
|
-
attempts = 0
|
|
25
|
+
attempts = 0,
|
|
26
|
+
transformation
|
|
24
27
|
}) {
|
|
25
28
|
if (attempts >= maxRetries) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
const incremented = value.join(" ");
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const transformed = transformation?.(incremented) ?? incremented;
|
|
33
|
+
if (await validation(transformed)) {
|
|
34
|
+
return transformed;
|
|
31
35
|
}
|
|
32
36
|
return incrementValue({
|
|
33
37
|
value: [value[0], value[1] + 1],
|
|
34
38
|
validation,
|
|
35
39
|
maxRetries,
|
|
40
|
+
transformation,
|
|
36
41
|
attempts: attempts + 1
|
|
37
42
|
});
|
|
38
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/generate-unique-value.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Generates a unique value based on a given default value and a validation function.\n *\n * The process works as follows:\n * 1. Optionally transform (e.g., slugify) the default value using a transformation function.\n * 2. Check if this value is unique by executing the provided validation function.\n * 3. If not unique, repeatedly append an incrementing integer (e.g., \"my-name 1\", \"my-name 2\", ...) and re-check uniqueness,\n * up to a maximum number of attempts (maxRetries).\n * 4. Returns the first unique value found or undefined if a unique value cannot be generated within the maximum retries.\n *\n * Example:\n * ```ts\n * // Existing names in use\n * const existing = new Set(['foo', 'foo 1', 'foo 2']);\n * const uniqueName = generateUniqueValue({\n * defaultValue: 'foo',\n * validation: (value) => !existing.has(value),\n * // transformation is optional, e.g. (val) => val.toLowerCase().replace(/[^\\w]+/g, '-'),\n * maxRetries: 10,\n * });\n * // uniqueName === 'foo 3'\n * ```\n */\nexport function generateUniqueValue({\n defaultValue,\n /** Check function to verify the uniqueness of the value */\n validation,\n /** Transformation function to transform the default value (such as into a slug) */\n transformation,\n maxRetries = 5,\n}: {\n /**\n *
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Generates a unique value based on a given default value and a validation function.\n *\n * The process works as follows:\n * 1. Optionally transform (e.g., slugify) the default value using a transformation function.\n * 2. Check if this value is unique by executing the provided validation function.\n * 3. If not unique, repeatedly append an incrementing integer (e.g., \"my-name 1\", \"my-name 2\", ...) and re-check uniqueness,\n * up to a maximum number of attempts (maxRetries).\n * 4. Returns the first unique value found or undefined if a unique value cannot be generated within the maximum retries.\n *\n * Example:\n * ```ts\n * // Existing names in use\n * const existing = new Set(['foo', 'foo 1', 'foo 2']);\n * const uniqueName = generateUniqueValue({\n * defaultValue: 'foo',\n * validation: (value) => !existing.has(value),\n * // transformation is optional, e.g. (val) => val.toLowerCase().replace(/[^\\w]+/g, '-'),\n * maxRetries: 10,\n * });\n * // uniqueName === 'foo 3'\n * ```\n */\nexport async function generateUniqueValue({\n defaultValue,\n /** Check function to verify the uniqueness of the value */\n validation,\n /** Transformation function to transform the default value (such as into a slug) */\n transformation,\n /** The maximum number of attempts to create a unique value by incrementing. */\n maxRetries = 5,\n}: {\n /**\n * The original value to base the unique generation upon.\n * Example: \"workspace\", which may end up producing \"workspace 2\", \"workspace 3\", etc.\n */\n defaultValue: string\n\n /**\n * Validation function that determines if a generated value is unique.\n * Should return true if the value is unique; false if not.\n * Can be asynchronous or synchronous.\n */\n validation: (value: string) => Promise<boolean> | boolean\n\n /**\n * Optional function to transform the default value before attempting uniqueness.\n * Example: Transform \"Workspace A\" into \"workspace-a\" to follow a slug schema.\n */\n transformation?: (value: string) => string\n\n /**\n * The maximum number of attempts to create a unique value by incrementing.\n * For example, if set to 5: \"foo\", \"foo 1\", \"foo 2\", \"foo 3\", \"foo 4\" will be attempted.\n */\n maxRetries: number\n}) {\n const transformed = transformation?.(defaultValue) ?? defaultValue\n\n if (await validation(transformed)) {\n return transformed\n }\n\n return incrementValue({\n value: [transformed, 1],\n validation,\n maxRetries,\n transformation,\n })\n}\n\n/**\n * Attempts to generate a unique value by appending and incrementing a counter to a base string.\n *\n * On each attempt, appends the next incrementing integer (e.g. \"foo 1\", \"foo 2\", etc.) to the original value,\n * and checks with the validation function whether the candidate value is unique.\n *\n * Continues until a unique value is found, or the maximum number of attempts is reached.\n *\n * Returns the first unique value found, or undefined if a unique value cannot be generated within maxRetries.\n *\n * Example:\n * ```ts\n * const existing = new Set(['bar', 'bar 1']);\n * const result = incrementValue({\n * value: ['bar', 1],\n * validation: (val) => !existing.has(val),\n * maxRetries: 5,\n * });\n * // result === \"bar 2\"\n * ```\n */\nasync function incrementValue({\n value,\n validation,\n maxRetries,\n attempts = 0,\n transformation,\n}: {\n /**\n * Tuple containing the base value and the starting increment number.\n * Example: [\"workspace\", 1] will try \"workspace 1\", \"workspace 2\", etc.\n */\n value: [string, number] // [base value, next increment]\n\n /**\n * Function to validate if the generated value is unique.\n * Should return true if the value is unique, otherwise false.\n * Supports both synchronous and asynchronous operation.\n */\n validation: (value: string) => Promise<boolean> | boolean\n\n /**\n * The maximum number of retry attempts to generate a unique value.\n * Generation will stop and return undefined if this number is exceeded.\n */\n maxRetries: number\n\n /**\n * The current attempt count.\n * Used internally for recursion; users should generally omit this field.\n */\n attempts?: number\n\n /**\n * Optional function to transform the value before passing it to validation.\n * E.g., for slugifying a value for URLs.\n */\n transformation?: (value: string) => string\n}) {\n if (attempts >= maxRetries) {\n return\n }\n\n const incremented = value.join(' ')\n const transformed = transformation?.(incremented) ?? incremented\n\n if (await validation(transformed)) {\n return transformed\n }\n\n return incrementValue({\n value: [value[0], value[1] + 1],\n validation,\n maxRetries,\n transformation,\n attempts: attempts + 1,\n })\n}\n"],
|
|
5
|
+
"mappings": "AAuBA,eAAsB,oBAAoB;AAAA,EACxC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA,aAAa;AACf,GAyBG;AACD,QAAM,cAAc,iBAAiB,YAAY,KAAK;AAEtD,MAAI,MAAM,WAAW,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,SAAO,eAAe;AAAA,IACpB,OAAO,CAAC,aAAa,CAAC;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAuBA,eAAe,eAAe;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,GA+BG;AACD,MAAI,YAAY,YAAY;AAC1B;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,KAAK,GAAG;AAClC,QAAM,cAAc,iBAAiB,WAAW,KAAK;AAErD,MAAI,MAAM,WAAW,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,SAAO,eAAe;AAAA,IACpB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,WAAW;AAAA,EACvB,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unpacks special vue reactivity & override & detect-changes & magic proxy from an input object or array,
|
|
3
3
|
* returning the "raw" plain object or array.
|
|
4
|
+
*
|
|
5
|
+
* This function recursively traverses the input object or array, removing any proxies
|
|
6
|
+
* (e.g. Vue reactivity proxies, magic proxies, override proxies, detect-changes proxies)
|
|
7
|
+
* to obtain and return the underlying "raw" plain object or array.
|
|
8
|
+
*
|
|
9
|
+
* The recursion is controlled by the `depth` parameter. If `depth` is `null`, unlimited depth is allowed.
|
|
10
|
+
* If a proxied object is detected and unwrapped at non-root level, a warning is logged.
|
|
11
|
+
*
|
|
12
|
+
* @param input - The object or array (possibly deeply nested or proxied) to recursively unwrap.
|
|
13
|
+
* @param depth - Optional, limits recursion depth. `null` means unlimited depth (default is 1).
|
|
14
|
+
* @returns - A plain object or array with all proxies removed up to the specified depth.
|
|
4
15
|
*/
|
|
5
|
-
export declare const unpackProxyObject: <T>(input: T
|
|
16
|
+
export declare const unpackProxyObject: <T>(input: T, { depth }?: {
|
|
17
|
+
depth?: number | null;
|
|
18
|
+
}) => T;
|
|
6
19
|
//# sourceMappingURL=unpack-proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpack-proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/unpack-proxy.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"unpack-proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/unpack-proxy.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,YAAe;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,KAAG,CAsE9F,CAAA"}
|
|
@@ -2,7 +2,57 @@ import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
|
2
2
|
import { toRaw } from "vue";
|
|
3
3
|
import { unpackDetectChangesProxy } from "../helpers/detect-changes-proxy.js";
|
|
4
4
|
import { unpackOverridesProxy } from "../helpers/overrides-proxy.js";
|
|
5
|
-
const unpackProxyObject = (input) =>
|
|
5
|
+
const unpackProxyObject = (input, { depth = 0 } = {}) => {
|
|
6
|
+
const dfs = (value, currentDepth = 0) => {
|
|
7
|
+
if (typeof value !== "object" || value === null) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
const raw = unpackDetectChangesProxy(toRaw(getRaw(unpackOverridesProxy(value))));
|
|
11
|
+
if (depth !== null && currentDepth >= depth) {
|
|
12
|
+
return raw;
|
|
13
|
+
}
|
|
14
|
+
if (currentDepth !== 0 && raw !== value) {
|
|
15
|
+
console.warn(
|
|
16
|
+
"%c\u26A0 Warning:%c You tried to assign a proxied object (depth: %d).\n%c\u{1F4A1} Tip:%c Pass a plain object instead \u2014 wrapping a proxy inside another proxy may cause weird bugs.\n%c\u{1F50D} Debug Info:%c The problematic value is shown below:",
|
|
17
|
+
// styles
|
|
18
|
+
"background: #fdd835; color: #000; font-weight: bold; padding: 2px 4px; border-radius: 3px;",
|
|
19
|
+
"color: inherit;",
|
|
20
|
+
currentDepth,
|
|
21
|
+
"color: #00bfa5; font-weight: bold;",
|
|
22
|
+
"color: inherit;",
|
|
23
|
+
"color: #03a9f4; font-weight: bold;",
|
|
24
|
+
"color: inherit;",
|
|
25
|
+
value,
|
|
26
|
+
input
|
|
27
|
+
);
|
|
28
|
+
console.groupCollapsed("%c\u{1F4DC} Proxy assignment trace", "color: #9c27b0; font-weight: bold;");
|
|
29
|
+
console.trace({ value, raw });
|
|
30
|
+
console.groupEnd();
|
|
31
|
+
}
|
|
32
|
+
Object.entries(raw).forEach(([key, value2]) => {
|
|
33
|
+
const propertyResult = dfs(value2, currentDepth + 1);
|
|
34
|
+
const result = Reflect.set(raw, key, propertyResult);
|
|
35
|
+
if (!result) {
|
|
36
|
+
console.warn(
|
|
37
|
+
'%c\u{1F6AB} Readonly Property Error:%c Failed to set property "%s" on object.\n%c\u{1F4A1} Tip:%c This property is readonly or non-configurable. You cannot unpack a readonly property \u2014 the value was not updated.\n%c\u{1F50D} Debug Info:%c Property: %s | Value: %o | Object: %o',
|
|
38
|
+
// styles
|
|
39
|
+
"background: #f44336; color: #fff; font-weight: bold; padding: 2px 4px; border-radius: 3px;",
|
|
40
|
+
"color: inherit;",
|
|
41
|
+
key,
|
|
42
|
+
"color: #00bfa5; font-weight: bold;",
|
|
43
|
+
"color: inherit;",
|
|
44
|
+
"color: #03a9f4; font-weight: bold;",
|
|
45
|
+
"color: inherit;",
|
|
46
|
+
key,
|
|
47
|
+
propertyResult,
|
|
48
|
+
raw
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return raw;
|
|
53
|
+
};
|
|
54
|
+
return dfs(input);
|
|
55
|
+
};
|
|
6
56
|
export {
|
|
7
57
|
unpackProxyObject
|
|
8
58
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/unpack-proxy.ts"],
|
|
4
|
-
"sourcesContent": ["import { getRaw } from '@scalar/json-magic/magic-proxy'\nimport { toRaw } from 'vue'\n\nimport { unpackDetectChangesProxy } from '@/helpers/detect-changes-proxy'\nimport { unpackOverridesProxy } from '@/helpers/overrides-proxy'\n\n/**\n * Unpacks special vue reactivity & override & detect-changes & magic proxy from an input object or array,\n * returning the \"raw\" plain object or array.\n */\nexport const unpackProxyObject = <T>(input: T): T
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AAEtB,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { getRaw } from '@scalar/json-magic/magic-proxy'\nimport { toRaw } from 'vue'\n\nimport { unpackDetectChangesProxy } from '@/helpers/detect-changes-proxy'\nimport { unpackOverridesProxy } from '@/helpers/overrides-proxy'\n\n/**\n * Unpacks special vue reactivity & override & detect-changes & magic proxy from an input object or array,\n * returning the \"raw\" plain object or array.\n *\n * This function recursively traverses the input object or array, removing any proxies\n * (e.g. Vue reactivity proxies, magic proxies, override proxies, detect-changes proxies)\n * to obtain and return the underlying \"raw\" plain object or array.\n *\n * The recursion is controlled by the `depth` parameter. If `depth` is `null`, unlimited depth is allowed.\n * If a proxied object is detected and unwrapped at non-root level, a warning is logged.\n *\n * @param input - The object or array (possibly deeply nested or proxied) to recursively unwrap.\n * @param depth - Optional, limits recursion depth. `null` means unlimited depth (default is 1).\n * @returns - A plain object or array with all proxies removed up to the specified depth.\n */\nexport const unpackProxyObject = <T>(input: T, { depth = 0 }: { depth?: number | null } = {}): T => {\n // Internal DFS helper to recursively strip all known proxies (Vue, overrides, detect-changes, magic proxies)\n const dfs = (value: any, currentDepth: number = 0): any => {\n // Base case: non-objects (primitives, null) are returned as-is\n if (typeof value !== 'object' || value === null) {\n return value\n }\n\n // Compose all the proxy unwraps in order\n const raw = unpackDetectChangesProxy(toRaw(getRaw(unpackOverridesProxy(value))))\n\n // If we have reached the maximum depth, return the value (potentially still partially proxied)\n if (depth !== null && currentDepth >= depth) {\n return raw\n }\n\n // Show a warning if a nested value was a proxy (usually undesired, can cause subtle bugs)\n if (currentDepth !== 0 && raw !== value) {\n console.warn(\n '%c\u26A0 Warning:%c You tried to assign a proxied object (depth: %d).\\n' +\n '%c\uD83D\uDCA1 Tip:%c Pass a plain object instead \u2014 wrapping a proxy inside another proxy may cause weird bugs.\\n' +\n '%c\uD83D\uDD0D Debug Info:%c The problematic value is shown below:',\n // styles\n 'background: #fdd835; color: #000; font-weight: bold; padding: 2px 4px; border-radius: 3px;',\n 'color: inherit;',\n currentDepth,\n 'color: #00bfa5; font-weight: bold;',\n 'color: inherit;',\n 'color: #03a9f4; font-weight: bold;',\n 'color: inherit;',\n value,\n input,\n )\n\n // Collapsed trace group for cleaner output\n console.groupCollapsed('%c\uD83D\uDCDC Proxy assignment trace', 'color: #9c27b0; font-weight: bold;')\n console.trace({ value, raw })\n console.groupEnd()\n }\n\n // Recursively process all properties/entries to make sure we are not assigning proxies directly,\n // but are always assigning plain objects at any level.\n Object.entries(raw).forEach(([key, value]) => {\n const propertyResult = dfs(value, currentDepth + 1)\n const result = Reflect.set(raw, key, propertyResult)\n\n if (!result) {\n console.warn(\n '%c\uD83D\uDEAB Readonly Property Error:%c Failed to set property \"%s\" on object.\\n' +\n '%c\uD83D\uDCA1 Tip:%c This property is readonly or non-configurable. You cannot unpack a readonly property \u2014 the value was not updated.\\n' +\n '%c\uD83D\uDD0D Debug Info:%c Property: %s | Value: %o | Object: %o',\n // styles\n 'background: #f44336; color: #fff; font-weight: bold; padding: 2px 4px; border-radius: 3px;',\n 'color: inherit;',\n key,\n 'color: #00bfa5; font-weight: bold;',\n 'color: inherit;',\n 'color: #03a9f4; font-weight: bold;',\n 'color: inherit;',\n key,\n propertyResult,\n raw,\n )\n }\n })\n\n return raw\n }\n\n return dfs(input)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AAEtB,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AAiB9B,MAAM,o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