oc 0.50.32 → 0.50.34
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/AGENTS.md +58 -0
- package/CHANGELOG.md +13 -5
- package/biome.json +51 -54
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/commands.js +3 -0
- package/dist/cli/domain/get-mocked-plugins.js +2 -2
- package/dist/cli/domain/registry.d.ts +1 -0
- package/dist/cli/domain/registry.js +6 -1
- package/dist/cli/domain/watch.js +3 -1
- package/dist/cli/facade/publish.d.ts +2 -0
- package/dist/cli/facade/publish.js +5 -1
- package/dist/cli/index.js +1 -1
- package/dist/components/oc-client/_package/package.json +9 -8
- package/dist/components/oc-client/_package/server.js +1 -1
- package/dist/components/oc-client/_package/template.js +17 -22
- package/dist/components/oc-client/package.json +1 -1
- package/dist/registry/domain/register-templates.js +35 -2
- package/dist/registry/middleware/index.js +2 -0
- package/dist/registry/middleware/request-handler.js +1 -1
- package/dist/registry/routes/component-info.js +5 -2
- package/dist/registry/routes/components.js +3 -3
- package/dist/registry/routes/helpers/get-component.js +1 -4
- package/dist/registry/routes/helpers/get-components-history.d.ts +1 -2
- package/dist/registry/routes/index.js +56 -34
- package/dist/registry/views/index.js +1 -5
- package/dist/registry/views/info.d.ts +2 -2
- package/dist/registry/views/info.js +122 -26
- package/dist/registry/views/partials/component-parameters.js +7 -7
- package/dist/registry/views/partials/component-state.js +1 -1
- package/dist/registry/views/partials/components-list.js +5 -14
- package/dist/registry/views/partials/layout.d.ts +2 -1
- package/dist/registry/views/partials/layout.js +65 -5
- package/dist/registry/views/partials/selected-checkbox.js +1 -1
- package/dist/registry/views/static/index.d.ts +1 -1
- package/dist/registry/views/static/index.js +2 -2
- package/dist/registry/views/static/info.d.ts +1 -1
- package/dist/registry/views/static/info.js +50 -0
- package/dist/registry/views/static/style.d.ts +1 -1
- package/dist/registry/views/static/style.js +1126 -192
- package/dist/types.d.ts +4 -2
- package/logintervals.md +1 -1
- package/package.json +42 -39
- package/preview/fakeVM.ts +583 -0
- package/preview/uiPreview.ts +57 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
## Rules
|
|
2
|
+
|
|
3
|
+
### 1. File & Folder Organization
|
|
4
|
+
- **Domain-driven structure**: Organize code by business domains (`cli/`, `registry/`, `components/`, `utils/`)
|
|
5
|
+
- **Subfolder patterns**: Use consistent patterns (`domain/`, `routes/`, `views/`, `middleware/`)
|
|
6
|
+
- **File naming**: Use kebab-case for all files and folders (`components-cache`, `package-json-validator`)
|
|
7
|
+
- **Module exports**: Use `index.ts` files for clean public APIs and re-exports
|
|
8
|
+
- **Centralized types**: Place shared TypeScript interfaces in `src/types.ts`
|
|
9
|
+
|
|
10
|
+
### 2. TypeScript Coding Standards
|
|
11
|
+
- **Strict compilation**: All code must pass TypeScript strict mode checks
|
|
12
|
+
- **Interface design**: Use comprehensive interfaces with optional properties (`?` syntax)
|
|
13
|
+
- **Type imports**: Use `import type` for type-only dependencies
|
|
14
|
+
- **Union types**: Use union types for constrained values (`'oc-registry' | 'oc-registry-local'`)
|
|
15
|
+
- **Generic interfaces**: Extend base types like `PackageJson` for specialized interfaces
|
|
16
|
+
- **Naming conventions**:
|
|
17
|
+
- camelCase for variables/functions (`componentName`, `getComponent`)
|
|
18
|
+
- PascalCase for interfaces/types (`Component`, `RegistryOptions`)
|
|
19
|
+
- UPPER_CASE for constants (`DEFAULT_PORT`)
|
|
20
|
+
|
|
21
|
+
### 3. Code Style & Patterns
|
|
22
|
+
- **Import organization**: Group imports (Node.js with `node:` prefix, external libraries, local modules)
|
|
23
|
+
- **Function style**: Use arrow functions for simple operations, function declarations for main functions
|
|
24
|
+
- **Async patterns**: Prefer async/await over Promise chains
|
|
25
|
+
- **Object destructuring**: Use destructuring in function parameters
|
|
26
|
+
- **Descriptive naming**: Use clear, descriptive function names (`getComponentRetrievingInfo` vs `getComp`)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## File Structure Enforcement
|
|
31
|
+
|
|
32
|
+
### Required Directory Structure
|
|
33
|
+
```
|
|
34
|
+
src/
|
|
35
|
+
├── cli/
|
|
36
|
+
│ ├── commands.ts
|
|
37
|
+
│ ├── domain/ # Business logic
|
|
38
|
+
│ ├── facade/ # Public APIs
|
|
39
|
+
│ └── programmatic-api.ts
|
|
40
|
+
├── registry/
|
|
41
|
+
│ ├── routes/ # Express routes
|
|
42
|
+
│ ├── domain/ # Business logic
|
|
43
|
+
│ │ └── validators/ # Input validation
|
|
44
|
+
│ ├── views/ # JSX components
|
|
45
|
+
│ │ └── partials/ # Reusable components
|
|
46
|
+
│ └── middleware/ # Express middleware
|
|
47
|
+
├── components/ # Component implementations
|
|
48
|
+
├── utils/ # Shared utilities
|
|
49
|
+
├── types.ts # Centralized type definitions
|
|
50
|
+
└── resources/ # Static resources
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### File Extension Rules
|
|
54
|
+
- `.ts` for TypeScript modules and business logic
|
|
55
|
+
- `.tsx` for React/JSX components and views
|
|
56
|
+
- `index.ts` for module exports and public APIs
|
|
57
|
+
|
|
58
|
+
---
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v0.50.34
|
|
4
|
+
- [#1450](https://github.com/opencomponents/oc/pull/1450) revert yargs for now
|
|
5
|
+
|
|
6
|
+
### v0.50.33
|
|
7
|
+
- [#1449](https://github.com/opencomponents/oc/pull/1449) allow token pass
|
|
8
|
+
- [#1448](https://github.com/opencomponents/oc/pull/1448) add ability for custom meta query
|
|
9
|
+
- [#1447](https://github.com/opencomponents/oc/pull/1447) Revamp UI + Preview server
|
|
10
|
+
|
|
3
11
|
### v0.50.32
|
|
4
12
|
- [#1446](https://github.com/opencomponents/oc/pull/1446) update oc-client-browser
|
|
5
13
|
|
|
@@ -309,7 +317,7 @@
|
|
|
309
317
|
### v0.49.2
|
|
310
318
|
- [#1259](https://github.com/opencomponents/oc/pull/1259) [BUGFIX] remove prefix command on npm
|
|
311
319
|
- [#1248](https://github.com/opencomponents/oc/pull/1248) Type better baseUrlFunc and discoveryFunc
|
|
312
|
-
- [#1249](https://github.com/opencomponents/oc/pull/1249) use internal body-parser from express >=4.16
|
|
320
|
+
- [#1249](https://github.com/opencomponents/oc/pull/1249) use internal body-parser from express >=4.16
|
|
313
321
|
- [#1250](https://github.com/opencomponents/oc/pull/1250) reduce lodash functions where they are easy replaceable
|
|
314
322
|
- [#1251](https://github.com/opencomponents/oc/pull/1251) [INTERNAL] remove cjs export from facade, deal with it on cli/index
|
|
315
323
|
- [#1252](https://github.com/opencomponents/oc/pull/1252) [INTERNAL] reduce usage of null assertions
|
|
@@ -808,12 +816,12 @@
|
|
|
808
816
|
|
|
809
817
|
### v0.41.16
|
|
810
818
|
- [#733](https://github.com/opencomponents/oc/pull/733) Repackage all components when file is outside component dir
|
|
811
|
-
- [#732](https://github.com/opencomponents/oc/pull/732) Prettify all the things
|
|
819
|
+
- [#732](https://github.com/opencomponents/oc/pull/732) Prettify all the things
|
|
812
820
|
- [#731](https://github.com/opencomponents/oc/pull/731) this-less cleanup
|
|
813
821
|
- [#729](https://github.com/opencomponents/oc/pull/729) Update aws-sdk to the latest version 🚀
|
|
814
822
|
|
|
815
823
|
### v0.41.15
|
|
816
|
-
- [#710](https://github.com/opencomponents/oc/pull/710) [DX-185] install compiler inside each components' dir
|
|
824
|
+
- [#710](https://github.com/opencomponents/oc/pull/710) [DX-185] install compiler inside each components' dir
|
|
817
825
|
|
|
818
826
|
### v0.41.14
|
|
819
827
|
- [#728](https://github.com/opencomponents/oc/pull/728) [DX-226] ]Minimal css for the preview view
|
|
@@ -1073,7 +1081,7 @@
|
|
|
1073
1081
|
### v0.37.11
|
|
1074
1082
|
- [#488](https://github.com/opencomponents/oc/pull/488) yarn-support
|
|
1075
1083
|
|
|
1076
|
-
closes #487
|
|
1084
|
+
closes #487
|
|
1077
1085
|
|
|
1078
1086
|
### v0.37.10
|
|
1079
1087
|
- [#516](https://github.com/opencomponents/oc/pull/516) Improve AWS upload mechanism and allow to override registry timeout settings
|
|
@@ -1590,7 +1598,7 @@ tested
|
|
|
1590
1598
|
- [#159](https://github.com/opencomponents/oc/pull/159) should have an explicit dep on phantom
|
|
1591
1599
|
|
|
1592
1600
|
### v0.22.0
|
|
1593
|
-
- [#157](https://github.com/opencomponents/oc/pull/157) Server/Client-side render info
|
|
1601
|
+
- [#157](https://github.com/opencomponents/oc/pull/157) Server/Client-side render info
|
|
1594
1602
|
- [#156](https://github.com/opencomponents/oc/pull/156) House keeping
|
|
1595
1603
|
|
|
1596
1604
|
### v0.21.0
|
package/biome.json
CHANGED
|
@@ -1,55 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": false,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": false
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false,
|
|
10
|
+
"includes": ["preview/**/*", "src/**/*", "!src/components/oc-client/**/*"]
|
|
11
|
+
},
|
|
12
|
+
"formatter": {
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"indentStyle": "tab"
|
|
15
|
+
},
|
|
16
|
+
"linter": {
|
|
17
|
+
"enabled": true,
|
|
18
|
+
"rules": {
|
|
19
|
+
"recommended": true,
|
|
20
|
+
"correctness": {
|
|
21
|
+
"useJsxKeyInIterable": "off"
|
|
22
|
+
},
|
|
23
|
+
"complexity": {
|
|
24
|
+
"useLiteralKeys": "off",
|
|
25
|
+
"noExcessiveNestedTestSuites": "off"
|
|
26
|
+
},
|
|
27
|
+
"style": {
|
|
28
|
+
"noParameterAssign": "off",
|
|
29
|
+
"noNonNullAssertion": "off",
|
|
30
|
+
"useTemplate": "off"
|
|
31
|
+
},
|
|
32
|
+
"suspicious": {
|
|
33
|
+
"noExplicitAny": "off"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"javascript": {
|
|
38
|
+
"formatter": {
|
|
39
|
+
"trailingCommas": "none",
|
|
40
|
+
"indentStyle": "space",
|
|
41
|
+
"quoteStyle": "single"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"assist": {
|
|
45
|
+
"enabled": true,
|
|
46
|
+
"actions": {
|
|
47
|
+
"source": {
|
|
48
|
+
"organizeImports": "on"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
package/dist/cli/commands.d.ts
CHANGED
package/dist/cli/commands.js
CHANGED
|
@@ -114,6 +114,9 @@ exports.default = {
|
|
|
114
114
|
username: {
|
|
115
115
|
description: 'username used to authenticate when publishing to registry'
|
|
116
116
|
},
|
|
117
|
+
token: {
|
|
118
|
+
description: 'token used to authenticate when publishing to registry'
|
|
119
|
+
},
|
|
117
120
|
skipPackage: {
|
|
118
121
|
boolean: true,
|
|
119
122
|
description: 'Skip packaging step',
|
|
@@ -37,12 +37,12 @@ const registerDynamicMocks = (ocJsonLocation, mocks, logger) => Object.entries(m
|
|
|
37
37
|
}
|
|
38
38
|
catch (er) {
|
|
39
39
|
logger.err(String(er));
|
|
40
|
-
return;
|
|
40
|
+
return undefined;
|
|
41
41
|
}
|
|
42
42
|
if (!isMockValid(pluginMock)) {
|
|
43
43
|
logger.err(`├── ${pluginName} () => Error (skipping)`);
|
|
44
44
|
logger.err(resources_1.default.errors.cli.MOCK_PLUGIN_IS_NOT_VALID);
|
|
45
|
-
return;
|
|
45
|
+
return undefined;
|
|
46
46
|
}
|
|
47
47
|
const register = pluginMock.register || defaultRegister;
|
|
48
48
|
const execute = pluginMock.execute || pluginMock;
|
|
@@ -105,7 +105,12 @@ function registry(opts = {}) {
|
|
|
105
105
|
return urlBuilder.componentPreview(parsed, parsed.registryUrl);
|
|
106
106
|
},
|
|
107
107
|
async putComponent(options) {
|
|
108
|
-
if (
|
|
108
|
+
if (options.token) {
|
|
109
|
+
requestsHeaders = Object.assign(requestsHeaders, {
|
|
110
|
+
Authorization: `Bearer ${options.token}`
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else if (!!options.username && !!options.password) {
|
|
109
114
|
requestsHeaders = Object.assign(requestsHeaders, {
|
|
110
115
|
Authorization: 'Basic ' +
|
|
111
116
|
Buffer.from(options.username + ':' + options.password).toString('base64')
|
package/dist/cli/domain/watch.js
CHANGED
|
@@ -22,7 +22,9 @@ function watch(dirs, baseDir, changed) {
|
|
|
22
22
|
.on('add', onChange)
|
|
23
23
|
.on('change', onChange)
|
|
24
24
|
.on('unlink', onChange)
|
|
25
|
-
.on('error',
|
|
25
|
+
.on('error', (err) => {
|
|
26
|
+
changed(err instanceof Error ? err : new Error(String(err)), '', undefined);
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
function escapeRegularExpression(text) {
|
|
28
30
|
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
@@ -12,6 +12,7 @@ declare const publish: ({ logger, registry, local }: {
|
|
|
12
12
|
dryRun?: boolean;
|
|
13
13
|
username?: string;
|
|
14
14
|
password?: string;
|
|
15
|
+
token?: string;
|
|
15
16
|
registries?: string[];
|
|
16
17
|
}): Promise<void>;
|
|
17
18
|
(opts: {
|
|
@@ -20,6 +21,7 @@ declare const publish: ({ logger, registry, local }: {
|
|
|
20
21
|
dryRun?: boolean;
|
|
21
22
|
username?: string;
|
|
22
23
|
password?: string;
|
|
24
|
+
token?: string;
|
|
23
25
|
registries?: string[];
|
|
24
26
|
}, arguments__1: (error: unknown, value: void) => void): void;
|
|
25
27
|
};
|
|
@@ -21,6 +21,10 @@ const publish = ({ logger, registry, local }) => (0, universalify_1.fromPromise)
|
|
|
21
21
|
let errorMessage;
|
|
22
22
|
const readPackageJson = () => fs_extra_1.default.readJson(node_path_1.default.join(packageDir, 'package.json'));
|
|
23
23
|
const getCredentials = async () => {
|
|
24
|
+
if (opts.token) {
|
|
25
|
+
logger.ok(index_1.default.messages.cli.USING_CREDS);
|
|
26
|
+
return { token: opts.token };
|
|
27
|
+
}
|
|
24
28
|
if (opts.username && opts.password) {
|
|
25
29
|
logger.ok(index_1.default.messages.cli.USING_CREDS);
|
|
26
30
|
const { username, password } = opts;
|
|
@@ -52,7 +56,7 @@ const publish = ({ logger, registry, local }) => (0, universalify_1.fromPromise)
|
|
|
52
56
|
}
|
|
53
57
|
catch (err) {
|
|
54
58
|
if (err === 'Unauthorized' || err.message === 'Unauthorized') {
|
|
55
|
-
if (!!options.username || !!options.password) {
|
|
59
|
+
if (!!options.username || !!options.password || !!options.token) {
|
|
56
60
|
logger.err(index_1.default.errors.cli.PUBLISHING_FAIL(index_1.default.errors.cli.INVALID_CREDENTIALS));
|
|
57
61
|
throw err;
|
|
58
62
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-client",
|
|
3
3
|
"description": "The OpenComponents client-side javascript client",
|
|
4
|
-
"version": "0.50.
|
|
4
|
+
"version": "0.50.34",
|
|
5
5
|
"repository": "https://github.com/opencomponents/oc/tree/master/components/oc-client",
|
|
6
6
|
"author": "Matteo Figus <matteofigus@gmail.com>",
|
|
7
7
|
"oc": {
|
|
@@ -12,24 +12,25 @@
|
|
|
12
12
|
"files": {
|
|
13
13
|
"template": {
|
|
14
14
|
"type": "oc-template-es6",
|
|
15
|
-
"hashKey": "
|
|
15
|
+
"hashKey": "c4abb6bf4dc6657fb718a45b64bd6b2cb92e874a",
|
|
16
16
|
"src": "template.js",
|
|
17
|
-
"version": "
|
|
18
|
-
"
|
|
17
|
+
"version": "2.0.0",
|
|
18
|
+
"minOcVersion": "0.50.18",
|
|
19
|
+
"size": 2752
|
|
19
20
|
},
|
|
20
21
|
"static": [
|
|
21
22
|
"src"
|
|
22
23
|
],
|
|
23
24
|
"dataProvider": {
|
|
24
25
|
"type": "node.js",
|
|
25
|
-
"hashKey": "
|
|
26
|
+
"hashKey": "94b78865716a8ea8be7a6a7e3f246aed2cef56e0",
|
|
26
27
|
"src": "server.js",
|
|
27
|
-
"size":
|
|
28
|
+
"size": 644
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
|
-
"version": "0.50.
|
|
31
|
+
"version": "0.50.34",
|
|
31
32
|
"packaged": true,
|
|
32
|
-
"date":
|
|
33
|
+
"date": 1758182053244
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"oc-template-es6-compiler": "^1.0.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(t,s)=>{const{staticPath:e,templates:a}=t;return s(null,{staticPath:e,templates:a})},r=(t,s)=>{o(t,(e,a,i={})=>{if(e)return s(e);if(a==null)return s(null,{__oc_emptyResponse:!0});const n=t.action?a:Object.assign({},a,{_staticPath:t.staticPath,_baseUrl:t.baseUrl,_componentName:"oc-client",_componentVersion:"0.50.34"}),c=t.staticPath.indexOf("http")===0?t.staticPath:"https:"+t.staticPath;return s(null,Object.assign({},{component:{key:"c4abb6bf4dc6657fb718a45b64bd6b2cb92e874a",src:c+"template.js",props:n,esm:!1,development:void 0}}))})};exports.data=r;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
var oc=oc||{};oc.components=oc.components||{};oc.components['
|
|
1
|
+
var oc=oc||{};oc.components=oc.components||{};oc.components['c4abb6bf4dc6657fb718a45b64bd6b2cb92e874a']=function(model) {
|
|
2
2
|
var __toOcStaticPathUrl = function(args) {
|
|
3
3
|
return model.component.props._staticPath + 'src/' + args;
|
|
4
4
|
}
|
|
5
5
|
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = model.component.props;
|
|
6
6
|
var __$$oc_initialData__ = rest;
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
var element = model.element || typeof document !== 'undefined' ? document.querySelector(window.oc.conf.tag || 'oc-component' + '[data-id="'+ model.id +'"]') : null;
|
|
8
9
|
var __$$oc_Settings__ = {id: model.id, element: element, staticPath: _staticPath, baseUrl: _baseUrl, name: _componentName, version: _componentVersion};
|
|
9
10
|
var innerFn = function(model){
|
|
10
11
|
oc.es6Components = oc.es6Components || {};
|
|
11
|
-
oc.es6Components['
|
|
12
|
+
oc.es6Components['c4abb6bf4dc6657fb718a45b64bd6b2cb92e874a'] = (
|
|
12
13
|
(function() {
|
|
13
|
-
var clientBundle=function(){"use strict";const n=({templates:c,staticPath:t})=>`<script>window.oc=window.oc||{};oc.conf=oc.conf||{};oc.conf.templates=(oc.conf.templates||[]).concat(${JSON.stringify(c)});<\/script><script src="${t}src/oc-client.min.js" type="text/javascript"><\/script>`;function e(c,t){const{_staticPath:o,_baseUrl:i,_componentName:r,_componentVersion:s,...a}=c;t.innerHTML=n(c)}return e}();
|
|
14
|
+
var clientBundle=(function(){"use strict";const n=({templates:c,staticPath:t})=>`<script>window.oc=window.oc||{};oc.conf=oc.conf||{};oc.conf.templates=(oc.conf.templates||[]).concat(${JSON.stringify(c)});<\/script><script src="${t}src/oc-client.min.js" type="text/javascript"><\/script>`;function e(c,t){const{_staticPath:o,_baseUrl:i,_componentName:r,_componentVersion:s,...a}=c;t.innerHTML=n(c)}return e})();
|
|
14
15
|
|
|
15
16
|
return clientBundle;
|
|
16
17
|
})());
|
|
@@ -19,37 +20,31 @@ var oc=oc||{};oc.components=oc.components||{};oc.components['8b7545cba94f7c029b9
|
|
|
19
20
|
var ssr = !!modelHTML;
|
|
20
21
|
var externals = [];
|
|
21
22
|
var staticPath = model.component.props._staticPath;
|
|
22
|
-
if (ssr) {
|
|
23
|
-
externals.push({
|
|
24
|
-
global: ['oc', 'components', '8b7545cba94f7c029b9d46108bfe8e4e6040ea09'],
|
|
25
|
-
url: staticPath + 'template.js',
|
|
26
|
-
name: "template"
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
23
|
var props = JSON.stringify(model.component.props);
|
|
30
24
|
oc = oc || {};
|
|
31
25
|
oc.__es6Template = oc.__es6Template || { count: 0 };
|
|
26
|
+
oc.__data = oc.__data || {};
|
|
27
|
+
oc.__data[model.id] = model.component.props;
|
|
32
28
|
var count = oc.__es6Template.count;
|
|
33
29
|
var templateId = "oc-es6Root-oc-client-" + count;
|
|
34
30
|
oc.__es6Template.count++;
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
return '<div id="' + templateId + '" class="oc-es6Root-oc-client">' + modelHTML + '</div>' +
|
|
38
|
-
'' +
|
|
39
|
-
'<script>' +
|
|
31
|
+
var renderScript = '<script>' +
|
|
40
32
|
'oc = oc || {};' +
|
|
41
33
|
'oc.cmd = oc.cmd || [];' +
|
|
42
34
|
'oc.cmd.push(function(oc){' +
|
|
43
35
|
'' +
|
|
44
36
|
'oc.requireSeries(' + JSON.stringify(externals) + ', function(){' +
|
|
45
|
-
'var targetNode = document.getElementById("' +
|
|
46
|
-
'
|
|
47
|
-
(
|
|
48
|
-
'oc.components["8b7545cba94f7c029b9d46108bfe8e4e6040ea09"]({ id: "' + model.id + '", component: { props:' + props + ' } });' +
|
|
49
|
-
'oc.es6Components["8b7545cba94f7c029b9d46108bfe8e4e6040ea09"](' + props + ', targetNode, ' + !!modelHTML + ');' +
|
|
37
|
+
'var targetNode = document.getElementById("' + model.id + '");' +
|
|
38
|
+
'oc.components["c4abb6bf4dc6657fb718a45b64bd6b2cb92e874a"]({ id: "' + model.id + '", component: { props: oc.__data["' + model.id + '"]} });' +
|
|
39
|
+
'oc.es6Components["c4abb6bf4dc6657fb718a45b64bd6b2cb92e874a"](oc.__data["' + model.id + '"], targetNode, ' + !!modelHTML + ');' +
|
|
50
40
|
'});' +
|
|
51
41
|
'});' +
|
|
52
|
-
'</script>'
|
|
42
|
+
'</script>';
|
|
43
|
+
var wrappedHtml = '<div id="' + templateId + '" class="oc-es6Root-oc-client">' + modelHTML + '</div>';
|
|
44
|
+
|
|
45
|
+
return modelHTML +
|
|
46
|
+
'' +
|
|
47
|
+
(ssr ? '' : renderScript)
|
|
53
48
|
};
|
|
54
49
|
return innerFn(model);
|
|
55
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-client",
|
|
3
3
|
"description": "The OpenComponents client-side javascript client",
|
|
4
|
-
"version": "0.50.
|
|
4
|
+
"version": "0.50.34",
|
|
5
5
|
"repository": "https://github.com/opencomponents/oc/tree/master/components/oc-client",
|
|
6
6
|
"author": "Matteo Figus <matteofigus@gmail.com>",
|
|
7
7
|
"oc": {
|
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.default = registerTemplates;
|
|
7
|
-
const
|
|
40
|
+
const es6Template = __importStar(require("oc-template-es6"));
|
|
8
41
|
const oc_template_handlebars_1 = __importDefault(require("oc-template-handlebars"));
|
|
9
42
|
const oc_template_jade_1 = __importDefault(require("oc-template-jade"));
|
|
10
43
|
function registerTemplates(extraTemplates, dev = false) {
|
|
11
44
|
const coreTemplates = [
|
|
12
|
-
|
|
45
|
+
es6Template,
|
|
13
46
|
oc_template_jade_1.default,
|
|
14
47
|
oc_template_handlebars_1.default
|
|
15
48
|
];
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.bind = void 0;
|
|
7
|
+
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
7
8
|
const errorhandler_1 = __importDefault(require("errorhandler"));
|
|
8
9
|
const express_1 = __importDefault(require("express"));
|
|
9
10
|
const morgan_1 = __importDefault(require("morgan"));
|
|
@@ -27,6 +28,7 @@ const bind = (app, options) => {
|
|
|
27
28
|
next();
|
|
28
29
|
});
|
|
29
30
|
app.use((0, request_handler_1.default)());
|
|
31
|
+
app.use((0, cookie_parser_1.default)());
|
|
30
32
|
if (options.postRequestPayloadSize) {
|
|
31
33
|
// Type is incorrect since limit can be a string like '50mb'
|
|
32
34
|
bodyParserJsonArgument.limit = options.postRequestPayloadSize;
|
|
@@ -10,7 +10,7 @@ function requestHandler() {
|
|
|
10
10
|
return (0, response_time_1.default)((req, res, time) => {
|
|
11
11
|
const data = {
|
|
12
12
|
body: req.body,
|
|
13
|
-
duration: Number.parseInt(String(time * 1000)),
|
|
13
|
+
duration: Number.parseInt(String(time * 1000), 10),
|
|
14
14
|
headers: req.headers,
|
|
15
15
|
method: req.method,
|
|
16
16
|
path: req.path,
|
|
@@ -55,7 +55,7 @@ function getParams(component) {
|
|
|
55
55
|
// Prefer default value over example
|
|
56
56
|
const value = param.default !== undefined
|
|
57
57
|
? String(param.default)
|
|
58
|
-
: param.example;
|
|
58
|
+
: String(param.example);
|
|
59
59
|
return [paramName, value];
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
@@ -83,6 +83,8 @@ function componentInfo(err, req, res, component, componentDetail) {
|
|
|
83
83
|
if (!result.isDiscoverable) {
|
|
84
84
|
href = `//${req.headers.host}${res.conf.prefix}`;
|
|
85
85
|
}
|
|
86
|
+
// Get theme from cookie or default to dark
|
|
87
|
+
const theme = req.cookies?.['oc-theme'] || 'dark';
|
|
86
88
|
res.send((0, info_1.default)({
|
|
87
89
|
component,
|
|
88
90
|
componentDetail,
|
|
@@ -91,7 +93,8 @@ function componentInfo(err, req, res, component, componentDetail) {
|
|
|
91
93
|
parsedAuthor,
|
|
92
94
|
repositoryUrl,
|
|
93
95
|
sandBoxDefaultQs: urlBuilder.queryString(params),
|
|
94
|
-
title: 'Component Info'
|
|
96
|
+
title: 'Component Info',
|
|
97
|
+
theme
|
|
95
98
|
}));
|
|
96
99
|
});
|
|
97
100
|
}
|
|
@@ -67,7 +67,7 @@ function components(conf, repository) {
|
|
|
67
67
|
version: component.version
|
|
68
68
|
}, (result) => callback(null, result));
|
|
69
69
|
},
|
|
70
|
-
// @ts-
|
|
70
|
+
// @ts-expect-error
|
|
71
71
|
(_err, results) => {
|
|
72
72
|
try {
|
|
73
73
|
setHeaders(results, res);
|
|
@@ -75,9 +75,9 @@ function components(conf, repository) {
|
|
|
75
75
|
res.status(200).json(results);
|
|
76
76
|
}
|
|
77
77
|
catch (e) {
|
|
78
|
-
// @ts-
|
|
78
|
+
// @ts-expect-error I think this will never reach (how can setHeaders throw?)
|
|
79
79
|
if (results.code && results.error) {
|
|
80
|
-
// @ts-
|
|
80
|
+
// @ts-expect-error
|
|
81
81
|
res.status(500).json({ code: results.code, error: results.error });
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
@@ -190,9 +190,7 @@ function getComponent(conf, repository) {
|
|
|
190
190
|
// sanitise and check params
|
|
191
191
|
const appliedParams = (0, apply_default_values_1.default)(requestedComponent.parameters, component.oc.parameters);
|
|
192
192
|
const params = sanitiser.sanitiseComponentParameters(appliedParams, component.oc.parameters);
|
|
193
|
-
const validationResult = validator.validateComponentParameters(
|
|
194
|
-
// @ts-ignore
|
|
195
|
-
params, component.oc.parameters);
|
|
193
|
+
const validationResult = validator.validateComponentParameters(params, component.oc.parameters);
|
|
196
194
|
if (!options.action && !validationResult.isValid) {
|
|
197
195
|
return callback({
|
|
198
196
|
status: 400,
|
|
@@ -245,7 +243,6 @@ function getComponent(conf, repository) {
|
|
|
245
243
|
const componentHref = urlBuilder.component({
|
|
246
244
|
name: component.name,
|
|
247
245
|
version: requestedComponent.version,
|
|
248
|
-
// @ts-ignore
|
|
249
246
|
parameters: params
|
|
250
247
|
}, conf.baseUrl);
|
|
251
248
|
const isUnrendered = options.headers.accept === settings_1.default.registry.acceptUnrenderedHeader;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ComponentsDetails } from '../../../types';
|
|
2
|
-
interface ComponentHistory {
|
|
2
|
+
export interface ComponentHistory {
|
|
3
3
|
name: string;
|
|
4
4
|
version: string;
|
|
5
5
|
publishDate: string;
|
|
6
6
|
templateSize?: number;
|
|
7
7
|
}
|
|
8
8
|
export default function getComponentsHistory(history: ComponentsDetails): ComponentHistory[];
|
|
9
|
-
export {};
|