Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added extension-load-queue #8

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.DS_Store
node_modules
/lib
/react

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is extra at this point

/dist
/build
/cache
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
extends: require.resolve('@diplodoc/lint/eslint-config'),
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json', './tsconfig.tests.json'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will be deleted every time by a pre-commit hook

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will change it in @diplodoc/lint package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, I went another way - I created an alternative TS configuration for the build.

project: ['./tsconfig.json'],
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.DS_Store
node_modules
/lib
/react
/dist
/build
/cache
Expand Down
45 changes: 33 additions & 12 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The Diplodoc ecosystem consists of many packages that have similar problems and
## Table of contents

- [AttrsParser](#AttrsParser)
- [Extension Load Queue](#Extension Load Queue)

### AttrsParser

Expand All @@ -21,17 +22,37 @@ Support [markdown-it-attrs](https://github.com/arve0/markdown-it-attrs)-like att
### Interface

```typescript
/*
optional first query
if provided parser will parse it immediately
each 'parse' call is pure
*/
const attrs = new AttrsParser('{.class #id data-name=diplodoc}');

attrs.state /* { class: ['class'], id: ['id'], 'data-name': ['diplodoc'] } */

const other = attrs.parse('{data-wide title="Support quotes too"}')

other /* { attr: ['data-wide'], title: ['Support quotes too'] } */
/*
optional first query
if provided parser will parse it immediately
each 'parse' call is pure
*/
const attrs = new AttrsParser('{.class #id data-name=diplodoc}');

attrs.state /* { class: ['class'], id: ['id'], 'data-name': ['diplodoc'] } */

const other = attrs.parse('{data-wide title="Support quotes too"}')

other /* { attr: ['data-wide'], title: ['Support quotes too'] } */
```

### Extension Load Queue

### Purpose

This queue mechanism allows asynchronous loading of extensions by setting a property on the "window" object in the browser. This property has a Symbol data type, which makes it difficult for external manipulations to access it.

### Interface

```typescript
// create a unique symbol
export const GLOBAL_SYMBOL: unique symbol = Symbol.for('someController');

// get the store
const store = getScriptStore<SomeController>(GLOBAL_SYMBOL);

// get the controller
const controller = useController<SomeController>(store);
```

See example in [diplodoc-platform/html-extension](https://github.com/diplodoc-platform/html-extension/blob/main/src/react/useDiplodocHtml.ts)
Loading
Loading