From 358ba00a97a34cebfe0b916006f926e265f38343 Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Mon, 25 Nov 2024 15:02:23 -0800 Subject: [PATCH] fix(enhanced): update share options of share plugin --- .../plugins/sharing/SharePlugin.d.ts | 8 +- .../enhanced/src/lib/sharing/SharePlugin.ts | 6 +- .../sharing/ConsumeSharedPlugin.check.js | 357 ------------------ .../sharing/ConsumeSharedPlugin.check.ts | 2 +- .../schemas/sharing/ConsumeSharedPlugin.json | 133 ------- 5 files changed, 11 insertions(+), 495 deletions(-) delete mode 100644 packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.js delete mode 100644 packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.json diff --git a/packages/enhanced/src/declarations/plugins/sharing/SharePlugin.d.ts b/packages/enhanced/src/declarations/plugins/sharing/SharePlugin.d.ts index 8172bed1638..ff730f0a323 100644 --- a/packages/enhanced/src/declarations/plugins/sharing/SharePlugin.d.ts +++ b/packages/enhanced/src/declarations/plugins/sharing/SharePlugin.d.ts @@ -76,7 +76,11 @@ export interface SharedConfig { */ version?: false | string; /** - * Share a specific layer of the module, if the module supports layers. + * Issuer layer in which the module should be resolved. */ - layer?: string; + issuerLayer?: string; + /** + * Required layer for the shared module. + */ + requiredLayer?: string; } diff --git a/packages/enhanced/src/lib/sharing/SharePlugin.ts b/packages/enhanced/src/lib/sharing/SharePlugin.ts index 06678dc7d79..1b8edb4e9c7 100644 --- a/packages/enhanced/src/lib/sharing/SharePlugin.ts +++ b/packages/enhanced/src/lib/sharing/SharePlugin.ts @@ -52,7 +52,8 @@ class SharePlugin { singleton: options.singleton, packageName: options.packageName, eager: options.eager, - layer: options.layer, + issuerLayer: options.issuerLayer, + requiredLayer: options.requiredLayer, }, }), ); @@ -67,7 +68,8 @@ class SharePlugin { requiredVersion: options.requiredVersion, strictVersion: options.strictVersion, singleton: options.singleton, - layer: options.layer, + issuerLayer: options.issuerLayer, + requiredLayer: options.requiredLayer, }, })); //@ts-ignore diff --git a/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.js b/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.js deleted file mode 100644 index e4ec4d514f0..00000000000 --- a/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.js +++ /dev/null @@ -1,357 +0,0 @@ -/* - * This file was automatically generated. - * DO NOT MODIFY BY HAND. - * Run `yarn special-lint-fix` to update - */ -'use strict'; -function r( - e, - { - instancePath: t = '', - parentData: n, - parentDataProperty: s, - rootData: a = e, - } = {}, -) { - let o = null, - i = 0; - if (0 === i) { - if (!e || 'object' != typeof e || Array.isArray(e)) - return (r.errors = [{ params: { type: 'object' } }]), !1; - { - const t = i; - for (const t in e) - if ( - 'eager' !== t && - 'import' !== t && - 'packageName' !== t && - 'requiredVersion' !== t && - 'shareKey' !== t && - 'shareScope' !== t && - 'singleton' !== t && - 'strictVersion' !== t - ) - return (r.errors = [{ params: { additionalProperty: t } }]), !1; - if (t === i) { - if (void 0 !== e.eager) { - const t = i; - if ('boolean' != typeof e.eager) - return (r.errors = [{ params: { type: 'boolean' } }]), !1; - var l = t === i; - } else l = !0; - if (l) { - if (void 0 !== e.import) { - let t = e.import; - const n = i, - s = i; - let a = !1; - const f = i; - if (!1 !== t) { - const r = { params: {} }; - null === o ? (o = [r]) : o.push(r), i++; - } - var p = f === i; - if (((a = a || p), !a)) { - const r = i; - if (i == i) - if ('string' == typeof t) { - if (t.length < 1) { - const r = { params: {} }; - null === o ? (o = [r]) : o.push(r), i++; - } - } else { - const r = { params: { type: 'string' } }; - null === o ? (o = [r]) : o.push(r), i++; - } - (p = r === i), (a = a || p); - } - if (!a) { - const e = { params: {} }; - return ( - null === o ? (o = [e]) : o.push(e), i++, (r.errors = o), !1 - ); - } - (i = s), - null !== o && (s ? (o.length = s) : (o = null)), - (l = n === i); - } else l = !0; - if (l) { - if (void 0 !== e.packageName) { - let t = e.packageName; - const n = i; - if (i === n) { - if ('string' != typeof t) - return (r.errors = [{ params: { type: 'string' } }]), !1; - if (t.length < 1) return (r.errors = [{ params: {} }]), !1; - } - l = n === i; - } else l = !0; - if (l) { - if (void 0 !== e.requiredVersion) { - let t = e.requiredVersion; - const n = i, - s = i; - let a = !1; - const p = i; - if (!1 !== t) { - const r = { params: {} }; - null === o ? (o = [r]) : o.push(r), i++; - } - var f = p === i; - if (((a = a || f), !a)) { - const r = i; - if ('string' != typeof t) { - const r = { params: { type: 'string' } }; - null === o ? (o = [r]) : o.push(r), i++; - } - (f = r === i), (a = a || f); - } - if (!a) { - const e = { params: {} }; - return ( - null === o ? (o = [e]) : o.push(e), i++, (r.errors = o), !1 - ); - } - (i = s), - null !== o && (s ? (o.length = s) : (o = null)), - (l = n === i); - } else l = !0; - if (l) { - if (void 0 !== e.shareKey) { - let t = e.shareKey; - const n = i; - if (i === n) { - if ('string' != typeof t) - return (r.errors = [{ params: { type: 'string' } }]), !1; - if (t.length < 1) return (r.errors = [{ params: {} }]), !1; - } - l = n === i; - } else l = !0; - if (l) { - if (void 0 !== e.shareScope) { - let t = e.shareScope; - const n = i; - if (i === n) { - if ('string' != typeof t) - return ( - (r.errors = [{ params: { type: 'string' } }]), !1 - ); - if (t.length < 1) - return (r.errors = [{ params: {} }]), !1; - } - l = n === i; - } else l = !0; - if (l) { - if (void 0 !== e.singleton) { - const t = i; - if ('boolean' != typeof e.singleton) - return ( - (r.errors = [{ params: { type: 'boolean' } }]), !1 - ); - l = t === i; - } else l = !0; - if (l) - if (void 0 !== e.strictVersion) { - const t = i; - if ('boolean' != typeof e.strictVersion) - return ( - (r.errors = [{ params: { type: 'boolean' } }]), !1 - ); - l = t === i; - } else l = !0; - } - } - } - } - } - } - } - } - } - return (r.errors = o), 0 === i; -} -function e( - t, - { - instancePath: n = '', - parentData: s, - parentDataProperty: a, - rootData: o = t, - } = {}, -) { - let i = null, - l = 0; - if (0 === l) { - if (!t || 'object' != typeof t || Array.isArray(t)) - return (e.errors = [{ params: { type: 'object' } }]), !1; - for (const s in t) { - let a = t[s]; - const f = l, - c = l; - let u = !1; - const y = l; - r(a, { - instancePath: n + '/' + s.replace(/~/g, '~0').replace(/\//g, '~1'), - parentData: t, - parentDataProperty: s, - rootData: o, - }) || ((i = null === i ? r.errors : i.concat(r.errors)), (l = i.length)); - var p = y === l; - if (((u = u || p), !u)) { - const r = l; - if (l == l) - if ('string' == typeof a) { - if (a.length < 1) { - const r = { params: {} }; - null === i ? (i = [r]) : i.push(r), l++; - } - } else { - const r = { params: { type: 'string' } }; - null === i ? (i = [r]) : i.push(r), l++; - } - (p = r === l), (u = u || p); - } - if (!u) { - const r = { params: {} }; - return null === i ? (i = [r]) : i.push(r), l++, (e.errors = i), !1; - } - if (((l = c), null !== i && (c ? (i.length = c) : (i = null)), f !== l)) - break; - } - } - return (e.errors = i), 0 === l; -} -function t( - r, - { - instancePath: n = '', - parentData: s, - parentDataProperty: a, - rootData: o = r, - } = {}, -) { - let i = null, - l = 0; - const p = l; - let f = !1; - const c = l; - if (l === c) - if (Array.isArray(r)) { - const t = r.length; - for (let s = 0; s < t; s++) { - let t = r[s]; - const a = l, - p = l; - let f = !1; - const c = l; - if (l == l) - if ('string' == typeof t) { - if (t.length < 1) { - const r = { params: {} }; - null === i ? (i = [r]) : i.push(r), l++; - } - } else { - const r = { params: { type: 'string' } }; - null === i ? (i = [r]) : i.push(r), l++; - } - var u = c === l; - if (((f = f || u), !f)) { - const a = l; - e(t, { - instancePath: n + '/' + s, - parentData: r, - parentDataProperty: s, - rootData: o, - }) || - ((i = null === i ? e.errors : i.concat(e.errors)), (l = i.length)), - (u = a === l), - (f = f || u); - } - if (f) (l = p), null !== i && (p ? (i.length = p) : (i = null)); - else { - const r = { params: {} }; - null === i ? (i = [r]) : i.push(r), l++; - } - if (a !== l) break; - } - } else { - const r = { params: { type: 'array' } }; - null === i ? (i = [r]) : i.push(r), l++; - } - var y = c === l; - if (((f = f || y), !f)) { - const t = l; - e(r, { - instancePath: n, - parentData: s, - parentDataProperty: a, - rootData: o, - }) || ((i = null === i ? e.errors : i.concat(e.errors)), (l = i.length)), - (y = t === l), - (f = f || y); - } - if (!f) { - const r = { params: {} }; - return null === i ? (i = [r]) : i.push(r), l++, (t.errors = i), !1; - } - return ( - (l = p), - null !== i && (p ? (i.length = p) : (i = null)), - (t.errors = i), - 0 === l - ); -} -function n( - r, - { - instancePath: e = '', - parentData: s, - parentDataProperty: a, - rootData: o = r, - } = {}, -) { - let i = null, - l = 0; - if (0 === l) { - if (!r || 'object' != typeof r || Array.isArray(r)) - return (n.errors = [{ params: { type: 'object' } }]), !1; - { - let s; - if (void 0 === r.consumes && (s = 'consumes')) - return (n.errors = [{ params: { missingProperty: s } }]), !1; - { - const s = l; - for (const e in r) - if ('consumes' !== e && 'shareScope' !== e) - return (n.errors = [{ params: { additionalProperty: e } }]), !1; - if (s === l) { - if (void 0 !== r.consumes) { - const n = l; - t(r.consumes, { - instancePath: e + '/consumes', - parentData: r, - parentDataProperty: 'consumes', - rootData: o, - }) || - ((i = null === i ? t.errors : i.concat(t.errors)), - (l = i.length)); - var p = n === l; - } else p = !0; - if (p) - if (void 0 !== r.shareScope) { - let e = r.shareScope; - const t = l; - if (l === t) { - if ('string' != typeof e) - return (n.errors = [{ params: { type: 'string' } }]), !1; - if (e.length < 1) return (n.errors = [{ params: {} }]), !1; - } - p = t === l; - } else p = !0; - } - } - } - } - return (n.errors = i), 0 === l; -} -(module.exports = n), (module.exports.default = n); diff --git a/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts b/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts index 325874270cf..fe7513f455d 100644 --- a/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts +++ b/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts @@ -49,7 +49,7 @@ const validateConsume: ValidationFunction = function validate( key !== 'singleton' && key !== 'strictVersion' && key !== 'issuerLayer' && - key !== 'layer' + key !== 'requiredLayer' ) { validate.errors = [{ params: { additionalProperty: key } }]; return false; diff --git a/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.json b/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.json deleted file mode 100644 index 346dfa3b2a4..00000000000 --- a/packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "definitions": { - "Consumes": { - "description": "Modules that should be consumed from share scope. When provided, property names are used to match requested modules in this compilation.", - "anyOf": [ - { - "type": "array", - "items": { - "description": "Modules that should be consumed from share scope.", - "anyOf": [ - { - "$ref": "#/definitions/ConsumesItem" - }, - { - "$ref": "#/definitions/ConsumesObject" - } - ] - } - }, - { - "$ref": "#/definitions/ConsumesObject" - } - ] - }, - "ConsumesConfig": { - "description": "Advanced configuration for modules that should be consumed from share scope.", - "type": "object", - "additionalProperties": false, - "properties": { - "eager": { - "description": "Include the fallback module directly instead behind an async request. This allows to use fallback module in initial load too. All possible shared modules need to be eager too.", - "type": "boolean" - }, - "import": { - "description": "Fallback module if no shared module is found in share scope. Defaults to the property name.", - "anyOf": [ - { - "description": "No fallback module.", - "enum": [false] - }, - { - "$ref": "#/definitions/ConsumesItem" - } - ] - }, - "issuerLayer": { - "description": "Layer in which the issuer should be.", - "type": "string", - "minLength": 1 - }, - "packageName": { - "description": "Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.", - "type": "string", - "minLength": 1 - }, - "requiredVersion": { - "description": "Version requirement from module in share scope.", - "anyOf": [ - { - "description": "No version requirement check.", - "enum": [false] - }, - { - "description": "Version as string. Can be prefixed with '^' or '~' for minimum matches. Each part of the version should be separated by a dot '.'.", - "type": "string" - } - ] - }, - "shareKey": { - "description": "Module is looked up under this key from the share scope.", - "type": "string", - "minLength": 1 - }, - "shareScope": { - "description": "Share scope name.", - "type": "string", - "minLength": 1 - }, - "singleton": { - "description": "Allow only a single version of the shared module in share scope (disabled by default).", - "type": "boolean" - }, - "strictVersion": { - "description": "Do not accept shared module if version is not valid (defaults to yes, if local fallback module is available and shared module is not a singleton, otherwise no, has no effect if there is no required version specified).", - "type": "boolean" - } - } - }, - "ConsumesItem": { - "description": "A module that should be consumed from share scope.", - "type": "string", - "minLength": 1 - }, - "ConsumesObject": { - "description": "Modules that should be consumed from share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.", - "type": "object", - "additionalProperties": { - "description": "Modules that should be consumed from share scope.", - "anyOf": [ - { - "$ref": "#/definitions/ConsumesConfig" - }, - { - "$ref": "#/definitions/ConsumesItem" - } - ] - } - } - }, - "title": "ConsumeSharedPluginOptions", - "description": "Options for consuming shared modules.", - "type": "object", - "additionalProperties": false, - "properties": { - "consumes": { - "$ref": "#/definitions/Consumes" - }, - "shareScope": { - "description": "Share scope name used for all consumed modules (defaults to 'default').", - "type": "string", - "minLength": 1 - }, - "layer": { - "description": "Layer in which modules should be placed in.", - "type": "string" - }, - "issuerLayer": { - "description": "Layer in which the issuer should be.", - "type": "string" - } - }, - "required": ["consumes"] -}