@absolutejs/absolute 0.19.0-beta.697 → 0.19.0-beta.699
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/browser.js.map +1 -1
- package/dist/angular/index.js +96 -16
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +96 -16
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +96 -16
- package/dist/build.js.map +3 -3
- package/dist/index.js +97 -17
- package/dist/index.js.map +4 -4
- package/dist/src/angular/components/defer-slot.component.d.ts +1 -1
- package/dist/src/core/prepare.d.ts +18 -0
- package/package.json +7 -7
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);\n\nexport { createStore };\n",
|
|
238
238
|
"const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst shouldDispatchFromDevtools = (api) => !!api.dispatchFromDevtools && typeof api.dispatch === \"function\";\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst findCallerName = (stack) => {\n var _a, _b;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return (_b = /.+ (.+) .+/.exec(callerLine)) == null ? void 0 : _b[1];\n};\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (shouldDispatchFromDevtools(api)) {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (shouldDispatchFromDevtools(api)) {\n api.dispatch(action);\n }\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => window.localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n let hydrationVersion = 0;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n const currentVersion = ++hydrationVersion;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n if (currentVersion !== hydrationVersion) {\n return;\n }\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nfunction ssrSafe(config, isSSR = typeof window === \"undefined\") {\n return (set, get, api) => {\n if (!isSSR) {\n return config(set, get, api);\n }\n const ssrSet = () => {\n throw new Error(\"Cannot set state of Zustand store in SSR\");\n };\n api.setState = ssrSet;\n return config(ssrSet, get, api);\n };\n}\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector, ssrSafe as unstable_ssrSafe };\n",
|
|
239
239
|
"import { createStore, type StateCreator, type StoreApi } from 'zustand/vanilla';\nimport { combine } from 'zustand/middleware';\n\nexport type IslandStoreState = object;\ntype IslandStoreSnapshot = Record<string, unknown>;\ntype IslandStoreShape<\n\tTState extends IslandStoreState,\n\tTActions extends object\n> = Omit<TState, keyof TActions> & TActions;\nexport type IslandStateSnapshot = Record<string, IslandStoreSnapshot>;\ntype AnyIslandStore = StoreApi<object>;\ntype IslandStoreInstance = {\n\tapplyExternalSnapshot: (snapshot: IslandStoreSnapshot) => void;\n\tstore: AnyIslandStore;\n};\n\nconst ABSOLUTE_ISLAND_STATE = '__ABS_ISLAND_STATE__';\nconst ABSOLUTE_ISLAND_STORES = '__ABS_ISLAND_STORES__';\n\ndeclare global {\n\tvar __ABS_ISLAND_STATE__: IslandStateSnapshot | undefined;\n\tvar __ABS_ISLAND_STORES__:\n\t\t| Map<string, Set<IslandStoreInstance>>\n\t\t| undefined;\n}\n\nconst getIslandStoreSnapshot = () => {\n\tglobalThis.__ABS_ISLAND_STATE__ ??= {};\n\n\treturn globalThis.__ABS_ISLAND_STATE__;\n};\n\nconst getIslandStores = () => {\n\tglobalThis.__ABS_ISLAND_STORES__ ??= new Map();\n\n\treturn globalThis.__ABS_ISLAND_STORES__;\n};\n\nconst isSerializableValue = (value: unknown) =>\n\ttypeof value !== 'function' && value !== undefined;\n\nconst toSerializableState = <T extends object>(state: T) =>\n\tObject.fromEntries(\n\t\tObject.entries(state).filter(([, value]) => isSerializableValue(value))\n\t);\n\nconst applySnapshot = <T extends object>(\n\tstore: StoreApi<T>,\n\tsnapshot: IslandStoreSnapshot | undefined\n) => {\n\tif (!snapshot) {\n\t\treturn;\n\t}\n\n\tstore.setState({\n\t\t...store.getState(),\n\t\t...snapshot\n\t});\n};\n\nconst getPeerStores = (\n\tstoreInstances: Set<IslandStoreInstance>,\n\townerStore: AnyIslandStore\n) => [...storeInstances].filter((peer) => peer.store !== ownerStore);\n\nconst syncIslandSnapshot = <\n\tTState extends IslandStoreState,\n\tTActions extends object\n>(\n\tstoreId: string,\n\tstate: IslandStoreShape<TState, TActions>,\n\tstoreInstances: Set<IslandStoreInstance>,\n\townerStore: AnyIslandStore\n) => {\n\tconst nextSnapshot = toSerializableState(state);\n\tgetIslandStoreSnapshot()[storeId] = nextSnapshot;\n\n\tfor (const peerStore of getPeerStores(storeInstances, ownerStore)) {\n\t\tpeerStore.applyExternalSnapshot(nextSnapshot);\n\t}\n};\n\nexport const createIslandStore = <\n\tTState extends IslandStoreState,\n\tTActions extends object\n>(\n\tstoreId: string,\n\tinitialState: TState,\n\tcreateState: StateCreator<TState, [], [], TActions>\n) => {\n\tconst store = createStore(combine(initialState, createState));\n\tconst stores = getIslandStores();\n\tconst storeInstances =\n\t\tstores.get(storeId) ?? new Set<IslandStoreInstance>();\n\tconst initialSnapshot = getIslandStoreSnapshot()[storeId];\n\tapplySnapshot(store, initialSnapshot);\n\tlet isApplyingExternalSnapshot = false;\n\n\tconst applyExternalSnapshot = (snapshot: IslandStoreSnapshot) => {\n\t\tisApplyingExternalSnapshot = true;\n\t\tapplySnapshot(store, snapshot);\n\t};\n\n\tstoreInstances.add({\n\t\tapplyExternalSnapshot,\n\t\tstore\n\t});\n\tstores.set(storeId, storeInstances);\n\n\tsyncIslandSnapshot(storeId, store.getState(), storeInstances, store);\n\tstore.subscribe((state) => {\n\t\tif (isApplyingExternalSnapshot) {\n\t\t\tisApplyingExternalSnapshot = false;\n\n\t\t\treturn;\n\t\t}\n\n\t\tsyncIslandSnapshot(storeId, state, storeInstances, store);\n\t});\n\n\treturn store;\n};\nexport const getIslandStoreServerSnapshot = <\n\tTState extends IslandStoreState,\n\tTSelected\n>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected\n) => selector(store.getInitialState());\nconst applySnapshotToStoreInstances = (\n\tstoreId: string,\n\tinstances: Set<IslandStoreInstance>,\n\tsnapshot: IslandStateSnapshot\n) => {\n\tfor (const instance of instances) {\n\t\tinstance.applyExternalSnapshot(snapshot[storeId] ?? {});\n\t}\n};\n\nexport const initializeIslandStores = (state: IslandStateSnapshot) => {\n\tconst currentSnapshot = getIslandStoreSnapshot();\n\tconst nextSnapshot: IslandStateSnapshot = {\n\t\t...state,\n\t\t...currentSnapshot\n\t};\n\n\tglobalThis.__ABS_ISLAND_STATE__ = nextSnapshot;\n\n\tfor (const [storeId, store] of getIslandStores()) {\n\t\tapplySnapshotToStoreInstances(storeId, store, nextSnapshot);\n\t}\n};\nexport const readIslandStore = <TState extends IslandStoreState, TSelected>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected\n) => selector(store.getState());\nexport const resetIslandStoreForTesting = () => {\n\tdelete globalThis.__ABS_ISLAND_STATE__;\n\tdelete globalThis.__ABS_ISLAND_STORES__;\n};\nexport const subscribeIslandStore = <\n\tTState extends IslandStoreState,\n\tTSelected\n>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected,\n\tlistener: (value: TSelected) => void\n) => {\n\tlet currentSelection = selector(store.getState());\n\n\treturn store.subscribe((state) => {\n\t\tconst nextSelection = selector(state);\n\t\tif (Object.is(nextSelection, currentSelection)) {\n\t\t\treturn;\n\t\t}\n\n\t\tcurrentSelection = nextSelection;\n\t\tlistener(nextSelection);\n\t});\n};\n\nexport { ABSOLUTE_ISLAND_STATE, ABSOLUTE_ISLAND_STORES };\n",
|
|
240
|
-
"import {\n\tChangeDetectionStrategy,\n\tChangeDetectorRef,\n\
|
|
240
|
+
"import {\n\tChangeDetectionStrategy,\n\tChangeDetectorRef,\n\ttype AfterViewInit,\n\tComponent,\n\tContentChild,\n\tInput,\n\tinject,\n\tsignal\n} from '@angular/core';\nimport { NgTemplateOutlet } from '@angular/common';\nimport {\n\tisStreamingSlotCollectionActive,\n\tregisterStreamingSlot,\n\twarnMissingStreamingSlotCollector\n} from '../../core/streamingSlotRegistrar';\nimport {\n\ttype AngularDeferSlotPayload,\n\tisAngularDeferSlotPayload\n} from './defer-slot-payload';\nimport {\n\ttype DeferSlotTemplateContext,\n\tDeferErrorTemplateDirective,\n\tDeferFallbackTemplateDirective,\n\tDeferResolvedTemplateDirective\n} from './defer-slot-templates.directive';\n\ntype DeferSlotResolver = () => Promise<AngularDeferSlotPayload>;\n\ntype DeferSlotState = 'error' | 'fallback' | 'resolved';\n\n@Component({\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\timports: [\n\t\tNgTemplateOutlet,\n\t\tDeferResolvedTemplateDirective,\n\t\tDeferFallbackTemplateDirective,\n\t\tDeferErrorTemplateDirective\n\t],\n\tselector: 'abs-defer-slot',\n\tstandalone: true,\n\ttemplate: `\n\t\t<div [attr.id]=\"id\" [attr.class]=\"className\" data-absolute-slot=\"true\">\n\t\t\t<ng-container\n\t\t\t\t[ngTemplateOutlet]=\"activeTemplate()\"\n\t\t\t\t[ngTemplateOutletContext]=\"templateContext()\"\n\t\t\t></ng-container>\n\t\t</div>\n\t`\n})\nexport class DeferSlotComponent implements AfterViewInit {\n\tprivate readonly cdr = inject(ChangeDetectorRef);\n\tprivate readonly runtimeReady = signal(false);\n\tprivate serverSlotRegistered = false;\n\n\t@Input() className?: string;\n\t@Input() id = '';\n\t@Input() resolve?: DeferSlotResolver;\n\t@ContentChild(DeferResolvedTemplateDirective)\n\tresolvedTemplate?: DeferResolvedTemplateDirective;\n\t@ContentChild(DeferFallbackTemplateDirective)\n\tfallbackTemplate?: DeferFallbackTemplateDirective;\n\t@ContentChild(DeferErrorTemplateDirective)\n\terrorTemplate?: DeferErrorTemplateDirective;\n\treadonly slotData = signal<Record<string, string>>({});\n\treadonly state = signal<DeferSlotState>('fallback');\n\n\treadonly activeTemplate = () => {\n\t\tif (this.state() === 'resolved') {\n\t\t\treturn this.resolvedTemplate?.templateRef ?? null;\n\t\t}\n\n\t\tif (this.state() === 'error') {\n\t\t\treturn (\n\t\t\t\tthis.errorTemplate?.templateRef ??\n\t\t\t\tthis.fallbackTemplate?.templateRef ??\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\tthis.fallbackTemplate?.templateRef ??\n\t\t\tthis.resolvedTemplate?.templateRef ??\n\t\t\tnull\n\t\t);\n\t};\n\n\treadonly templateContext = (): DeferSlotTemplateContext => {\n\t\tconst slotData = this.slotData();\n\n\t\treturn {\n\t\t\t$implicit: slotData,\n\t\t\tslotData\n\t\t};\n\t};\n\n\tngOnInit() {\n\t\tconst { id } = this;\n\t\tif (!id) return;\n\n\t\tif (this.registerServerSlot()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst consumers = (window.__ABS_SLOT_CONSUMERS__ =\n\t\t\twindow.__ABS_SLOT_CONSUMERS__ ?? {});\n\t\tconsumers[id] = (payload) => {\n\t\t\tif (!this.runtimeReady()) return false;\n\t\t\tthis.applyPatchPayload(payload);\n\n\t\t\treturn true;\n\t\t};\n\t}\n\n\tngAfterViewInit() {\n\t\tif (this.registerServerSlot()) return;\n\t\tif (typeof window === 'undefined') return;\n\n\t\trequestAnimationFrame(() => {\n\t\t\tthis.runtimeReady.set(true);\n\t\t\tthis.cdr.markForCheck();\n\t\t\twindow.__ABS_SLOT_FLUSH__?.();\n\t\t});\n\t}\n\n\tngOnDestroy() {\n\t\tif (typeof window === 'undefined') return;\n\t\tconst { id } = this;\n\t\tif (!id) return;\n\t\tdelete window.__ABS_SLOT_CONSUMERS__?.[id];\n\t}\n\n\tprivate registerServerSlot() {\n\t\tconst { id, resolve } = this;\n\t\tif (this.serverSlotRegistered || !id || !resolve) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!isStreamingSlotCollectionActive()) {\n\t\t\twarnMissingStreamingSlotCollector('DeferSlot');\n\n\t\t\treturn false;\n\t\t}\n\n\t\tregisterStreamingSlot({\n\t\t\tid,\n\t\t\tresolve\n\t\t});\n\t\tthis.serverSlotRegistered = true;\n\n\t\treturn true;\n\t}\n\n\tprivate applyPatchPayload(payload: unknown) {\n\t\tif (payload === null || typeof payload === 'undefined') return;\n\n\t\tif (isAngularDeferSlotPayload(payload)) {\n\t\t\tconst data =\n\t\t\t\tpayload.data && typeof payload.data === 'object'\n\t\t\t\t\t? payload.data\n\t\t\t\t\t: {};\n\t\t\tthis.slotData.set(data);\n\t\t\tthis.state.set(payload.state === 'error' ? 'error' : 'resolved');\n\t\t\tthis.cdr.markForCheck();\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.slotData.set({});\n\t\tthis.state.set(payload === '' ? 'fallback' : 'resolved');\n\t\tthis.cdr.markForCheck();\n\t}\n}\n",
|
|
241
241
|
"export type AngularDeferSlotPayload = {\n\tdata?: Record<string, string>;\n\thtml: string;\n\tkind: 'angular-defer';\n\tstate?: 'error' | 'resolved';\n};\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object';\n\nexport const isAngularDeferSlotPayload = (\n\tvalue: unknown\n): value is AngularDeferSlotPayload => {\n\tif (!isObjectRecord(value)) return false;\n\n\treturn value.kind === 'angular-defer' && typeof value.html === 'string';\n};\n",
|
|
242
242
|
"import { Directive, TemplateRef, inject } from '@angular/core';\n\nexport type DeferSlotTemplateContext = {\n\t$implicit: Record<string, string>;\n\tslotData: Record<string, string>;\n};\n\n@Directive({\n\tselector: 'ng-template[absDeferError]',\n\tstandalone: true\n})\nexport class DeferErrorTemplateDirective {\n\treadonly templateRef = inject<TemplateRef<unknown>>(TemplateRef);\n}\n\n@Directive({\n\tselector: 'ng-template[absDeferFallback]',\n\tstandalone: true\n})\nexport class DeferFallbackTemplateDirective {\n\treadonly templateRef = inject<TemplateRef<unknown>>(TemplateRef);\n}\n\n@Directive({\n\tselector: 'ng-template[absDeferResolved]',\n\tstandalone: true\n})\nexport class DeferResolvedTemplateDirective {\n\treadonly templateRef =\n\t\tinject<TemplateRef<DeferSlotTemplateContext>>(TemplateRef);\n}\n",
|
|
243
243
|
"import { Component, computed, input, signal } from '@angular/core';\nimport { NgStyle } from '@angular/common';\nimport {\n\tDEFAULT_QUALITY,\n\tbuildOptimizedUrl,\n\tgenerateBlurSvg,\n\tgenerateSrcSet\n} from '../../utils/imageProcessing';\n\n/** Resolve the blur background CSS value from placeholder config */\nconst resolveBlurBg = (\n\tplaceholderValue: string,\n\tblurDataUrl: string | undefined\n) => {\n\tif (\n\t\ttypeof placeholderValue === 'string' &&\n\t\tplaceholderValue !== 'blur' &&\n\t\tplaceholderValue.startsWith('data:')\n\t) {\n\t\treturn generateBlurSvg(placeholderValue);\n\t}\n\n\tif (blurDataUrl) return generateBlurSvg(blurDataUrl);\n\n\treturn undefined;\n};\n\n@Component({\n\timports: [NgStyle],\n\tselector: 'abs-image',\n\tstandalone: true,\n\ttemplate: `\n\t\t@if (fill()) {\n\t\t\t<span\n\t\t\t\tstyle=\"position:relative;overflow:hidden;display:block;width:100%;height:100%\"\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\t[alt]=\"alt()\"\n\t\t\t\t\t[src]=\"resolvedSrc()\"\n\t\t\t\t\t[attr.srcset]=\"resolvedSrcSet()\"\n\t\t\t\t\t[attr.sizes]=\"resolvedSizes()\"\n\t\t\t\t\t[loading]=\"resolvedLoading()\"\n\t\t\t\t\t[class]=\"className()\"\n\t\t\t\t\t[ngStyle]=\"imgStyle()\"\n\t\t\t\t\t[attr.crossorigin]=\"resolvedCrossOrigin()\"\n\t\t\t\t\t[attr.referrerpolicy]=\"resolvedReferrerPolicy()\"\n\t\t\t\t\t[attr.fetchpriority]=\"resolvedFetchPriority()\"\n\t\t\t\t\tdecoding=\"async\"\n\t\t\t\t\t(load)=\"handleLoad($event)\"\n\t\t\t\t\t(error)=\"handleError($event)\"\n\t\t\t\t/>\n\t\t\t</span>\n\t\t} @else {\n\t\t\t<img\n\t\t\t\t[alt]=\"alt()\"\n\t\t\t\t[src]=\"resolvedSrc()\"\n\t\t\t\t[attr.srcset]=\"resolvedSrcSet()\"\n\t\t\t\t[attr.sizes]=\"resolvedSizes()\"\n\t\t\t\t[width]=\"width()\"\n\t\t\t\t[height]=\"height()\"\n\t\t\t\t[loading]=\"resolvedLoading()\"\n\t\t\t\t[class]=\"className()\"\n\t\t\t\t[ngStyle]=\"imgStyle()\"\n\t\t\t\t[attr.crossorigin]=\"resolvedCrossOrigin()\"\n\t\t\t\t[attr.referrerpolicy]=\"resolvedReferrerPolicy()\"\n\t\t\t\t[attr.fetchpriority]=\"resolvedFetchPriority()\"\n\t\t\t\tdecoding=\"async\"\n\t\t\t\t(load)=\"handleLoad($event)\"\n\t\t\t\t(error)=\"handleError($event)\"\n\t\t\t/>\n\t\t}\n\t`\n})\nexport class ImageComponent {\n\t// ── Inputs ──────────────────────────────────────────────────\n\treadonly alt = input.required<string>();\n\treadonly blurDataURL = input<string>();\n\treadonly className = input<string>();\n\treadonly crossOrigin = input<'anonymous' | 'use-credentials' | ''>();\n\treadonly fetchPriority = input<'high' | 'low' | 'auto'>();\n\treadonly fill = input(false);\n\treadonly height = input<number>();\n\treadonly loader =\n\t\tinput<\n\t\t\t(params: { src: string; width: number; quality: number }) => string\n\t\t>();\n\treadonly loading = input<'lazy' | 'eager'>('lazy');\n\treadonly onError = input<(event: Event) => void>();\n\treadonly onLoad = input<(event: Event) => void>();\n\treadonly overrideSrc = input<string>();\n\treadonly placeholder = input<'blur' | 'empty' | string>('empty');\n\treadonly priority = input(false);\n\treadonly quality = input(DEFAULT_QUALITY);\n\treadonly referrerPolicy = input<string>();\n\treadonly sizes = input<string>();\n\treadonly src = input.required<string>();\n\treadonly style = input<Record<string, string | number>>();\n\treadonly unoptimized = input(false);\n\treadonly width = input<number>();\n\n\t// ── Internal state ──────────────────────────────────────────\n\tprivate readonly blurRemoved = signal(false);\n\n\t// ── Computed ────────────────────────────────────────────────\n\treadonly resolvedSrc = computed(() => {\n\t\tconst override = this.overrideSrc();\n\n\t\tif (override) return override;\n\n\t\tif (this.unoptimized()) return this.src();\n\n\t\tconst loaderFn = this.loader();\n\n\t\tif (loaderFn)\n\t\t\treturn loaderFn({\n\t\t\t\tquality: this.quality(),\n\t\t\t\tsrc: this.src(),\n\t\t\t\twidth: this.width() ?? 0\n\t\t\t});\n\n\t\tconst currentWidth = this.width();\n\n\t\tif (!currentWidth)\n\t\t\treturn buildOptimizedUrl(this.src(), 0, this.quality());\n\n\t\treturn buildOptimizedUrl(this.src(), currentWidth, this.quality());\n\t});\n\n\treadonly srcSet = computed(() =>\n\t\tthis.unoptimized()\n\t\t\t? null\n\t\t\t: (generateSrcSet(\n\t\t\t\t\tthis.src(),\n\t\t\t\t\tthis.width(),\n\t\t\t\t\tthis.sizes(),\n\t\t\t\t\tundefined,\n\t\t\t\t\tthis.loader() ?? undefined\n\t\t\t\t) ?? null)\n\t);\n\n\treadonly resolvedSrcSet = computed(() => this.srcSet() ?? null);\n\n\treadonly resolvedSizes = computed(\n\t\t() => this.sizes() ?? (this.fill() ? '100vw' : null)\n\t);\n\n\treadonly resolvedCrossOrigin = computed(() => this.crossOrigin() ?? null);\n\n\treadonly resolvedReferrerPolicy = computed(\n\t\t() => this.referrerPolicy() ?? null\n\t);\n\n\treadonly resolvedLoading = computed(() =>\n\t\tthis.priority() ? ('eager' as const) : this.loading()\n\t);\n\n\treadonly resolvedFetchPriority = computed(() =>\n\t\tthis.priority() ? 'high' : (this.fetchPriority() ?? null)\n\t);\n\n\treadonly imgStyle = computed(() => {\n\t\tconst base: Record<string, string | number> = {\n\t\t\t...(this.style() ?? {}),\n\t\t\tcolor: 'transparent'\n\t\t};\n\n\t\tconst hasBlur =\n\t\t\t!this.blurRemoved() &&\n\t\t\t(this.placeholder() === 'blur' ||\n\t\t\t\t(typeof this.placeholder() === 'string' &&\n\t\t\t\t\tthis.placeholder() !== 'empty' &&\n\t\t\t\t\t(this.placeholder() ?? '').startsWith('data:')));\n\n\t\tconst blurValue = hasBlur\n\t\t\t? resolveBlurBg(this.placeholder(), this.blurDataURL())\n\t\t\t: undefined;\n\n\t\tif (blurValue) {\n\t\t\tbase['background-image'] = blurValue;\n\t\t\tbase['background-position'] = 'center';\n\t\t\tbase['background-repeat'] = 'no-repeat';\n\t\t\tbase['background-size'] = 'cover';\n\t\t}\n\n\t\tif (this.fill()) {\n\t\t\tbase.height = '100%';\n\t\t\tbase.inset = '0';\n\t\t\tbase['object-fit'] = 'cover';\n\t\t\tbase.position = 'absolute';\n\t\t\tbase.width = '100%';\n\t\t}\n\n\t\treturn base;\n\t});\n\n\t// ── Event handlers ──────────────────────────────────────────\n\thandleLoad(event: Event) {\n\t\tthis.blurRemoved.set(true);\n\n\t\tconst callback = this.onLoad();\n\n\t\tif (callback) callback(event);\n\t}\n\n\thandleError(event: Event) {\n\t\tconst callback = this.onError();\n\n\t\tif (callback) callback(event);\n\t}\n}\n",
|
package/dist/angular/index.js
CHANGED
|
@@ -3106,6 +3106,37 @@ var computeConfigHash = () => {
|
|
|
3106
3106
|
} catch {
|
|
3107
3107
|
return "";
|
|
3108
3108
|
}
|
|
3109
|
+
}, readTsconfigPathAliases = () => {
|
|
3110
|
+
try {
|
|
3111
|
+
const configPath = resolve6(process.cwd(), "tsconfig.json");
|
|
3112
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
|
|
3113
|
+
const compilerOptions = config?.compilerOptions ?? {};
|
|
3114
|
+
const baseUrl = resolve6(process.cwd(), compilerOptions.baseUrl ?? ".");
|
|
3115
|
+
const aliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, replacements]) => ({ pattern, replacements }));
|
|
3116
|
+
return { aliases, baseUrl };
|
|
3117
|
+
} catch {
|
|
3118
|
+
return { aliases: [], baseUrl: process.cwd() };
|
|
3119
|
+
}
|
|
3120
|
+
}, matchTsconfigAlias = (specifier, aliases, baseUrl, resolveSourceFile) => {
|
|
3121
|
+
for (const alias of aliases) {
|
|
3122
|
+
const wildcardIndex = alias.pattern.indexOf("*");
|
|
3123
|
+
const exactMatch = wildcardIndex === -1;
|
|
3124
|
+
if (exactMatch && specifier !== alias.pattern)
|
|
3125
|
+
continue;
|
|
3126
|
+
const prefix = exactMatch ? alias.pattern : alias.pattern.slice(0, wildcardIndex);
|
|
3127
|
+
const suffix = exactMatch ? "" : alias.pattern.slice(wildcardIndex + 1);
|
|
3128
|
+
if (!exactMatch && (!specifier.startsWith(prefix) || !specifier.endsWith(suffix))) {
|
|
3129
|
+
continue;
|
|
3130
|
+
}
|
|
3131
|
+
const wildcardValue = exactMatch ? "" : specifier.slice(prefix.length, specifier.length - suffix.length);
|
|
3132
|
+
for (const replacement of alias.replacements) {
|
|
3133
|
+
const candidate = replacement.replace("*", wildcardValue);
|
|
3134
|
+
const resolved = resolveSourceFile(resolve6(baseUrl, candidate));
|
|
3135
|
+
if (resolved)
|
|
3136
|
+
return resolved;
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
return;
|
|
3109
3140
|
}, resolveDevClientDir = () => {
|
|
3110
3141
|
const projectRoot = process.cwd();
|
|
3111
3142
|
const fromSource = resolve6(import.meta.dir, "../dev/client");
|
|
@@ -3471,8 +3502,9 @@ ${slot.resolvedBindings.map((binding) => ` "${binding.key}": this.__absoluteDef
|
|
|
3471
3502
|
${fields}
|
|
3472
3503
|
`);
|
|
3473
3504
|
}, readAndEscapeFile = async (filePath, stylePreprocessors) => {
|
|
3474
|
-
if (!existsSync5(filePath))
|
|
3475
|
-
|
|
3505
|
+
if (!existsSync5(filePath)) {
|
|
3506
|
+
throw new Error(`Unable to inline Angular style resource: file not found at ${filePath}`);
|
|
3507
|
+
}
|
|
3476
3508
|
const content = await compileStyleFileIfNeeded(filePath, stylePreprocessors);
|
|
3477
3509
|
return escapeTemplateContent(content);
|
|
3478
3510
|
}, inlineTemplateAndLowerDefer = async (source, fileDir) => {
|
|
@@ -3480,7 +3512,7 @@ ${fields}
|
|
|
3480
3512
|
if (templateUrlMatch?.[1]) {
|
|
3481
3513
|
const templatePath = join5(fileDir, templateUrlMatch[1]);
|
|
3482
3514
|
if (!existsSync5(templatePath)) {
|
|
3483
|
-
|
|
3515
|
+
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
3484
3516
|
}
|
|
3485
3517
|
const templateRaw2 = await fs.readFile(templatePath, "utf-8");
|
|
3486
3518
|
const lowered2 = lowerAngularDeferSyntax(templateRaw2);
|
|
@@ -3511,7 +3543,7 @@ ${fields}
|
|
|
3511
3543
|
if (templateUrlMatch?.[1]) {
|
|
3512
3544
|
const templatePath = join5(fileDir, templateUrlMatch[1]);
|
|
3513
3545
|
if (!existsSync5(templatePath)) {
|
|
3514
|
-
|
|
3546
|
+
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
3515
3547
|
}
|
|
3516
3548
|
const templateRaw2 = readFileSync4(templatePath, "utf-8");
|
|
3517
3549
|
const lowered2 = lowerAngularDeferSyntax(templateRaw2);
|
|
@@ -3584,9 +3616,52 @@ ${fields}
|
|
|
3584
3616
|
}
|
|
3585
3617
|
})
|
|
3586
3618
|
});
|
|
3587
|
-
const
|
|
3619
|
+
const tsconfigAliases = readTsconfigPathAliases();
|
|
3620
|
+
const resolveSourceFile = (candidate) => {
|
|
3621
|
+
const candidates = candidate.match(/\.[cm]?[tj]sx?$/) ? [candidate] : [
|
|
3622
|
+
`${candidate}.ts`,
|
|
3623
|
+
`${candidate}.tsx`,
|
|
3624
|
+
`${candidate}.js`,
|
|
3625
|
+
`${candidate}.jsx`,
|
|
3626
|
+
join5(candidate, "index.ts"),
|
|
3627
|
+
join5(candidate, "index.tsx"),
|
|
3628
|
+
join5(candidate, "index.js"),
|
|
3629
|
+
join5(candidate, "index.jsx")
|
|
3630
|
+
];
|
|
3631
|
+
return candidates.find((file) => existsSync5(file));
|
|
3632
|
+
};
|
|
3633
|
+
const resolveLocalImport = (specifier, fromDir) => {
|
|
3634
|
+
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3635
|
+
return resolveSourceFile(resolve6(fromDir, specifier));
|
|
3636
|
+
}
|
|
3637
|
+
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile);
|
|
3638
|
+
if (aliased)
|
|
3639
|
+
return aliased;
|
|
3640
|
+
try {
|
|
3641
|
+
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
3642
|
+
if (resolved.includes("/node_modules/"))
|
|
3643
|
+
return;
|
|
3644
|
+
const absolute = resolve6(resolved);
|
|
3645
|
+
if (!absolute.startsWith(baseDir))
|
|
3646
|
+
return;
|
|
3647
|
+
return resolveSourceFile(absolute);
|
|
3648
|
+
} catch {
|
|
3649
|
+
return;
|
|
3650
|
+
}
|
|
3651
|
+
};
|
|
3652
|
+
const toOutputPath = (sourcePath) => {
|
|
3653
|
+
const inputDir = dirname4(sourcePath);
|
|
3654
|
+
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
3655
|
+
const fileBase = basename3(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
3656
|
+
return join5(outDir, relativeDir, fileBase);
|
|
3657
|
+
};
|
|
3658
|
+
const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
|
|
3588
3659
|
let processedContent = angularTranspiler.transformSync(sourceCode);
|
|
3589
3660
|
const rewriteBareImport = (prefix, specifier, suffix) => {
|
|
3661
|
+
const rewritten = importRewrites.get(specifier);
|
|
3662
|
+
if (rewritten) {
|
|
3663
|
+
return `${prefix}${rewritten}${suffix}`;
|
|
3664
|
+
}
|
|
3590
3665
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3591
3666
|
return `${prefix}${specifier}${suffix}`;
|
|
3592
3667
|
}
|
|
@@ -3631,12 +3706,13 @@ ${fields}
|
|
|
3631
3706
|
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname4(actualPath)).source;
|
|
3632
3707
|
const inputDir = dirname4(actualPath);
|
|
3633
3708
|
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
3634
|
-
const fileBase = basename3(actualPath).replace(/\.
|
|
3709
|
+
const fileBase = basename3(actualPath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
3635
3710
|
const targetDir = join5(outDir, relativeDir);
|
|
3636
|
-
const targetPath =
|
|
3711
|
+
const targetPath = toOutputPath(actualPath);
|
|
3637
3712
|
const localImports = [];
|
|
3638
|
-
const
|
|
3639
|
-
const
|
|
3713
|
+
const importRewrites = new Map;
|
|
3714
|
+
const fromRegex = /(?:from|import)\s+['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]/g;
|
|
3715
|
+
const dynamicImportRegex = /import\(\s*['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]\s*\)/g;
|
|
3640
3716
|
let importMatch;
|
|
3641
3717
|
while ((importMatch = fromRegex.exec(sourceCode)) !== null) {
|
|
3642
3718
|
if (importMatch[1])
|
|
@@ -3646,22 +3722,26 @@ ${fields}
|
|
|
3646
3722
|
if (importMatch[1])
|
|
3647
3723
|
localImports.push(importMatch[1]);
|
|
3648
3724
|
}
|
|
3725
|
+
const localImportPaths = localImports.map((specifier) => {
|
|
3726
|
+
const resolved2 = resolveLocalImport(specifier, inputDir);
|
|
3727
|
+
if (!resolved2)
|
|
3728
|
+
return null;
|
|
3729
|
+
const relativeImport = relative3(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
|
|
3730
|
+
importRewrites.set(specifier, relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`);
|
|
3731
|
+
return resolved2;
|
|
3732
|
+
}).filter((path) => Boolean(path));
|
|
3649
3733
|
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
3650
3734
|
const cacheKey = actualPath;
|
|
3651
3735
|
if (jitContentCache.get(cacheKey) === contentHash && existsSync5(targetPath)) {
|
|
3652
3736
|
allOutputs.push(targetPath);
|
|
3653
3737
|
} else {
|
|
3654
|
-
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath);
|
|
3738
|
+
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
|
|
3655
3739
|
await fs.mkdir(targetDir, { recursive: true });
|
|
3656
3740
|
await fs.writeFile(targetPath, processedContent, "utf-8");
|
|
3657
3741
|
allOutputs.push(targetPath);
|
|
3658
3742
|
jitContentCache.set(cacheKey, contentHash);
|
|
3659
3743
|
}
|
|
3660
|
-
|
|
3661
|
-
await Promise.all(localImports.map((imp) => {
|
|
3662
|
-
const importPath = resolve6(inputDirForResolve, imp);
|
|
3663
|
-
return transpileFile(importPath);
|
|
3664
|
-
}));
|
|
3744
|
+
await Promise.all(localImportPaths.map((importPath) => transpileFile(importPath)));
|
|
3665
3745
|
};
|
|
3666
3746
|
await transpileFile(inputPath);
|
|
3667
3747
|
return allOutputs;
|
|
@@ -14136,5 +14216,5 @@ export {
|
|
|
14136
14216
|
Island
|
|
14137
14217
|
};
|
|
14138
14218
|
|
|
14139
|
-
//# debugId=
|
|
14219
|
+
//# debugId=72803DF1FE68786864756E2164756E21
|
|
14140
14220
|
//# sourceMappingURL=index.js.map
|