diff --git a/README.md b/README.md index 9cb5f46..8b9ceaf 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,9 @@ import JavaScript modules - _extensions_ - that add new features and capabilities to the application. ExtendIt.js has been designed to efficiently work with -[React](https://react.dev/), for this purpose it provides a number of -reactive [hooks](). However, the library can be used without +[React](https://react.dev/), for this purpose it provides a number of reactive +[React hooks](https://react.dev/reference/react/hooks). +However, the library can be used without React too. It's only a peer dependency. # Installation @@ -104,16 +105,24 @@ export function activate(ctx: ExtensionContext) { ``` The host application registers extensions using the +[`readExtensionManifest`](https://forman.github.io/extendit/functions/core.readExtensionManifest.html) +and [`registerExtension`](https://forman.github.io/extendit/functions/core.registerExtension.html) -function: +functions: ```ts -import { registerExtension } from "@forman2/extendit"; +import { readExtensionManifest, registerExtension } from "@forman2/extendit"; export function initApp() { const extensionsUrls = getAppExtensionUrls(); extensionUrls.forEach((extensionUrl) => { - void registerExtension(extensionUrl); + readExtensionManifest(extensionUrl) + .then((manifest) => + registerExtension(manifest) + ) + .catch((error) => { + // ... + }); }); } @@ -277,7 +286,7 @@ async function getCommand(commandId: string): Promise { ``` There is also a corresponding React hook -[`useLoadCodeContribution`](https://forman.github.io/extendit/functions/react.useCodeContributions.html) +[`useLoadCodeContribution`](https://forman.github.io/extendit/functions/react.useLoadCodeContribution.html) that is used for implementing React components: ```tsx @@ -306,21 +315,6 @@ export default function CommandButton({ command }: CommandButtonProps) { We currently only have this file and the [API docs](https://forman.github.io/extendit/), sorry. -# Acknowledgements - -ExtendIt.js currently uses the awesome libraries - -* [Ajv](https://ajv.js.org/) for JSON validation (may be turned into peer dependency later) -* [memoize-one](https://github.com/alexreardon/memoize-one) for implementing state selector functions -* [zustand](https://github.com/pmndrs/zustand) for state management - -# License - -Copyright © 2023 Norman Fomferra - -Permissions are hereby granted under the terms of the MIT License: -https://opensource.org/licenses/MIT. - # Development ## Source Code @@ -377,3 +371,18 @@ stick to the following order: If we also have resource dependencies (`*.css`, `*.json`, `*.svg`, ...), we first import TypeScript source dependencies, then separated by a newline, insert resource dependencies in the same order as source dependencies. + +# Acknowledgements + +ExtendIt.js currently uses the awesome libraries + +* [Ajv](https://ajv.js.org/) for JSON validation (may be turned into peer dependency later) +* [memoize-one](https://github.com/alexreardon/memoize-one) for implementing state selector functions +* [zustand](https://github.com/pmndrs/zustand) for state management + +# License + +Copyright © 2023 Norman Fomferra + +Permissions are hereby granted under the terms of the MIT License: +https://opensource.org/licenses/MIT. diff --git a/docs/classes/util.AssertionError.html b/docs/classes/util.AssertionError.html index 72695f1..6174733 100644 --- a/docs/classes/util.AssertionError.html +++ b/docs/classes/util.AssertionError.html @@ -27,7 +27,7 @@

Hierarchy

+
  • Defined in src/framework/util/assert.ts:10
  • @@ -156,7 +156,7 @@
    message: Returns AssertionError
    +
  • Defined in src/framework/util/assert.ts:15
  • +
  • Defined in src/framework/util/disposable.ts:57
    • @@ -135,7 +135,7 @@

      Returns

    +
  • Defined in src/framework/util/disposable.ts:32
  • +
  • Defined in src/framework/util/expr/node.ts:243
  • Returns ParserError

    +
  • Defined in src/framework/util/expr/parser.ts:358
  • +
  • Defined in src/framework/util/expr/parser.ts:352
  • +
  • Defined in src/framework/util/expr/parser.ts:146
  • +
  • Defined in src/framework/util/expr/parser.ts:286
    • @@ -160,7 +160,7 @@

      Parameters

      Rest ...opIds: string[]
      Rest

    Returns undefined | BinaryOp

    +
  • Defined in src/framework/util/expr/parser.ts:319
  • +
  • Defined in src/framework/util/expr/parser.ts:118
  • +
  • Defined in src/framework/util/expr/parser.ts:80
  • +
  • Defined in src/framework/util/expr/parser.ts:76
    • @@ -197,7 +197,7 @@

      Parameters

      func: Node<unknown>

    Returns FunctionCall

    +
  • Defined in src/framework/util/expr/parser.ts:252
  • +
  • Defined in src/framework/util/expr/parser.ts:128
  • Returns IndexRef

    +
  • Defined in src/framework/util/expr/parser.ts:275
  • +
  • Defined in src/framework/util/expr/parser.ts:108
  • +
  • Defined in src/framework/util/expr/parser.ts:98
  • +
  • Defined in src/framework/util/expr/parser.ts:162
  • Returns undefined | T

    +
  • Defined in src/framework/util/expr/parser.ts:323
  • +
  • Defined in src/framework/util/expr/parser.ts:187
  • +
  • Defined in src/framework/util/expr/parser.ts:208
  • Returns PropertyRef

    +
  • Defined in src/framework/util/expr/parser.ts:263
  • +
  • Defined in src/framework/util/expr/parser.ts:67
  • Returns boolean

    +
  • Defined in src/framework/util/expr/parser.ts:306
  • +
  • Defined in src/framework/util/expr/parser.ts:178
  • Returns undefined | UnaryOp

    +
  • Defined in src/framework/util/expr/parser.ts:315
  • +
  • Defined in src/framework/util/expr/parser.ts:344
  • +
  • Defined in src/framework/util/expr/parser.ts:55
  • +
  • Defined in src/framework/util/log/level.ts:82
  • style?: string
    @@ -136,7 +136,7 @@
    +
  • Defined in src/framework/util/log/level.ts:81
  • value: number
    @@ -144,7 +144,7 @@
    +
  • Defined in src/framework/util/log/level.ts:80
  • ALL: LogLevel = ...
    @@ -152,7 +152,7 @@
    +
  • Defined in src/framework/util/log/level.ts:18
  • DEBUG: LogLevel = ...
    @@ -160,12 +160,12 @@
    +
  • Defined in src/framework/util/log/level.ts:22
  • DEFAULT: LogLevel = LogLevel.OFF
    +
  • Defined in src/framework/util/log/level.ts:56
  • ERROR: LogLevel = ...
    @@ -173,7 +173,7 @@
    +
  • Defined in src/framework/util/log/level.ts:49
  • INFO: LogLevel = ...
    @@ -181,12 +181,12 @@
    +
  • Defined in src/framework/util/log/level.ts:31
  • LEVELS: Map<string, LogLevel> = ...
    +
  • Defined in src/framework/util/log/level.ts:58
  • OFF: LogLevel = ...
    @@ -194,7 +194,7 @@
    +
  • Defined in src/framework/util/log/level.ts:14
  • WARN: LogLevel = ...
    @@ -202,7 +202,7 @@
    +
  • Defined in src/framework/util/log/level.ts:40
  • Methods

    @@ -217,7 +217,7 @@

    Parameters

    label: string

    Returns undefined | LogLevel

    +
  • Defined in src/framework/util/log/level.ts:85
  • @@ -229,7 +229,7 @@
    label: defaultLevel: LogLevel
  • Returns LogLevel

    +
  • Defined in src/framework/util/log/level.ts:86
  • +
  • Defined in src/framework/util/log/logger.ts:44
  • name: string
    @@ -137,17 +137,17 @@
    +
  • Defined in src/framework/util/log/logger.ts:42
  • seenWarnings: Set<string> = ...
    +
  • Defined in src/framework/util/log/logger.ts:15
  • globalLevel: LogLevel = ...
    +
  • Defined in src/framework/util/log/logger.ts:14
  • Methods

    @@ -167,7 +167,7 @@
    Rest Returns void
    +
  • Defined in src/framework/util/log/logger.ts:92
  • +
  • Defined in src/framework/util/log/logger.ts:128
  • +
  • Defined in src/framework/util/log/logger.ts:57
  • +
  • Defined in src/framework/util/log/logger.ts:50
  • +
  • Defined in src/framework/util/log/logger.ts:100
  • +
  • Defined in src/framework/util/log/logger.ts:72
  • +
  • Defined in src/framework/util/log/logger.ts:80
  • Log data with given level.

    @@ -291,7 +291,7 @@
    Rest Returns void
  • +
  • Defined in src/framework/util/log/logger.ts:142
  • +
  • Defined in src/framework/util/log/logger.ts:65
  • +
  • Defined in src/framework/util/log/logger.ts:108
  • +
  • Defined in src/framework/util/log/logger.ts:116
  • +
  • Defined in src/framework/util/log/logger.ts:20
  • +
  • Defined in src/framework/util/log/logger.ts:29
  • +
  • Defined in src/framework/contrib/tool-views.ts:120
  • +
  • Defined in src/framework/contrib/commands.ts:118
  • +
  • Defined in src/framework/contrib/configuration.ts:107
  • +
  • Defined in src/framework/contrib/configuration.ts:111
  • +
  • Defined in src/framework/contrib/configuration.ts:119
  • +
  • Defined in src/framework/contrib/data-views.ts:104
  • +
  • Defined in src/framework/contrib/configuration.ts:100
  • +
  • Defined in src/framework/contrib/commands.ts:111
  • +
  • Defined in src/framework/contrib/register.ts:36
  • +
  • Defined in src/framework/contrib/data-views.ts:93
  • +
  • Defined in src/framework/contrib/status-bar-items.ts:33
  • +
  • Defined in src/framework/contrib/stores.ts:22
  • +
  • Defined in src/framework/contrib/tool-views.ts:99
  • +
  • Defined in src/framework/contrib/command-palette.ts:25
  • +
  • Defined in src/framework/contrib/commands.ts:99
  • +
  • Defined in src/framework/contrib/configuration.ts:370
  • +
  • Defined in src/framework/contrib/configuration.ts:169
  • +
  • Defined in src/framework/contrib/configuration.ts:128
  • +
  • Defined in src/framework/contrib/data-views.ts:84
  • +
  • Defined in src/framework/contrib/data-views.ts:80
  • +
  • Defined in src/framework/contrib/configuration.ts:89
  • +
  • Defined in src/framework/contrib/keybindings.ts:94
  • +
  • Defined in src/framework/contrib/menus.ts:127
  • +
  • Defined in src/framework/contrib/status-bar-items.ts:43
  • +
  • Defined in src/framework/contrib/stores.ts:35
  • +
  • Defined in src/framework/contrib/submenus.ts:53
  • +
  • Defined in src/framework/contrib/tool-views.ts:106
  • +
  • Defined in src/framework/contrib/tool-views.ts:88
  • +
  • Defined in src/framework/core/contrib-point/when.ts:61
  • +
  • Defined in src/framework/core/contrib-point/get.ts:33
  • +
  • Defined in src/framework/core/contrib-point/get.ts:55
  • +
  • Defined in src/framework/core/contrib-point/get.ts:88
  • +
  • Defined in src/framework/core/extension/get.ts:29
  • +
  • Defined in src/framework/core/code-contrib/load.ts:24
  • +
  • Defined in src/framework/core/code-contrib/register.ts:26
  • +
  • Defined in src/framework/core/contrib-point/register.ts:18
  • +
  • Defined in src/framework/core/extension/register.ts:39
  • +
  • Defined in src/framework/core/config.ts:24
  • +
  • Defined in src/framework/react/hooks.ts:106
  • +
  • Defined in src/framework/react/hooks.ts:69
  • +
  • Defined in src/framework/react/hooks.ts:53
  • +
  • Defined in src/framework/react/hooks.ts:119
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:45
  • @@ -159,7 +159,7 @@
    x3: Returns Result
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:50
  • @@ -209,7 +209,7 @@
    x4: Returns Result
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:56
  • @@ -265,7 +265,7 @@
    x5: Returns Result
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:63
  • @@ -327,7 +327,7 @@
    x6: Returns Result
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:71
  • @@ -395,7 +395,7 @@
    x7: Returns Result
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:80
  • @@ -469,7 +469,7 @@
    x8: Returns Result
  • Returns Selector<State, Result>

    +
  • Defined in src/framework/util/selector.ts:98
  • Returns number

    +
  • Defined in src/framework/util/json/ui-schema.ts:154
  • @@ -47,7 +47,7 @@

    Parameters

    schema: StringUiSchema
  • Returns string

    +
  • Defined in src/framework/util/json/ui-schema.ts:155
  • @@ -57,7 +57,7 @@

    Parameters

    schema: TupleUiSchema
  • Returns TupleUiValue

    +
  • Defined in src/framework/util/json/ui-schema.ts:156
  • @@ -67,7 +67,7 @@

    Parameters

    schema: ListUiSchema
  • Returns ListUiValue

    +
  • Defined in src/framework/util/json/ui-schema.ts:157
  • @@ -77,7 +77,7 @@

    Parameters

    schema: ObjectUiSchema
  • Returns ObjectUiValue

    +
  • Defined in src/framework/util/json/ui-schema.ts:158
  • @@ -87,7 +87,7 @@

    Parameters

    schema: UiSchema
  • Returns UiValue

    +
  • Defined in src/framework/util/json/ui-schema.ts:159
  • +
  • Defined in src/framework/util/json/ui-schema.ts:131
  • +
  • Defined in src/framework/util/json/ui-schema.ts:134
  • +
  • Defined in src/framework/util/json/ui-schema.ts:146
  • +
  • Defined in src/framework/util/json/ui-schema.ts:137
  • +
  • Defined in src/framework/util/json/ui-schema.ts:149
  • +
  • Defined in src/framework/util/json/ui-schema.ts:140
  • +
  • Defined in src/framework/util/json/ui-schema.ts:143
  • import { type ExtensionContext, getExtension } from "@forman2/extendit";
    import { type MyApi } from "@my-company/my-extension";

    export function activate(ctx: ExtensionContext) {
    const myExtension = getExtension("my-company.my-extension");
    const myApi = myExtension.exports as MyApi;
    // Use imported extension API here, e.g., to add some contribution
    myApi.registerViewProvider({ ... });
    }

    The host application registers extensions using the +readExtensionManifest +and registerExtension -function:

    -
    import { registerExtension } from "@forman2/extendit";

    export function initApp() {
    const extensionsUrls = getAppExtensionUrls();
    extensionUrls.forEach((extensionUrl) => {
    void registerExtension(extensionUrl);
    });
    }

    function getAppExtensionUrls(): URL[] {
    // ...
    } +functions:

    +
    import { readExtensionManifest, registerExtension } from "@forman2/extendit";

    export function initApp() {
    const extensionsUrls = getAppExtensionUrls();
    extensionUrls.forEach((extensionUrl) => {
    readExtensionManifest(extensionUrl)
    .then((manifest) =>
    registerExtension(manifest)
    )
    .catch((error) => {
    // ...
    });
    });
    }

    function getAppExtensionUrls(): URL[] {
    // ...
    }

    The host application (or an extension) can also define handy contribution points:

    @@ -118,21 +121,12 @@

    @forman2/extendit

    import { loadCodeContribution } from "@forman2/extendit";
    import { type Command } from "./command";

    async function getCommand(commandId: string): Promise<Command> {
    return await loadCodeContribution<Command>("commands", commandId);
    }

    There is also a corresponding React hook -useLoadCodeContribution +useLoadCodeContribution that is used for implementing React components:

    import { useLoadCodeContribution } from "@forman2/extendit/react";
    import { type Command } from "./command";

    interface CommandButtonProps {
    command: Command;
    }

    export default function CommandButton({ command }: CommandButtonProps) {
    const commandCode = useLoadCodeContribution("commands", command.id);
    return (
    <button
    onClick={commandCode.data}
    disabled={commandCode.loading || commandCode.error}
    >
    {command.title}
    </button>
    );
    }

    Documentation

    We currently only have this file and the API docs, sorry.

    -

    Acknowledgements

    ExtendIt.js currently uses the awesome libraries

    -
      -
    • Ajv for JSON validation (may be turned into peer dependency later)
    • -
    • memoize-one for implementing state selector functions
    • -
    • zustand for state management
    • -
    -

    License

    Copyright © 2023 Norman Fomferra

    -

    Permissions are hereby granted under the terms of the MIT License: -https://opensource.org/licenses/MIT.

    Development

    Source Code

    Get sources and install dependencies first:

    $ git clone https://github.com/forman/extendit
    $ cd extendit
    $ npm install
    @@ -164,6 +158,15 @@

    @forman2/extendit

    If we also have resource dependencies (*.css, *.json, *.svg, ...), we first import TypeScript source dependencies, then separated by a newline, insert resource dependencies in the same order as source dependencies.

    +

    Acknowledgements

    ExtendIt.js currently uses the awesome libraries

    +
      +
    • Ajv for JSON validation (may be turned into peer dependency later)
    • +
    • memoize-one for implementing state selector functions
    • +
    • zustand for state management
    • +
    +

    License

    Copyright © 2023 Norman Fomferra

    +

    Permissions are hereby granted under the terms of the MIT License: +https://opensource.org/licenses/MIT.

    +
  • Coding style
  • +
  • Acknowledgements
  • +
  • License
  • +
  • Defined in src/framework/contrib/commands.ts:25
  • checked?: When
    +
  • Defined in src/framework/contrib/commands.ts:37
  • command: string
    +
  • Defined in src/framework/contrib/commands.ts:23
  • enablement?: When
    +
  • Defined in src/framework/contrib/commands.ts:36
  • icon?: string
    +
  • Defined in src/framework/contrib/commands.ts:27
  • title?: string
    +
  • Defined in src/framework/contrib/commands.ts:24
  • tooltip?: string
    +
  • Defined in src/framework/contrib/commands.ts:26
  • +
  • Defined in src/framework/contrib/commands.ts:26
  • +
  • Defined in src/framework/contrib/menus.ts:44
  • +
  • Defined in src/framework/contrib/configuration.ts:358
  • +
  • Defined in src/framework/contrib/configuration.ts:362
  • +
  • Defined in src/framework/contrib/data-views.ts:21
  • +
  • Defined in src/framework/contrib/data-views.ts:43
  • +
  • Defined in src/framework/contrib/data-views.ts:21
  • +
  • Defined in src/framework/contrib/keybindings.ts:30
  • +
  • Defined in src/framework/contrib/keybindings.ts:26
  • +
  • Defined in src/framework/contrib/menus.ts:26
  • +
  • Defined in src/framework/contrib/menus.ts:37
  • +
  • Defined in src/framework/contrib/submenus.ts:17
  • +
  • Defined in src/framework/contrib/tool-views.ts:28
  • +
  • Defined in src/framework/core/types.ts:289
  • +
  • Defined in src/framework/core/types.ts:133
  • deactivate?: ((extensionContext) => void | Promise<void>)
    @@ -90,7 +90,7 @@

    Parameters

    extensionContext: ExtensionContext

    Returns void | Promise<void>

    +
  • Defined in src/framework/core/types.ts:138
  • +
  • Defined in src/framework/core/types.ts:235
  • schema: AnySchema | JsonTypedSchema<TM>
    @@ -89,7 +89,7 @@
    +
  • Defined in src/framework/core/types.ts:226
  • +
  • Defined in src/framework/core/types.ts:317
  • +
  • Defined in src/framework/util/json/ui-schema.ts:65
  • +
  • Defined in src/framework/util/disposable.ts:11
  • +
  • Defined in src/framework/util/json/ui-schema.ts:69
  • +
  • Defined in src/framework/util/json/ui-schema.ts:79
  • +
  • Defined in src/framework/core/index.ts:1
  • Index

    diff --git a/docs/modules/react.html b/docs/modules/react.html index b0b7cb0..f896826 100644 --- a/docs/modules/react.html +++ b/docs/modules/react.html @@ -16,7 +16,7 @@
  • react
  • Module react

    +
  • Defined in src/framework/react/index.ts:1
  • Index

    diff --git a/docs/modules/util.expr.html b/docs/modules/util.expr.html index 5f2b40c..0c6dd03 100644 --- a/docs/modules/util.expr.html +++ b/docs/modules/util.expr.html @@ -17,7 +17,7 @@
  • expr
  • Namespace expr

    +
  • Defined in src/framework/util/expr/index.ts:1
  • Index

    diff --git a/docs/modules/util.html b/docs/modules/util.html index 35feef4..366b629 100644 --- a/docs/modules/util.html +++ b/docs/modules/util.html @@ -16,7 +16,7 @@
  • util
  • Module util

    +
  • Defined in src/framework/util/index.ts:1
  • Index

    diff --git a/docs/modules/util.log.html b/docs/modules/util.log.html index d39e4e0..86d9f13 100644 --- a/docs/modules/util.log.html +++ b/docs/modules/util.log.html @@ -17,7 +17,7 @@
  • log
  • Namespace log

    +
  • Defined in src/framework/util/log/index.ts:1
  • Index

    diff --git a/docs/types/contrib.CommandFn.html b/docs/types/contrib.CommandFn.html index 4e60451..5a0203b 100644 --- a/docs/types/contrib.CommandFn.html +++ b/docs/types/contrib.CommandFn.html @@ -38,7 +38,7 @@

    Parameters

    Rest ...args: A
    Rest

    Returns T

    +
  • Defined in src/framework/contrib/commands.ts:95
  • +
  • Defined in src/framework/contrib/configuration.ts:32
  • +
  • Defined in src/framework/contrib/configuration.ts:366
  • +
  • Defined in src/framework/contrib/configuration.ts:33
  • +
  • Defined in src/framework/core/types.ts:324
  • +
  • Defined in src/framework/core/types.ts:42
  • +
  • Defined in src/framework/util/json/json.ts:38
  • +
  • Defined in src/framework/util/json/json-meta-schema.ts:17
  • +
  • Defined in src/framework/util/json/json-schema.ts:9
  • +
  • Defined in src/framework/util/json/json.ts:13
  • +
  • Defined in src/framework/util/json/ui-schema.ts:28
  • +
  • Defined in src/framework/util/json/ui-schema.ts:16
  • +
  • Defined in src/framework/util/json/ui-schema.ts:88
  • +
  • Defined in src/framework/util/json/ui-schema.ts:10
  • +
  • Defined in src/framework/util/selector.ts:17
  • +
  • Defined in src/framework/util/json/ui-schema.ts:22
  • +
  • Defined in src/framework/util/json/ui-schema.ts:125
  • +
  • Defined in src/framework/util/json/ui-schema.ts:38
  • +
  • Defined in src/framework/util/expr/node.ts:12
  • +
  • Defined in src/framework/contrib/commands.ts:80
  • +
  • Defined in src/framework/contrib/configuration.ts:74
  • +
  • Defined in src/framework/contrib/data-views.ts:69
  • +
  • Defined in src/framework/contrib/status-bar-items.ts:26
  • +
  • Defined in src/framework/contrib/stores.ts:17
  • +
  • Defined in src/framework/contrib/submenus.ts:46
  • +
  • Defined in src/framework/contrib/tool-views.ts:63
  • +
  • Defined in src/framework/util/json/json-meta-schema.ts:9