Skip to content

Commit

Permalink
feat(LocalStorage/SessionStorage): add "hasItem", "removeItem", "setI…
Browse files Browse the repository at this point in the history
…tem" aliases (matches web storage specs) #17109
  • Loading branch information
rstoenescu committed Apr 16, 2024
1 parent 195e915 commit e0c9514
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 92 deletions.
5 changes: 4 additions & 1 deletion docs/src/components/DocApiEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,15 @@ describe.methods = (openState, methods) => {
const method = methods[ methodName ]
const masterKey = `method|${ methodName }`

const alias = method.alias ? `Alias: "${ method.alias }"; ` : ''
const desc = `${ alias }${ method.desc }`

const methodNode = h('div', { class: 'doc-api-entry row' }, [
getNameDiv(method, methodName, 0, `${ getMethodParams(method) }${ getMethodReturnValue(method) }`),

...getExpandable(
openState,
method.desc,
desc,
method.params !== void 0 || method.returns !== void 0,
masterKey,
() => {
Expand Down
64 changes: 43 additions & 21 deletions ui/build/build.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,27 @@ const nativeTypes = [ 'Component', 'Error', 'Element', 'File', 'FileList', 'Even

const objectTypes = {
Boolean: {
props: [ 'tsInjectionPoint', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'default', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
props: [ 'tsInjectionPoint', 'tsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'default', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isArray: [ 'examples' ]
isArray: [ 'examples' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

String: {
props: [ 'tsInjectionPoint', 'tsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'values', 'default', 'examples', 'category', 'addedIn', 'transformAssetUrls', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'transformAssetUrls', 'internal', 'passthrough' ],
isArray: [ 'examples', 'values' ]
isArray: [ 'examples', 'values' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

Number: {
props: [ 'tsInjectionPoint', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'values', 'default', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
props: [ 'tsInjectionPoint', 'tsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'values', 'default', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isArray: [ 'examples', 'values' ]
isArray: [ 'examples', 'values' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

Object: {
Expand All @@ -98,39 +101,44 @@ const objectTypes = {
recursive: [ 'definition' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isObject: [ 'definition' ],
isArray: [ 'examples', 'values' ]
isArray: [ 'examples', 'values' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

Array: {
props: [ 'tsInjectionPoint', 'tsType', 'autoDefineTsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'values', 'default', 'definition', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isObject: [ 'definition' ],
isArray: [ 'examples', 'values' ]
isArray: [ 'examples', 'values' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

Promise: {
props: [ 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'default', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
props: [ 'tsInjectionPoint', 'tsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'default', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isObject: [ 'definition' ],
isArray: [ 'examples' ]
isArray: [ 'examples' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

Function: {
props: [ 'tsInjectionPoint', 'tsType', 'autoDefineTsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'default', 'params', 'returns', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc', 'params', 'returns' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isObject: [ 'params', 'returns' ],
isArray: [ 'examples' ]
isArray: [ 'examples' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

MultipleTypes: {
props: [ 'tsInjectionPoint', 'tsType', 'autoDefineTsType', 'desc', 'required', 'reactive', 'sync', 'syncable', 'link', 'values', 'default', 'definition', 'params', 'returns', 'examples', 'category', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'tsInjectionPoint', 'required', 'reactive', 'sync', 'syncable', 'passthrough', 'internal' ],
isObject: [ 'definition', 'params', 'returns' ],
isArray: [ 'examples', 'values' ]
isArray: [ 'examples', 'values' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
},

meta: {
Expand All @@ -140,48 +148,54 @@ const objectTypes = {

// component only
slots: {
props: [ 'desc', 'link', 'scope', 'addedIn', 'internal' ],
props: [ 'tsType', 'desc', 'link', 'scope', 'addedIn', 'internal' ],
required: [ 'desc' ],
isObject: [ 'scope' ],
isBoolean: [ 'internal' ]
isBoolean: [ 'internal' ],
isString: [ 'tsType', 'desc', 'addedIn' ]
},

// component only
events: {
props: [ 'desc', 'link', 'params', 'addedIn', 'passthrough', 'internal' ],
props: [ 'tsType', 'desc', 'link', 'params', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isObject: [ 'params' ],
isBoolean: [ 'passthrough', 'internal' ]
isBoolean: [ 'passthrough', 'internal' ],
isString: [ 'tsType', 'desc', 'addedIn' ]
},

// component only
computedProps: {
props: [ 'desc', 'tsType', 'examples', 'addedIn', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'internal' ],
isArray: [ 'examples' ]
isArray: [ 'examples' ],
isString: [ 'tsType', 'desc', 'addedIn' ]
},

methods: {
props: [ 'tsInjectionPoint', 'tsType', 'desc', 'link', 'params', 'returns', 'addedIn' ],
props: [ 'tsInjectionPoint', 'tsType', 'desc', 'link', 'params', 'returns', 'addedIn', 'alias' ],
required: [ 'desc', 'params', 'returns' ],
isBoolean: [ 'tsInjectionPoint' ],
isObject: [ 'params', 'returns' ]
isObject: [ 'params', 'returns' ],
isString: [ 'tsType', 'desc', 'link', 'addedIn', 'alias' ]
},

quasarConfOptions: {
props: [ 'propName', 'definition', 'values', 'tsType', 'desc', 'examples', 'link', 'addedIn' ],
props: [ 'tsType', 'desc', 'propName', 'definition', 'values', 'examples', 'link', 'addedIn' ],
required: [ 'propName' ],
isObject: [ 'definition' ],
isArray: [ 'values' ]
isArray: [ 'values' ],
isString: [ 'tsType', 'desc', 'addedIn' ]
}
}

nativeTypes.forEach(name => {
objectTypes[ name ] = {
props: [ 'tsType', 'desc', 'required', 'category', 'examples', 'addedIn', 'passthrough', 'internal' ],
required: [ 'desc' ],
isBoolean: [ 'passthrough', 'internal' ]
isBoolean: [ 'passthrough', 'internal' ],
isString: [ 'tsType', 'desc', 'category', 'addedIn' ]
}
})

Expand Down Expand Up @@ -425,6 +439,14 @@ function parseObject ({ banner, api, itemName, masterType, verifyCategory, verif
process.exit(1)
}
})
def.isString && def.isString.forEach(prop => {
if (obj[ prop ] && typeof obj[ prop ] !== 'string') {
logError(`${ banner }/"${ prop }" is not a String`)
console.error(obj)
console.log()
process.exit(1)
}
})

if (obj.default !== void 0 && obj.required === true) {
logError(`${ banner } cannot have "required" as true since it is optional because it has "default"`)
Expand Down
12 changes: 12 additions & 0 deletions ui/build/build.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,18 @@ function getIndexDts (apis, quasarLangIndex) {
prop.type = 'Function'
})

if (content.type === 'plugin') {
Object.keys(content.methods).forEach(methodName => {
const method = content.methods[ methodName ]
if (method.alias) {
content.methods[ method.alias ] = {
...method,
desc: `(Alias of "${ methodName }") ${ method.desc }`
}
}
})
}

// computedProps should always be required
content.computedProps = transformObject(content.computedProps, makeRequired)

Expand Down
Loading

0 comments on commit e0c9514

Please sign in to comment.