Skip to content

Commit

Permalink
chore(docs): v0.9.4 API docs & examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Freiburger committed Jan 29, 2024
1 parent 4e48c3e commit 6591f22
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 84 deletions.
93 changes: 47 additions & 46 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
* [buildTemplateProcessor](README.md#buildtemplateprocessor)
* [createSFCModule](README.md#createsfcmodule)
* [defaultGetResource](README.md#defaultgetresource)
* [defaultHandleModule](README.md#defaulthandlemodule)
* [defaultPathResolve](README.md#defaultpathresolve)
* [handleModuleInternal](README.md#handlemoduleinternal)
* [loadModule](README.md#loadmodule)
* [loadModuleInternal](README.md#loadmoduleinternal)

Expand All @@ -49,7 +49,7 @@

Ƭ **AbstractPath**: { toString: () => string }

*Defined in [types.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L32)*
*Defined in [types.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L32)*

An abstract way to specify a path. It could be a simple string or a object like an URL. An AbstractPath must always be convertible to a string.

Expand All @@ -65,7 +65,7 @@ ___

Ƭ **Cache**: { get: (key: string) => Promise<string \| undefined\> ; set: (key: string, value: string) => Promise<void\> }

*Defined in [types.ts:20](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L20)*
*Defined in [types.ts:20](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L20)*

#### Type declaration:

Expand All @@ -80,15 +80,15 @@ ___

Ƭ **ContentData**: string \| ArrayBuffer

*Defined in [types.ts:71](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L71)*
*Defined in [types.ts:71](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L71)*

___

### CustomBlock

Ƭ **CustomBlock**: { attrs: Record<string, string \| true\> ; content: string ; type: string }

*Defined in [types.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L109)*
*Defined in [types.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L109)*

A custom block

Expand All @@ -106,7 +106,7 @@ ___

Ƭ **CustomBlockCallback**: (component: [ModuleExport](README.md#moduleexport)) => void

*Defined in [types.ts:103](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L103)*
*Defined in [types.ts:103](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L103)*

CustomBlockCallback function type

Expand All @@ -116,7 +116,7 @@ ___

Ƭ **File**: { getContentData: (asBinary: Boolean) => Promise<[ContentData](README.md#contentdata)\> ; type: string }

*Defined in [types.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L77)*
*Defined in [types.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L77)*

Represents a file content and the extension name.

Expand All @@ -133,15 +133,15 @@ ___

Ƭ **LangProcessor**: (source: string, preprocessOptions?: any) => Promise<string\> \| string

*Defined in [types.ts:429](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L429)*
*Defined in [types.ts:439](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L439)*

___

### Module

Ƭ **Module**: { exports: [ModuleExport](README.md#moduleexport) }

*Defined in [types.ts:128](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L128)*
*Defined in [types.ts:128](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L128)*

This just represents a loaded js module

Expand All @@ -157,15 +157,15 @@ ___

Ƭ **ModuleCacheId**: string

*Defined in [types.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L26)*
*Defined in [types.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L26)*

___

### ModuleExport

Ƭ **ModuleExport**: {} \| null

*Defined in [types.ts:123](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L123)*
*Defined in [types.ts:123](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L123)*

This just represents a loaded js module exports

Expand All @@ -175,7 +175,7 @@ ___

Ƭ **ModuleHandler**: (type: string, getContentData: File[\"getContentData\"], path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| null\>

*Defined in [types.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L68)*
*Defined in [types.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L68)*

Used by the library when it needs to handle a does not know how to handle a given file type (eg. `.json` files).

Expand All @@ -198,9 +198,9 @@ ___

### Options

Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record<string, any\> ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; devMode?: boolean ; handleModule?: [ModuleHandler](README.md#modulehandler) ; isCustomElement: (tag: string) => boolean \| undefined ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; whitespace?: \"preserve\" \| \"condense\" ; addStyle: (style: string, scopeId: string \| undefined) => void ; createCJSModule: (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void }
Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record<string, any\> ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; devMode?: boolean ; handleModule?: [ModuleHandler](README.md#modulehandler) ; isCustomElement: (tag: string) => boolean \| undefined ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; whitespace?: \"preserve\" \| \"condense\" ; addStyle: (style: string, scopeId: string \| undefined) => void ; createCJSModule: (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void ; processStyles: (srcRaw: string, lang: string \| undefined, filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<string\> }

*Defined in [types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L139)*
*Defined in [types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L139)*

#### Type declaration:

Expand All @@ -214,7 +214,7 @@ Name | Type | Description |
`handleModule?` | [ModuleHandler](README.md#modulehandler) | Handle additional module types (eg. '.svg', '.json' ). see [ModuleHandler](README.md#modulehandler) |
`isCustomElement` | (tag: string) => boolean \| undefined | Specifies a check method to recognize native custom elements. see. https://vuejs.org/api/application.html#app-config-compileroptions-iscustomelement note: this option has no effect on vue2 |
`moduleCache` | Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> | Initial cache that will contain resolved dependencies. All new modules go here. `vue` must initially be contained in this object. [moduleCache](README.md#modulecache) is mandatory and should be shared between options objects used for you application (note that you can also pass the same options object through multiple loadModule calls) It is recommended to provide a prototype-less object (`Object.create(null)`) to avoid potential conflict with `Object` properties (constructor, __proto__, hasOwnProperty, ...). ​ * The library take the ownership of [moduleCache](README.md#modulecache) when [loadModule](README.md#loadmodule) is called. See also [[options.loadModule]]. **example:** ```javascript ... moduleCache: Object.assign(Object.create(null), { vue: Vue, }), ... ``` |
`pathResolve` | [PathResolve](README.md#pathresolve) | Abstact path handling |
`pathResolve` | [PathResolve](README.md#pathresolve) | Abstact path handling *(optional)* |
`whitespace?` | \"preserve\" \| \"condense\" | Whitespace handling strategy see https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options |
`addStyle` | (style: string, scopeId: string \| undefined) => void | - |
`createCJSModule` | (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) | - |
Expand All @@ -223,14 +223,15 @@ Name | Type | Description |
`getResource` | (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) | - |
`loadModule?` | (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> | - |
`log?` | (type: string, ...data: any[]) => void | - |
`processStyles` | (srcRaw: string, lang: string \| undefined, filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<string\> | - |

___

### PathContext

Ƭ **PathContext**: { refPath: [AbstractPath](README.md#abstractpath) \| undefined ; relPath: [AbstractPath](README.md#abstractpath) }

*Defined in [types.ts:41](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L41)*
*Defined in [types.ts:41](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L41)*

A PathContext represents a path (relPath) relative to an abolute path (refPath)
Note that relPath is not necessary relative, but when it is, relPath is relative to refPath.
Expand All @@ -248,7 +249,7 @@ ___

Ƭ **PathResolve**: (pathCx: [PathContext](README.md#pathcontext)) => [AbstractPath](README.md#abstractpath)

*Defined in [types.ts:50](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L50)*
*Defined in [types.ts:50](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L50)*

relative to absolute module path resolution

Expand All @@ -258,7 +259,7 @@ ___

Ƭ **Resource**: { getContent: () => Promise<[File](README.md#file)\> ; id: [ModuleCacheId](README.md#modulecacheid) ; path: [AbstractPath](README.md#abstractpath) }

*Defined in [types.ts:88](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L88)*
*Defined in [types.ts:88](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L88)*

Represents a resource.

Expand All @@ -276,9 +277,9 @@ Name | Type | Description |

`Const` **version**: string = process.env.VERSION as string

*Defined in [tools.ts:49](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L49)*
*Defined in [tools.ts:49](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L49)*

*Defined in [index.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L26)*
*Defined in [index.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L26)*

the version of the library (process.env.VERSION is set by webpack, at compile-time)

Expand All @@ -288,7 +289,7 @@ ___

`Const` **vueVersion**: string = process.env.VUE\_VERSION as string

*Defined in [index.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L32)*
*Defined in [index.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L32)*

the version of Vue that is expected by the library

Expand All @@ -298,7 +299,7 @@ the version of Vue that is expected by the library

**buildTemplateProcessor**(`processor`: [LangProcessor](README.md#langprocessor)): object

*Defined in [index.ts:194](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L194)*
*Defined in [index.ts:194](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L194)*

Convert a function to template processor interface (consolidate)

Expand All @@ -320,7 +321,7 @@ ___

**createSFCModule**(`source`: string, `filename`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>

*Defined in [createSFCModule.ts:3](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/createSFCModule.ts#L3)*
*Defined in [createSFCModule.ts:3](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/createSFCModule.ts#L3)*

#### Parameters:

Expand All @@ -338,7 +339,7 @@ ___

**defaultGetResource**(`pathCx`: [PathContext](README.md#pathcontext), `options`: [Options](README.md#options)): [Resource](README.md#resource)

*Defined in [index.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L74)*
*Defined in [index.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L74)*

Default getResource implementation
by default, getContent() use the file extension as file type.
Expand All @@ -354,54 +355,54 @@ Name | Type |

___

### defaultHandleModule
### defaultPathResolve

**defaultHandleModule**(`type`: string, `getContentData`: File[\"getContentData\"], `path`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
`Const`**defaultPathResolve**(`__namedParameters`: { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) }): string \| [AbstractPath](README.md#abstractpath)

*Defined in [tools.ts:399](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L399)*
*Defined in [index.ts:51](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L51)*

Default implementation of handleModule
Default resolve implementation
resolve() should handle 3 situations :
- resolve a relative path ( eg. import './details.vue' )
- resolve an absolute path ( eg. import '/components/card.vue' )
- resolve a module name ( eg. import { format } from 'date-fns' )

#### Parameters:

Name | Type |
------ | ------ |
`type` | string |
`getContentData` | File[\"getContentData\"] |
`path` | [AbstractPath](README.md#abstractpath) |
`options` | [Options](README.md#options) |
`__namedParameters` | { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) } |

**Returns:** Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
**Returns:** string \| [AbstractPath](README.md#abstractpath)

___

### defaultPathResolve
### handleModuleInternal

`Const`**defaultPathResolve**(`__namedParameters`: { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) }): string \| [AbstractPath](README.md#abstractpath)
**handleModuleInternal**(`type`: string, `getContentData`: File[\"getContentData\"], `path`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport) \| undefined\>

*Defined in [index.ts:51](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L51)*
*Defined in [tools.ts:399](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L399)*

Default resolve implementation
resolve() should handle 3 situations :
- resolve a relative path ( eg. import './details.vue' )
- resolve an absolute path ( eg. import '/components/card.vue' )
- resolve a module name ( eg. import { format } from 'date-fns' )
Default implementation of handleModule

#### Parameters:

Name | Type |
------ | ------ |
`__namedParameters` | { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) } |
`type` | string |
`getContentData` | File[\"getContentData\"] |
`path` | [AbstractPath](README.md#abstractpath) |
`options` | [Options](README.md#options) |

**Returns:** string \| [AbstractPath](README.md#abstractpath)
**Returns:** Promise<[ModuleExport](README.md#moduleexport) \| undefined\>

___

### loadModule

**loadModule**(`path`: [AbstractPath](README.md#abstractpath), `options?`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>

*Defined in [index.ts:155](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L155)*
*Defined in [index.ts:155](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L155)*

This is the main function.
This function is intended to be used only to load the entry point of your application.
Expand Down Expand Up @@ -455,7 +456,7 @@ ___

**loadModuleInternal**(`pathCx`: [PathContext](README.md#pathcontext), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>

*Defined in [tools.ts:276](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L276)*
*Defined in [tools.ts:276](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L276)*

#### Parameters:

Expand All @@ -472,6 +473,6 @@ Name | Type |

`Const` **targetBrowserBabelPlugins**: object

*Defined in [tools.ts:211](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L211)*
*Defined in [tools.ts:211](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L211)*

#### Properties:
Loading

0 comments on commit 6591f22

Please sign in to comment.